Work on the ue wingman manual

This commit is contained in:
2026-04-13 22:51:35 -04:00
parent 34011e43d5
commit 07b90ced1a
4 changed files with 32 additions and 21 deletions

View File

@@ -12,16 +12,19 @@ class UWing_Documentation_Manual : public UWingHandler
GENERATED_BODY()
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;
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("Print the user manual."));
TStringBuilder<128> Docs;
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
{
TSet<FName> Sections = WingManual::GetSections();
if (Section.IsEmpty())
{
UWingManualSections::FetcherPaths();
@@ -34,10 +37,15 @@ public:
else
{
FName SectionName(*Section);
if (!WingManual::PrintSection(SectionName))
if (WingManual::PrintSection(SectionName))
{
WingOut::Stdout.Printf(TEXT("ERROR: Unknown manual section '%s'\nAvailable sections: "), *Section);
WingManual::PrintSectionNames(WingManual::GetSections());
WingOut::Stdout.Printf(TEXT("\n"));
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);
}
}
}

View File

@@ -185,9 +185,6 @@ void UWingManualSections::ImportantCommands()
"\n You can use Documentation_Commands(Query=Command,Verbose=true)"
"\n to get detailed help for a specific command."
"\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;
}
void WingManual::PrintSectionNames(const TSet<FName>& Sections)
void WingManual::PrintSectionNames(const TCHAR *Prefix, const TSet<FName>& Sections, WingOut Output)
{
if (Sections.IsEmpty()) return;
if (Prefix) Output.Print(Prefix);
bool bFirst = true;
for (const FName& Section : Sections)
{
if (!bFirst) WingOut::Stdout.Print(TEXT(", "));
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)

View File

@@ -187,14 +187,18 @@ FString UWingServer::HandleRequest(const FString& Line)
WingOut::Stdout.Printf(TEXT("UE_LOG: %s\n"), *Msg);
}
LogCapture.CapturedErrors.Empty();
if (bSuggestHandlerHelp && LastHandler)
if (bSuggestHandlerHelp || (!SuggestedManualSections.IsEmpty()))
{
WingManual::PrintHandlerHelp(*LastHandler);
}
if (!SuggestedManualSections.IsEmpty())
{
WingOut::Stdout.Print(TEXT("Suggested manual sections: "));
WingManual::PrintSectionNames(SuggestedManualSections);
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())
{
WingManual::PrintSectionNames(TEXT("Suggested manual sections: "),
SuggestedManualSections, WingOut::Stdout);
}
}
FString Result = WingOut::StdoutBuffer.ToString();
WingOut::StdoutBuffer.Reset();
@@ -231,7 +235,7 @@ void UWingServer::TryCallHandler(const FString &Line)
FWingHandlerConfig* Found = FindHandler(Command);
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));
return;
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "CoreMinimal.h"
#include "WingBasics.h"
#include "WingManual.generated.h"
struct FWingHandlerConfig;
@@ -15,7 +16,7 @@ public:
static void Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose);
static TSet<FName> GetSections();
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()