Skip to content

Commit 98b03c5

Browse files
committed
adoc pagination framework
1 parent 0c44ad5 commit 98b03c5

10 files changed

+307
-1001
lines changed

source/lib/_adoc/AdocGenerator.cpp

Lines changed: 9 additions & 789 deletions
Large diffs are not rendered by default.

source/lib/_adoc/AdocGenerator.hpp

Lines changed: 6 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,8 @@
1313
#define MRDOX_LIB_ADOC_ADOCGENERATOR_HPP
1414

1515
#include <mrdox/Platform.hpp>
16-
#include <mrdox/Config.hpp>
17-
#include <mrdox/Corpus.hpp>
1816
#include <mrdox/MetadataFwd.hpp>
1917
#include <mrdox/Generator.hpp>
20-
#include <mrdox/Metadata/Javadoc.hpp>
21-
#include <llvm/ADT/Optional.h>
22-
#include <llvm/ADT/StringRef.h>
23-
#include <llvm/Support/FileSystem.h>
24-
#include <llvm/Support/Path.h>
25-
#include <llvm/Support/raw_ostream.h>
26-
#include <string>
2718

2819
namespace clang {
2920
namespace mrdox {
@@ -33,8 +24,6 @@ class AdocGenerator
3324
: public Generator
3425
{
3526
public:
36-
class Writer;
37-
3827
llvm::StringRef
3928
name() const noexcept override
4029
{
@@ -53,6 +42,12 @@ class AdocGenerator
5342
return "adoc";
5443
}
5544

45+
llvm::Error
46+
buildPages(
47+
llvm::StringRef outputPath,
48+
Corpus const& corpus,
49+
Reporter& R) const override;
50+
5651
llvm::Error
5752
buildSinglePage(
5853
llvm::raw_ostream& os,
@@ -61,93 +56,6 @@ class AdocGenerator
6156
llvm::raw_fd_ostream* fd_os) const override;
6257
};
6358

64-
//------------------------------------------------
65-
66-
class AdocGenerator::Writer
67-
: public Corpus::Visitor
68-
{
69-
protected:
70-
struct Section
71-
{
72-
int level = 0;
73-
std::string markup;
74-
};
75-
76-
llvm::raw_ostream& os_;
77-
llvm::raw_fd_ostream* fd_os_;
78-
Corpus const& corpus_;
79-
Reporter& R_;
80-
Section sect_;
81-
82-
public:
83-
Writer(
84-
llvm::raw_ostream& os,
85-
llvm::raw_fd_ostream* fd_os,
86-
Corpus const& corpus,
87-
Reporter& R) noexcept;
88-
89-
llvm::Error build();
90-
91-
struct FormalParam;
92-
struct TypeName;
93-
94-
void writeFormalParam(FormalParam const& p, llvm::raw_ostream& os);
95-
void writeTypeName(TypeName const& tn, llvm::raw_ostream& os);
96-
97-
protected:
98-
bool visit(NamespaceInfo const&) override;
99-
bool visit(RecordInfo const&) override;
100-
bool visit(FunctionInfo const&) override;
101-
bool visit(TypedefInfo const&) override;
102-
bool visit(EnumInfo const&) override;
103-
104-
protected:
105-
void writeRecord(RecordInfo const& I);
106-
void writeFunction(FunctionInfo const& I);
107-
void writeTypedef(TypedefInfo const& I);
108-
void writeEnum(EnumInfo const& I);
109-
110-
void writeBase(BaseRecordInfo const& I);
111-
void writeFunctionOverloads(
112-
llvm::StringRef sectionName,
113-
OverloadsSet const& set);
114-
void writeNestedTypes(
115-
llvm::StringRef sectionName,
116-
std::vector<TypedefInfo> const& list,
117-
AccessSpecifier access);
118-
void writeDataMembers(
119-
llvm::StringRef sectionName,
120-
llvm::SmallVectorImpl<MemberTypeInfo> const& list,
121-
AccessSpecifier access);
122-
123-
void writeBrief(
124-
llvm::Optional<Javadoc> const& javadoc,
125-
bool withNewline = true);
126-
void writeDescription(
127-
llvm::Optional<Javadoc> const& javadoc);
128-
void writeLocation(SymbolInfo const& I);
129-
130-
template<class T>
131-
void writeNodes(List<T> const& list);
132-
void writeNode(Javadoc::Node const& node);
133-
void writeNode(Javadoc::Text const& node);
134-
void writeNode(Javadoc::StyledText const& node);
135-
void writeNode(Javadoc::Paragraph const& node);
136-
void writeNode(Javadoc::Admonition const& node);
137-
void writeNode(Javadoc::Code const& node);
138-
void writeNode(Javadoc::Param const& node);
139-
void writeNode(Javadoc::TParam const& node);
140-
void writeNode(Javadoc::Returns const& node);
141-
142-
FormalParam formalParam(FieldTypeInfo const& ft);
143-
TypeName typeName(TypeInfo const& ti);
144-
145-
void openSection(llvm::StringRef name);
146-
void closeSection();
147-
148-
static llvm::StringRef toString(TagTypeKind k) noexcept;
149-
};
150-
15159
} // adoc
15260
} // mrdox
15361
} // clang
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// This is a derivative work. originally part of the LLVM Project.
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
// Copyright (c) 2023 Vinnie Falco ([email protected])
8+
//
9+
// Official repository: https://github.com/cppalliance/mrdox
10+
//
11+
12+
#include "AdocMultiPageWriter.hpp"
13+
14+
namespace clang {
15+
namespace mrdox {
16+
namespace adoc {
17+
18+
AdocMultiPageWriter::
19+
AdocMultiPageWriter(
20+
llvm::raw_ostream& os,
21+
llvm::raw_fd_ostream* fd_os,
22+
Corpus const& corpus,
23+
Reporter& R) noexcept
24+
: AdocWriter(os, fd_os, corpus, R)
25+
{
26+
}
27+
28+
llvm::Error
29+
AdocMultiPageWriter::
30+
build()
31+
{
32+
Assert(sect_.level == 0);
33+
sect_.level = 1;
34+
sect_.markup = "=";
35+
os_ <<
36+
"= Reference\n"
37+
":role: mrdox\n";
38+
(void)corpus_.visit(globalNamespaceID, *this);
39+
closeSection();
40+
return llvm::Error::success();
41+
}
42+
43+
bool
44+
AdocMultiPageWriter::
45+
visit(
46+
NamespaceInfo const& I)
47+
{
48+
return corpus_.visit(I.Children, *this);
49+
}
50+
51+
bool
52+
AdocMultiPageWriter::
53+
visit(
54+
RecordInfo const& I)
55+
{
56+
write(I);
57+
return corpus_.visit(I.Children, *this);
58+
}
59+
60+
bool
61+
AdocMultiPageWriter::
62+
visit(
63+
FunctionInfo const& I)
64+
{
65+
write(I);
66+
return true;
67+
}
68+
69+
bool
70+
AdocMultiPageWriter::
71+
visit(
72+
TypedefInfo const& I)
73+
{
74+
write(I);
75+
return true;
76+
}
77+
78+
bool
79+
AdocMultiPageWriter::
80+
visit(
81+
EnumInfo const& I)
82+
{
83+
write(I);
84+
return true;
85+
}
86+
87+
} // adoc
88+
} // mrdox
89+
} // clang
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
3+
// See https://llvm.org/LICENSE.txt for license information.
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
//
6+
// Copyright (c) 2023 Vinnie Falco ([email protected])
7+
//
8+
// Official repository: https://github.com/cppalliance/mrdox
9+
//
10+
11+
#ifndef MRDOX_LIB_ADOC_ADOCMULTIPAGEWRITER_HPP
12+
#define MRDOX_LIB_ADOC_ADOCMULTIPAGEWRITER_HPP
13+
14+
#include "AdocWriter.hpp"
15+
#include <mrdox/Corpus.hpp>
16+
17+
namespace clang {
18+
namespace mrdox {
19+
namespace adoc {
20+
21+
class AdocMultiPageWriter
22+
: public AdocWriter
23+
, public Corpus::Visitor
24+
{
25+
public:
26+
AdocMultiPageWriter(
27+
llvm::raw_ostream& os,
28+
llvm::raw_fd_ostream* fd_os,
29+
Corpus const& corpus,
30+
Reporter& R) noexcept;
31+
32+
llvm::Error build();
33+
34+
private:
35+
bool visit(NamespaceInfo const&) override;
36+
bool visit(RecordInfo const&) override;
37+
bool visit(FunctionInfo const&) override;
38+
bool visit(TypedefInfo const&) override;
39+
bool visit(EnumInfo const&) override;
40+
};
41+
42+
} // adoc
43+
} // mrdox
44+
} // clang
45+
46+
#endif

source/lib/_adoc/PagesBuilder.cpp renamed to source/lib/_adoc/AdocPagesBuilder.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Official repository: https://github.com/cppalliance/mrdox
99
//
1010

11-
#include "PagesBuilder.hpp"
11+
#include "AdocPagesBuilder.hpp"
1212
#include "Support/Radix.hpp"
1313
#include <mrdox/Metadata.hpp>
1414
#include <llvm/ADT/STLExtras.h>
@@ -19,26 +19,8 @@ namespace clang {
1919
namespace mrdox {
2020
namespace adoc {
2121

22-
/*
23-
Pages are as follows:
24-
25-
Class
26-
Class Template
27-
Class Template Specialization
28-
OverloadSet
29-
Nested Class
30-
Free Function
31-
Variable/Constant
32-
Typedef
33-
Enum
34-
35-
Page name:
36-
37-
/{namespace}/{symbol}.html
38-
*/
39-
4022
void
41-
PagesBuilder::
23+
AdocPagesBuilder::
4224
scan()
4325
{
4426
// visit the children not the namespace
@@ -55,7 +37,7 @@ scan()
5537
}
5638

5739
bool
58-
PagesBuilder::
40+
AdocPagesBuilder::
5941
visit(
6042
NamespaceInfo const& I)
6143
{
@@ -69,7 +51,7 @@ visit(
6951
}
7052

7153
bool
72-
PagesBuilder::
54+
AdocPagesBuilder::
7355
visit(
7456
RecordInfo const& I)
7557
{
@@ -90,7 +72,7 @@ visit(
9072
}
9173

9274
bool
93-
PagesBuilder::
75+
AdocPagesBuilder::
9476
visit(
9577
Overloads const& I)
9678
{
@@ -105,15 +87,15 @@ visit(
10587
}
10688

10789
bool
108-
PagesBuilder::
90+
AdocPagesBuilder::
10991
visit(
11092
FunctionInfo const& I)
11193
{
11294
return true;
11395
}
11496

11597
bool
116-
PagesBuilder::
98+
AdocPagesBuilder::
11799
visit(
118100
TypedefInfo const& I)
119101
{
@@ -129,7 +111,7 @@ visit(
129111
}
130112

131113
bool
132-
PagesBuilder::
114+
AdocPagesBuilder::
133115
visit(
134116
EnumInfo const& I)
135117
{

source/lib/_adoc/PagesBuilder.hpp renamed to source/lib/_adoc/AdocPagesBuilder.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// Official repository: https://github.com/cppalliance/mrdox
99
//
1010

11-
#ifndef MRDOX_LIB_ADOC_PAGESBUILDER_HPP
12-
#define MRDOX_LIB_ADOC_PAGESBUILDER_HPP
11+
#ifndef MRDOX_LIB_ADOC_ADOCPAGESBUILDER_HPP
12+
#define MRDOX_LIB_ADOC_ADOCPAGESBUILDER_HPP
1313

1414
#include <mrdox/Platform.hpp>
1515
#include <mrdox/Corpus.hpp>
@@ -20,7 +20,7 @@ namespace clang {
2020
namespace mrdox {
2121
namespace adoc {
2222

23-
class PagesBuilder : Corpus::Visitor
23+
class AdocPagesBuilder : Corpus::Visitor
2424
{
2525
Corpus const& corpus_;
2626

@@ -39,7 +39,7 @@ class PagesBuilder : Corpus::Visitor
3939

4040
std::vector<Page> pages;
4141

42-
PagesBuilder(
42+
AdocPagesBuilder(
4343
Corpus const& corpus) noexcept
4444
: corpus_(corpus)
4545
{

0 commit comments

Comments
 (0)