Skip to content

Commit 2bbb606

Browse files
committed
asciidoc generator refactor
1 parent 6806796 commit 2bbb606

31 files changed

+1144
-6994
lines changed

addons/generator/asciidoc/layouts/default.adoc.hbs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
== {{page.name}}
2+
3+
{{#if page.doc}}
4+
{{page.doc.brief}}
5+
{{/if}}
6+
7+
=== Synopsis
8+
9+
{{#if page.decl}}
10+
[,cpp]
11+
----
12+
{{page.decl}}
13+
----
14+
{{/if}}
15+
16+
{{#if page.loc}}
17+
Declared in file <{{page.loc}}>
18+
{{/if}}
19+
20+
{{page.synopsis}}
21+
22+
{{#if page.doc.description}}
23+
=== Description
24+
25+
{{page.doc.description}}
26+
27+
{{/if}}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
== Namespace {{page.name}}
2+
3+
{{#each page.members}}
4+
5+
=== {{name}}
6+
7+
{{doc.brief}}
8+
9+
==== Description
10+
11+
{{doc.description }}
12+
13+
{{/each}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{>record-detail}}
2+

addons/generator/asciidoc/partials/class.adoc.hbs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
|{{item.tag}} |{{item.name}} |{{item.id}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[,cpp]
2+
----
3+
struct {{page.name}}
4+
{
5+
};
6+
----

mrdox.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ function(mrdox)
5555
COMMAND
5656
mrdox --config=${CMAKE_CURRENT_SOURCE_DIR}/${MRDOX_TARGET_CONFIG}
5757
${MRDOX_COMPILE_COMMANDS}
58+
--addons=../addons
5859
--format=${MRDOX_TARGET_FORMAT}
59-
--output=${MRDOX_TARGET_OUTPUT}
60+
"--output=${MRDOX_TARGET_OUTPUT}"
6061
MAIN_DEPENDENCY ${MRDOX_TARGET_CONFIG} # scanner!
6162
DEPENDS ${MRDOX_EXECUTABLE_DEPENDENCY} ${MRDOX_TARGET_SOURCES}
6263
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}

source/-adoc/AdocGenerator.cpp

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,43 @@
1010
//
1111

1212
#include "AdocGenerator.hpp"
13-
#include "AdocMultiPageWriter.hpp"
14-
#include "AdocPagesBuilder.hpp"
15-
#include "AdocSinglePageWriter.hpp"
16-
#include "Support/RawOstream.hpp"
13+
#include "Builder.hpp"
14+
#include "SinglePageVisitor.hpp"
1715
#include "Support/SafeNames.hpp"
16+
#include <mrdox/Support/Thread.hpp>
17+
#include <mrdox/Support/Path.hpp>
18+
#include <optional>
19+
#include <vector>
1820

1921
namespace clang {
2022
namespace mrdox {
2123
namespace adoc {
2224

25+
Expected<ExecutorGroup<Builder>>
26+
createExecutors(
27+
Corpus const& corpus)
28+
{
29+
auto options = loadOptions(corpus);
30+
if(! options)
31+
return options.getError();
32+
33+
auto const& config = corpus.config;
34+
auto& threadPool = config.threadPool();
35+
ExecutorGroup<Builder> group(threadPool);
36+
for(auto i = threadPool.getThreadCount(); i--;)
37+
{
38+
try
39+
{
40+
group.emplace(corpus, *options);
41+
}
42+
catch(Error const& e)
43+
{
44+
return e;
45+
}
46+
}
47+
return group;
48+
}
49+
2350
//------------------------------------------------
2451
//
2552
// AdocGenerator
@@ -34,8 +61,12 @@ build(
3461
{
3562
if(corpus.config.singlePage)
3663
return Generator::build(outputPath, corpus);
37-
return AdocPagesBuilder(
38-
llvm::StringRef(outputPath), corpus).build();
64+
65+
auto ex = createExecutors(corpus);
66+
if(! ex)
67+
return ex.getError();
68+
69+
return Error::success();
3970
}
4071

4172
Error
@@ -44,8 +75,14 @@ buildOne(
4475
std::ostream& os,
4576
Corpus const& corpus) const
4677
{
47-
RawOstream raw_os(os);
48-
return AdocSinglePageWriter(raw_os, corpus).build();
78+
auto ex = createExecutors(corpus);
79+
if(! ex)
80+
return ex.getError();
81+
82+
SinglePageVisitor visitor(*ex, corpus, os);
83+
visitor(corpus.globalNamespace());
84+
ex->wait();
85+
return Error::success();
4986
}
5087

5188
} // adoc

source/-adoc/AdocGenerator.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define MRDOX_TOOL_ADOC_ADOCGENERATOR_HPP
1414

1515
#include <mrdox/Platform.hpp>
16-
#include <mrdox/MetadataFwd.hpp>
1716
#include <mrdox/Generator.hpp>
1817

1918
namespace clang {
@@ -23,9 +22,6 @@ namespace adoc {
2322
class AdocGenerator
2423
: public Generator
2524
{
26-
struct MultiPageBuilder;
27-
struct SinglePageBuilder;
28-
2925
public:
3026
std::string_view
3127
id() const noexcept override

0 commit comments

Comments
 (0)