Start the process of standardizing the formatting of documentation inside our header files.

This commit is contained in:
2026-02-14 02:14:19 -05:00
parent dd159b064d
commit d046ef8161
11 changed files with 567 additions and 399 deletions

View File

@@ -1,4 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
////////////////////////////////////////////////////////////
//
// FormatMessage.h
//
// Two K2Nodes: FormatMessage and FormatLogMessage.
// FormatMessage outputs a formatted string as a pin.
// FormatLogMessage outputs it to the log instead.
//
// FormatLogMessage is a derived class that just sets
// a flag to alter the base class behavior.
//
////////////////////////////////////////////////////////////
#pragma once
@@ -17,45 +28,49 @@
#include "FormatMessage.generated.h"
/** Format Log Verbosity: controls how a message from the "Format Log Message"
* K2Node gets written to the log.
*
* 'Fatal' is deliberately placed at the end so that the editor defaults to
* 'Error' (value 0) when the dropdown is uninitialized. This means the
* numeric values don't match ELogVerbosity, so a conversion function is needed.
*
* ThrottledDisplay and ThrottledLog behave like Display and Log respectively,
* but suppress repeated messages with the same format pattern, logging at most
* once per second.
*/
////////////////////////////////////////////////////////////
//
// ElxFormatLogVerbosity
//
// Controls the ELogVerbosity of the UE_LOG directive inside
// FormatLogMessage. Also controls the throttling of log
// messages.
//
// Fatal is deliberately placed at the end so that the
// editor defaults to Error (value 0) when the dropdown is
// uninitialized. The numeric values don't match
// ELogVerbosity, so a conversion function is needed.
//
////////////////////////////////////////////////////////////
UENUM(BlueprintType)
enum class ElxFormatLogVerbosity : uint8 {
/* Prints an error to the console and log file. The editor collects and reports errors. */
/** Prints an error to the console and log file. The editor collects and reports errors. */
Error,
/* Prints a warning to the console and log file. The editor collects and report warnings. */
/** Prints a warning to the console and log file. The editor collects and reports warnings. */
Warning,
/* Prints a message to the console and log file. */
/** Prints a message to the console and log file. */
Display,
/* Prints a message to the log file, however, it does not print to the console. */
/** Prints a message to the log file, but not to the console. */
Log,
/* Like Display, but suppresses repeated messages with the same format pattern (at most once per second). */
/** Like Display, but suppresses repeated messages with the same format pattern (at most once per second). */
ThrottledDisplay,
/* Like Log, but suppresses repeated messages with the same format pattern (at most once per second). */
/** Like Log, but suppresses repeated messages with the same format pattern (at most once per second). */
ThrottledLog,
/* Prints a message to a log file only if Verbose logging is enabled for the given category. This is usually used for detailed logging. */
/** Prints a message to the log file only if Verbose logging is enabled for the given category. */
Verbose,
/* Prints a message to a log file. If VeryVerbose logging is enabled, then this is used for detailed logging that would otherwise spam output. */
/** Prints a message to the log file only if VeryVerbose logging is enabled. */
VeryVerbose,
/* Danger! Prints a fatal error to the console and log file, then crashes (this crashes the editor too). */
/** Prints a fatal error to the console and log file, then crashes (this crashes the editor too). */
Fatal,
};
@@ -64,19 +79,12 @@ class FString;
class UEdGraph;
class UObject;
////////////////////////////////////////////////////////////
//
// FormatMessage and FormatErrorMessage
//
// This file defines two K2Nodes: FormatMessage, and FormatErrorMessage. The
// only difference between them is that the former outputs the message as an
// output pin. The latter outputs the message to the log instead.
//
// To implement code reuse, we put all the code into FormatMessage, and made
// FormatErrorMessage a derived class of FormatMessage. The derived class
// doesn't override anything - all it does is set a flag, the flag changes
// the behavior of FormatMessage.
//
// UK2Node_FormatMessage
//
////////////////////////////////////////////////////////////
UCLASS(MinimalAPI)
class UK2Node_FormatMessage : public UK2Node
{
@@ -110,17 +118,24 @@ class UK2Node_FormatMessage : public UK2Node
//~ End UK2Node Interface.
protected:
/** Create all necessary pins */
// Create all necessary pins.
//
void CreateCorrectPins();
/** Synchronize the type of the given argument pin with the type its connected to, or reset it to a wildcard pin if there's no connection */
// Synchronize the type of the given argument pin
// with the type its connected to, or reset it to
// a wildcard pin if there's no connection.
//
void SynchronizeArgumentPinType(UEdGraphPin* Pin);
/** Our derived class will set this to true, altering the behavior of this K2Node. **/
// Derived class sets this to true, altering
// the behavior of this K2Node.
//
virtual bool IsFormatErrorMessage() const { return false; }
// When IsFormatErrorMessage is true, the K2Node macroexpands to call this
// function, which formats the message and outputs it to the log.
// When IsFormatErrorMessage is true, the K2Node
// macroexpands to call this function, which
// formats the message and outputs it to the log.
//
UFUNCTION(BlueprintCallable, meta=(WorldContext = "Context", BlueprintInternalUseOnly = "true"))
static void FormatLogMessageInternal(UObject *Context, ElxFormatLogVerbosity Verbosity, const FString &InPattern, TArray<FFormatArgumentData> InArgs);
@@ -129,26 +144,31 @@ private:
static ELogVerbosity::Type ConvertElxFormatLogVerbosity(ElxFormatLogVerbosity Verbosity);
protected:
/** When adding arguments to the node, their names are placed here and are generated as pins during construction */
// Argument names added to the node, generated as pins
// during construction.
//
UPROPERTY()
TArray<FString> PinNames;
/** Tooltip text for this node. */
// Tooltip text for this node.
//
FText NodeTooltip;
};
////////////////////////////////////////////////////////////
//
// UK2Node_FormatLogMessage
//
// Derives from FormatMessage. Sets a flag to make
// the base class output to the log instead of to
// a pin.
//
////////////////////////////////////////////////////////////
//
// This derives from FormatMessage.
//
UCLASS(MinimalAPI)
class UK2Node_FormatLogMessage : public UK2Node_FormatMessage
{
GENERATED_UCLASS_BODY()
// Setting this flag alters the behavior of FormatMessage, making it
// output to the log instead of to a pin.
//
virtual bool IsFormatErrorMessage() const override { return true; }
};