Skip to content

Commit

Permalink
asciidoc generator refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Jun 15, 2023
1 parent 6806796 commit 2bbb606
Show file tree
Hide file tree
Showing 31 changed files with 1,144 additions and 6,994 deletions.
4 changes: 0 additions & 4 deletions addons/generator/asciidoc/layouts/default.adoc.hbs

This file was deleted.

27 changes: 27 additions & 0 deletions addons/generator/asciidoc/layouts/function.adoc.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
== {{page.name}}

{{#if page.doc}}
{{page.doc.brief}}
{{/if}}

=== Synopsis

{{#if page.decl}}
[,cpp]
----
{{page.decl}}
----
{{/if}}
{{#if page.loc}}
Declared in file <{{page.loc}}>
{{/if}}
{{page.synopsis}}
{{#if page.doc.description}}
=== Description
{{page.doc.description}}
{{/if}}
13 changes: 13 additions & 0 deletions addons/generator/asciidoc/layouts/namespace.adoc.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
== Namespace {{page.name}}

{{#each page.members}}

=== {{name}}

{{doc.brief}}

==== Description

{{doc.description }}

{{/each}}
2 changes: 2 additions & 0 deletions addons/generator/asciidoc/layouts/record.adoc.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{>record-detail}}

4 changes: 0 additions & 4 deletions addons/generator/asciidoc/partials/class.adoc.hbs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|{{item.tag}} |{{item.name}} |{{item.id}}
6 changes: 6 additions & 0 deletions addons/generator/asciidoc/partials/record-detail.adoc.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[,cpp]
----
struct {{page.name}}
{
};
----
3 changes: 2 additions & 1 deletion mrdox.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ function(mrdox)
COMMAND
mrdox --config=${CMAKE_CURRENT_SOURCE_DIR}/${MRDOX_TARGET_CONFIG}
${MRDOX_COMPILE_COMMANDS}
--addons=../addons
--format=${MRDOX_TARGET_FORMAT}
--output=${MRDOX_TARGET_OUTPUT}
"--output=${MRDOX_TARGET_OUTPUT}"
MAIN_DEPENDENCY ${MRDOX_TARGET_CONFIG} # scanner!
DEPENDS ${MRDOX_EXECUTABLE_DEPENDENCY} ${MRDOX_TARGET_SOURCES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
53 changes: 45 additions & 8 deletions source/-adoc/AdocGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,43 @@
//

#include "AdocGenerator.hpp"
#include "AdocMultiPageWriter.hpp"
#include "AdocPagesBuilder.hpp"
#include "AdocSinglePageWriter.hpp"
#include "Support/RawOstream.hpp"
#include "Builder.hpp"
#include "SinglePageVisitor.hpp"
#include "Support/SafeNames.hpp"
#include <mrdox/Support/Thread.hpp>
#include <mrdox/Support/Path.hpp>
#include <optional>
#include <vector>

namespace clang {
namespace mrdox {
namespace adoc {

Expected<ExecutorGroup<Builder>>
createExecutors(
Corpus const& corpus)
{
auto options = loadOptions(corpus);
if(! options)
return options.getError();

auto const& config = corpus.config;
auto& threadPool = config.threadPool();
ExecutorGroup<Builder> group(threadPool);
for(auto i = threadPool.getThreadCount(); i--;)
{
try
{
group.emplace(corpus, *options);
}
catch(Error const& e)
{
return e;
}
}
return group;
}

//------------------------------------------------
//
// AdocGenerator
Expand All @@ -34,8 +61,12 @@ build(
{
if(corpus.config.singlePage)
return Generator::build(outputPath, corpus);
return AdocPagesBuilder(
llvm::StringRef(outputPath), corpus).build();

auto ex = createExecutors(corpus);
if(! ex)
return ex.getError();

return Error::success();
}

Error
Expand All @@ -44,8 +75,14 @@ buildOne(
std::ostream& os,
Corpus const& corpus) const
{
RawOstream raw_os(os);
return AdocSinglePageWriter(raw_os, corpus).build();
auto ex = createExecutors(corpus);
if(! ex)
return ex.getError();

SinglePageVisitor visitor(*ex, corpus, os);
visitor(corpus.globalNamespace());
ex->wait();
return Error::success();
}

} // adoc
Expand Down
4 changes: 0 additions & 4 deletions source/-adoc/AdocGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define MRDOX_TOOL_ADOC_ADOCGENERATOR_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/MetadataFwd.hpp>
#include <mrdox/Generator.hpp>

namespace clang {
Expand All @@ -23,9 +22,6 @@ namespace adoc {
class AdocGenerator
: public Generator
{
struct MultiPageBuilder;
struct SinglePageBuilder;

public:
std::string_view
id() const noexcept override
Expand Down
104 changes: 0 additions & 104 deletions source/-adoc/AdocMultiPageWriter.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions source/-adoc/AdocMultiPageWriter.hpp

This file was deleted.

Loading

0 comments on commit 2bbb606

Please sign in to comment.