blob: 5452d7617efd73299c631119d5dbb781709f21b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#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
|