Skip to content

Commit

Permalink
refactor(Generator): build member function
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Nov 14, 2024
1 parent 6639b8d commit eb464a3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
18 changes: 16 additions & 2 deletions include/mrdocs/Generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class MRDOCS_VISIBLE
@param corpus The symbols to emit. The
generator may modify the contents of
the object before returning.
@param config The configuration to use.
*/
MRDOCS_DECL
virtual
Expand All @@ -109,6 +107,22 @@ class MRDOCS_VISIBLE
std::string_view outputPath,
Corpus const& corpus) const;

/** Build reference documentation for the corpus.
This function invokes the generator to emit
the documentation using the corpus configuration
options to determine the output location.
@return The error, if any occurred.
@param corpus The symbols to emit. The
generator may modify the contents of
the object before returning.
*/
MRDOCS_DECL
Error
build(Corpus const& corpus) const;

/** Build reference documentation for the corpus.
This function invokes the generator to emit
Expand Down
11 changes: 11 additions & 0 deletions src/lib/Support/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ build(
return buildOne(fileName.str(), corpus);
}

Error
Generator::
build(Corpus const& corpus) const
{
std::string absOutput = files::normalizePath(
files::makeAbsolute(
corpus.config->output,
corpus.config->configDir));
return build(absOutput, corpus);
}

Error
Generator::
buildOne(
Expand Down
6 changes: 1 addition & 5 deletions src/tool/GenerateAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,8 @@ DoGenerateAction(
// --------------------------------------------------------------
// Normalize outputPath path
MRDOCS_CHECK(settings.output, "The output path argument is missing");
std::string absOutput = files::normalizePath(
files::makeAbsolute(
settings.output,
(*config)->configDir));
report::info("Generating docs\n");
MRDOCS_TRY(generator.build(absOutput, *corpus));
MRDOCS_TRY(generator.build(*corpus));

// --------------------------------------------------------------
//
Expand Down

0 comments on commit eb464a3

Please sign in to comment.