summaryrefslogtreecommitdiff
path: root/source/core/slang-command-options-writer.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-05-02 11:10:58 -0400
committerGitHub <noreply@github.com>2023-05-02 11:10:58 -0400
commit29cb65585782f71a9c6fa1062eaa0b8de8359604 (patch)
treecdd820f2c4a8b26933ba4f5057f92e84b8dc01eb /source/core/slang-command-options-writer.h
parent19c0866b050a022406867aa650302f4efbf8e010 (diff)
Markdown CommandOptions (#2860)
* WIP CommandOptions * Fix some output issues. * Simplify word wrapping. * Add file extensions. * Change how lookup takes place. Add appendSplit functions to StringUtil. Make Categories hold the index range of their options. * Small improvement. * Lookup with partial option names. * Associate user values. * Encoding flags in the name. * Refactor setting up of command options. * Use CommandOptions in slang-options. * Remove old help text. * Cache the CommandOptions on the Session. * Range checking. Fix bug in the Options handling. * Extra checks for validity. * Get categories directly. * Slight improvements over output. * Added NameValue types. * Fix typo. Remove some now unused diagnostics. Fix diagnostic in testing, as output has changed. * Add minimal usage message. * Remove platform executable extension from diagnostics output. * Some improvements around getting names from NameValue types. * Improve some option descriptions. * Small fixes. * WIP improvements around CommandOptions. * Split out CommandOptionsWriter. * Add links to options. * Add command line options reference. * Link to the reference command line information. * Add quick links. * Improvements around lookup. Add categories to linking. * Small additional fixes. * Add LinkFlags control. * Small text fixes. * Fix typo. * Fix typo. * Fix typo. * Add support for -g and -O using CommandOptions. * Improve generated doc output/descriptions. Remove options listed directly in documentation.
Diffstat (limited to 'source/core/slang-command-options-writer.h')
-rw-r--r--source/core/slang-command-options-writer.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/core/slang-command-options-writer.h b/source/core/slang-command-options-writer.h
new file mode 100644
index 000000000..eb9a2795f
--- /dev/null
+++ b/source/core/slang-command-options-writer.h
@@ -0,0 +1,69 @@
+#ifndef SLANG_CORE_COMMAND_OPTIONS_WRITER_H
+#define SLANG_CORE_COMMAND_OPTIONS_WRITER_H
+
+#include "slang-command-options.h"
+
+namespace Slang
+{
+
+class CommandOptionsWriter : public RefObject
+{
+public:
+ typedef CommandOptions::CategoryKind CategoryKind;
+ typedef CommandOptions::NameKey NameKey;
+ typedef CommandOptions::LookupKind LookupKind;
+
+ enum class Style
+ {
+ Text, ///< Suitable for output to a terminal
+ Markdown, ///< Markdown
+ NoLinkMarkdown, ///< Markdown without links
+ };
+
+ static ConstArrayView<NamesDescriptionValue> getStyleInfos();
+
+ struct Options
+ {
+ Style style = Style::Text; ///< The style
+ Index lineLength = 120; ///< The maximum amount of characters on a line
+ UnownedStringSlice indent = toSlice(" ");;
+ };
+
+ /// Append descirption for a category
+ void appendDescriptionForCategory(CommandOptions* options, Index categoryIndex);
+ /// Appends a description of all of the options
+ void appendDescription(CommandOptions* options);
+
+ /// Get the builder that string is being written to
+ StringBuilder& getBuilder() { return m_builder; }
+
+ static RefPtr<CommandOptionsWriter> create(const Options& options);
+
+
+protected:
+
+ /// Append descirption for a category
+ virtual void appendDescriptionForCategoryImpl(Index categoryIndex) = 0;
+ /// Appends a description of all of the options
+ virtual void appendDescriptionImpl() = 0;
+
+ // Ctor, use create to create a writer
+ CommandOptionsWriter(const Options& options);
+
+ /// Get the length of the current line in ascii chars/bytes
+ Count _getCurrentLineLength();
+
+ /// Indentation/wrapping
+ void _requireIndent(Count indentCount);
+ void _appendWrappedIndented(Count indentCount, List<UnownedStringSlice>& slices, const UnownedStringSlice& delimit);
+
+ CommandOptions* m_commandOptions = nullptr;
+
+ StringSlicePool m_pool;
+ StringBuilder m_builder;
+ Options m_options;
+};
+
+} // namespace Slang
+
+#endif