Skip to content

Commit b39afbd

Browse files
committed
chore: Config::Settings
1 parent 45d69f7 commit b39afbd

File tree

13 files changed

+166
-146
lines changed

13 files changed

+166
-146
lines changed

include/mrdox/Config.hpp

Lines changed: 86 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -35,111 +35,122 @@ class ThreadPool;
3535
particular directory from which absolute paths
3636
are calculated from relative paths.
3737
*/
38-
class MRDOX_VISIBLE
38+
class MRDOX_DECL
3939
Config
4040
{
4141
protected:
4242
Config() noexcept;
4343

4444
public:
45-
/** Destructor.
46-
*/
47-
MRDOX_DECL
48-
virtual
49-
~Config() noexcept = 0;
45+
struct Settings
46+
{
47+
/** `true` if AST visitation failures should not stop the program.
5048
51-
/** Return a pool of threads for executing work.
52-
*/
53-
MRDOX_DECL
54-
virtual
55-
ThreadPool&
56-
threadPool() const noexcept = 0;
49+
@code
50+
ignore-failures: true
51+
@endcode
52+
*/
53+
bool ignoreFailures = false;
5754

58-
//--------------------------------------------
59-
//
60-
// YAML
61-
//
62-
//--------------------------------------------
55+
/** `true` if output should consist of multiple files.
56+
*/
57+
bool multiPage = false;
6358

64-
/** `true` if AST visitation failures should not stop the program.
59+
/** `true` if tool output should be verbose.
6560
66-
@code
67-
ignore-failures: true
68-
@endcode
69-
*/
70-
bool ignoreFailures = false;
61+
@code
62+
verbose: true
63+
@endcode
64+
*/
65+
bool verboseOutput = false;
7166

72-
/** `true` if output should consist of multiple files.
73-
*/
74-
bool multiPage = false;
67+
/** `true` if private members should be extracted and displayed.
7568
76-
/** `true` if tool output should be verbose.
69+
In some cases private members will be listed
70+
even if this configuration value is set to
71+
`false`. For example, when extracting private
72+
virtual functions in a base class.
73+
*/
74+
bool includePrivate = false;
7775

78-
@code
79-
verbose: true
80-
@endcode
81-
*/
82-
bool verboseOutput = false;
76+
/** `true` if anonymous namespace members should be extracted and displayed.
8377
84-
/** `true` if private members should be extracted and displayed.
78+
In some cases anonymous namespace members will
79+
be listed even if this configuration value is set to
80+
`false`. For example, this may occur for a class derived
81+
from one declared within an anonymous namespace.
82+
*/
83+
bool includeAnonymous = true;
8584

86-
In some cases private members will be listed
87-
even if this configuration value is set to
88-
`false`. For example, when extracting private
89-
virtual functions in a base class.
90-
*/
91-
bool includePrivate = false;
85+
/** The level of concurrency desired.
9286
93-
/** `true` if anonymous namespace members should be extracted and displayed.
87+
This will always be greater than zero.
88+
*/
89+
unsigned int concurrency = 0;
9490

95-
In some cases anonymous namespace members will
96-
be listed even if this configuration value is set to
97-
`false`. For example, this may occur for a class derived
98-
from one declared within an anonymous namespace.
99-
*/
100-
bool includeAnonymous = true;
91+
//--------------------------------------------
10192

102-
/** The level of concurrency desired.
93+
/** Full path to the working directory
10394
104-
This will always be greater than zero.
105-
*/
106-
unsigned int concurrency = 0;
95+
The working directory is used to calculate
96+
full paths from relative paths.
10797
108-
//--------------------------------------------
98+
This string will always be native style
99+
and have a trailing directory separator.
100+
*/
101+
std::string workingDir;
109102

110-
/** Full path to the working directory
103+
/** Full path to the Addons directory.
111104
112-
The working directory is used to calculate
113-
full paths from relative paths.
105+
This string will always be native style
106+
and have a trailing directory separator.
107+
*/
108+
std::string addonsDir;
114109

115-
This string will always be native style
116-
and have a trailing directory separator.
117-
*/
118-
std::string workingDir;
110+
/** A string holding the complete configuration YAML.
111+
*/
112+
std::string configYaml;
119113

120-
/** Full path to the Addons directory.
114+
/** A string holding extra configuration YAML.
121115
122-
This string will always be native style
123-
and have a trailing directory separator.
124-
*/
125-
std::string addonsDir;
116+
Any keys in this string which match keys used
117+
in @ref configYaml will effectively replace
118+
those entries in the configuration.
126119
127-
/** A string holding the complete configuration YAML.
128-
*/
129-
std::string configYaml;
120+
A @ref Generator that wishes to implement
121+
format-specific options, should parse and
122+
apply `configYaml`, then parse and apply
123+
this string to the same settings.
124+
*/
125+
std::string extraYaml;
130126

131-
/** A string holding extra configuration YAML.
127+
constexpr Settings const*
128+
operator->() const noexcept
129+
{
130+
return this;
131+
}
132+
};
132133

133-
Any keys in this string which match keys used
134-
in @ref configYaml will effectively replace
135-
those entries in the configuration.
134+
/** Destructor.
135+
*/
136+
MRDOX_DECL
137+
virtual
138+
~Config() noexcept = 0;
136139

137-
A @ref Generator that wishes to implement
138-
format-specific options, should parse and
139-
apply `configYaml`, then parse and apply
140-
this string to the same settings.
140+
/** Return a pool of threads for executing work.
141141
*/
142-
std::string extraYaml;
142+
MRDOX_DECL
143+
virtual
144+
ThreadPool&
145+
threadPool() const noexcept = 0;
146+
147+
constexpr Settings const*
148+
operator->() const noexcept
149+
{
150+
return &settings();
151+
}
152+
153+
virtual Settings const& settings() const noexcept = 0;
143154
};
144155

145156
} // mrdox

lib/-XML/XMLWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ build()
122122
{
123123
{
124124
llvm::yaml::Input yin(
125-
corpus_.config.configYaml,
125+
corpus_.config->configYaml,
126126
this, ConfigImpl::yamlDiagnostic);
127127
yin.setAllowUnknownKeys(true);
128128
yin >> options_;
@@ -131,7 +131,7 @@ build()
131131
}
132132
{
133133
llvm::yaml::Input yin(
134-
corpus_.config.extraYaml,
134+
corpus_.config->extraYaml,
135135
this, ConfigImpl::yamlDiagnostic);
136136
yin.setAllowUnknownKeys(true);
137137
yin >> options_;

lib/-adoc/AdocGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ build(
6262
std::string_view outputPath,
6363
Corpus const& corpus) const
6464
{
65-
if(! corpus.config.multiPage)
65+
if(! corpus.config->multiPage)
6666
return Generator::build(outputPath, corpus);
6767

6868
AdocCorpus domCorpus(corpus);

lib/-adoc/Builder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Builder(
4242

4343
scope.script(files::getFileText(
4444
files::appendPath(
45-
config.addonsDir, "js", "handlebars.js")
45+
config->addonsDir, "js", "handlebars.js")
4646
).value()).maybeThrow();
4747
auto Handlebars = scope.getGlobal("Handlebars").value();
4848

@@ -64,7 +64,7 @@ Handlebars.setlog();
6464

6565
// load partials
6666
forEachFile(
67-
files::appendPath(config.addonsDir,
67+
files::appendPath(config->addonsDir,
6868
"generator", "asciidoc", "partials"),
6969
[&](std::string_view pathName)
7070
{
@@ -83,7 +83,7 @@ Handlebars.setlog();
8383
// load helpers
8484
#if 0
8585
err = forEachFile(
86-
files::appendPath(config.addonsDir,
86+
files::appendPath(config->addonsDir,
8787
"generator", "js", "helpers"),
8888
[&](std::string_view pathName)
8989
{
@@ -149,7 +149,7 @@ callTemplate(
149149

150150
js::Scope scope(ctx_);
151151
auto Handlebars = scope.getGlobal("Handlebars");
152-
auto layoutDir = files::appendPath(config.addonsDir,
152+
auto layoutDir = files::appendPath(config->addonsDir,
153153
"generator", "asciidoc", "layouts");
154154
auto pathName = files::appendPath(layoutDir, name);
155155
auto fileText = files::getFileText(pathName);

lib/-adoc/Options.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ loadOptions(
100100
// config
101101
{
102102
llvm::yaml::Input yin(
103-
corpus.config.configYaml, nullptr,
103+
corpus.config->configYaml, nullptr,
104104
ConfigImpl::yamlDiagnostic);
105105
yin.setAllowUnknownKeys(true);
106106
yin >> opt;
@@ -111,7 +111,7 @@ loadOptions(
111111
// extra
112112
{
113113
llvm::yaml::Input yin(
114-
corpus.config.extraYaml, nullptr,
114+
corpus.config->extraYaml, nullptr,
115115
ConfigImpl::yamlDiagnostic);
116116
yin.setAllowUnknownKeys(true);
117117
yin >> opt;
@@ -125,7 +125,7 @@ loadOptions(
125125
{
126126
opt.template_dir = files::makeAbsolute(
127127
opt.template_dir,
128-
corpus.config.workingDir);
128+
corpus.config->workingDir);
129129
}
130130
else
131131
{
@@ -138,7 +138,7 @@ loadOptions(
138138
opt.template_dir = files::makeDirsy(
139139
files::makeAbsolute(
140140
opt.template_dir,
141-
corpus.config.workingDir));
141+
corpus.config->workingDir));
142142
}
143143
else
144144
{

lib/AST/ASTVisitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ traverse(NamespaceDecl* D)
16431643
{
16441644
if(! shouldExtract(D))
16451645
return true;
1646-
if(! config_.includeAnonymous &&
1646+
if(! config_->includeAnonymous &&
16471647
D->isAnonymousNamespace())
16481648
return true;
16491649

lib/AST/AbsoluteCompilationDatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ AbsoluteCompilationDatabase(
201201
cmd.Output = cmd0.Output;
202202
cmd.CommandLine = adjustCommandLine(
203203
cmd0.CommandLine,
204-
config_impl->additionalDefines_);
204+
(*config_impl)->additionalDefines);
205205

206206
if(path::is_absolute(cmd0.Directory))
207207
{

lib/Metadata/Interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Interface::Build
5151
Corpus const& corpus) noexcept
5252
: I_(I)
5353
, corpus_(corpus)
54-
, includePrivate_(corpus_.config.includePrivate)
54+
, includePrivate_(corpus_.config->includePrivate)
5555
{
5656
// treat `Derived` as a public base,
5757
append(AccessKind::Public, Derived);

0 commit comments

Comments
 (0)