Work on the ue wingman manual
This commit is contained in:
@@ -12,16 +12,19 @@ class UWing_Documentation_Manual : public UWingHandler
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere, meta=(Optional, Description="If specified, print only this section of the manual"))
|
UPROPERTY(EditAnywhere, meta=(Optional, Description="section of the manual"))
|
||||||
FString Section;
|
FString Section;
|
||||||
|
|
||||||
virtual void Register() override
|
virtual void Register() override
|
||||||
{
|
{
|
||||||
UWingServer::AddHandler(this,
|
TStringBuilder<128> Docs;
|
||||||
TEXT("Print the user manual."));
|
Docs.Append(TEXT("Print a section of the manual. Valid sections: "));
|
||||||
|
WingManual::PrintSectionNames(nullptr, WingManual::GetSections(), Docs);
|
||||||
|
UWingServer::AddHandler(this, Docs.ToString());
|
||||||
}
|
}
|
||||||
virtual void Handle() override
|
virtual void Handle() override
|
||||||
{
|
{
|
||||||
|
TSet<FName> Sections = WingManual::GetSections();
|
||||||
if (Section.IsEmpty())
|
if (Section.IsEmpty())
|
||||||
{
|
{
|
||||||
UWingManualSections::FetcherPaths();
|
UWingManualSections::FetcherPaths();
|
||||||
@@ -34,10 +37,15 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FName SectionName(*Section);
|
FName SectionName(*Section);
|
||||||
if (!WingManual::PrintSection(SectionName))
|
if (WingManual::PrintSection(SectionName))
|
||||||
{
|
{
|
||||||
WingOut::Stdout.Printf(TEXT("ERROR: Unknown manual section '%s'\nAvailable sections: "), *Section);
|
WingOut::Stdout.Printf(TEXT("\n"));
|
||||||
WingManual::PrintSectionNames(WingManual::GetSections());
|
WingManual::PrintSectionNames(TEXT("Other manual sections:"), Sections, WingOut::Stdout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WingOut::Stdout.Printf(TEXT("Unknown manual section '%s'\n"));
|
||||||
|
WingManual::PrintSectionNames(TEXT("Valid manual sections:"), Sections, WingOut::Stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,9 +185,6 @@ void UWingManualSections::ImportantCommands()
|
|||||||
"\n You can use Documentation_Commands(Query=Command,Verbose=true)"
|
"\n You can use Documentation_Commands(Query=Command,Verbose=true)"
|
||||||
"\n to get detailed help for a specific command."
|
"\n to get detailed help for a specific command."
|
||||||
"\n"
|
"\n"
|
||||||
"\n You can use Documentation_Manual(Section=Name) to print out"
|
|
||||||
"\n a specific manual section."
|
|
||||||
"\n"
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,17 +198,18 @@ TSet<FName> WingManual::GetSections()
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WingManual::PrintSectionNames(const TSet<FName>& Sections)
|
void WingManual::PrintSectionNames(const TCHAR *Prefix, const TSet<FName>& Sections, WingOut Output)
|
||||||
{
|
{
|
||||||
if (Sections.IsEmpty()) return;
|
if (Sections.IsEmpty()) return;
|
||||||
|
if (Prefix) Output.Print(Prefix);
|
||||||
bool bFirst = true;
|
bool bFirst = true;
|
||||||
for (const FName& Section : Sections)
|
for (const FName& Section : Sections)
|
||||||
{
|
{
|
||||||
if (!bFirst) WingOut::Stdout.Print(TEXT(", "));
|
if (!bFirst) WingOut::Stdout.Print(TEXT(", "));
|
||||||
bFirst = false;
|
bFirst = false;
|
||||||
WingOut::Stdout.Printf(TEXT("%s"), *Section.ToString());
|
Output.Printf(TEXT("%s"), *Section.ToString());
|
||||||
}
|
}
|
||||||
WingOut::Stdout.Print(TEXT("\n"));
|
if (Prefix) Output.Print(TEXT("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WingManual::PrintSection(FName Section)
|
bool WingManual::PrintSection(FName Section)
|
||||||
|
|||||||
@@ -187,14 +187,18 @@ FString UWingServer::HandleRequest(const FString& Line)
|
|||||||
WingOut::Stdout.Printf(TEXT("UE_LOG: %s\n"), *Msg);
|
WingOut::Stdout.Printf(TEXT("UE_LOG: %s\n"), *Msg);
|
||||||
}
|
}
|
||||||
LogCapture.CapturedErrors.Empty();
|
LogCapture.CapturedErrors.Empty();
|
||||||
if (bSuggestHandlerHelp && LastHandler)
|
if (bSuggestHandlerHelp || (!SuggestedManualSections.IsEmpty()))
|
||||||
{
|
{
|
||||||
WingManual::PrintHandlerHelp(*LastHandler);
|
if (LastHandler) WingManual::PrintHandlerHelp(*LastHandler);
|
||||||
|
if ((LastHandler == nullptr) || (LastHandler->Name != TEXT("Documentation_Manual")))
|
||||||
|
{
|
||||||
|
WingOut::Stdout.Print(TEXT("To see manual: command=Documentation_Manual\n"));
|
||||||
}
|
}
|
||||||
if (!SuggestedManualSections.IsEmpty())
|
if (!SuggestedManualSections.IsEmpty())
|
||||||
{
|
{
|
||||||
WingOut::Stdout.Print(TEXT("Suggested manual sections: "));
|
WingManual::PrintSectionNames(TEXT("Suggested manual sections: "),
|
||||||
WingManual::PrintSectionNames(SuggestedManualSections);
|
SuggestedManualSections, WingOut::Stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FString Result = WingOut::StdoutBuffer.ToString();
|
FString Result = WingOut::StdoutBuffer.ToString();
|
||||||
WingOut::StdoutBuffer.Reset();
|
WingOut::StdoutBuffer.Reset();
|
||||||
@@ -231,7 +235,7 @@ void UWingServer::TryCallHandler(const FString &Line)
|
|||||||
FWingHandlerConfig* Found = FindHandler(Command);
|
FWingHandlerConfig* Found = FindHandler(Command);
|
||||||
if (!Found)
|
if (!Found)
|
||||||
{
|
{
|
||||||
WingOut::Stdout.Printf(TEXT("Unknown command: %s"), *Command);
|
WingOut::Stdout.Printf(TEXT("Unknown command: %s\n"), *Command);
|
||||||
UWingServer::SuggestManual(GET_FUNCTION_NAME_CHECKED(UWingManualSections, ImportantCommands));
|
UWingServer::SuggestManual(GET_FUNCTION_NAME_CHECKED(UWingManualSections, ImportantCommands));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "WingBasics.h"
|
||||||
#include "WingManual.generated.h"
|
#include "WingManual.generated.h"
|
||||||
|
|
||||||
struct FWingHandlerConfig;
|
struct FWingHandlerConfig;
|
||||||
@@ -15,7 +16,7 @@ public:
|
|||||||
static void Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose);
|
static void Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose);
|
||||||
static TSet<FName> GetSections();
|
static TSet<FName> GetSections();
|
||||||
static bool PrintSection(FName Section);
|
static bool PrintSection(FName Section);
|
||||||
static void PrintSectionNames(const TSet<FName>& Sections);
|
static void PrintSectionNames(const TCHAR *Prefix, const TSet<FName>& Sections, WingOut Output);
|
||||||
};
|
};
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
|
|||||||
Reference in New Issue
Block a user