Skip to content

Commit 8834acb

Browse files
committed
refactor: metadata base classes do not expose constructors
1 parent f3d43cb commit 8834acb

File tree

21 files changed

+203
-111
lines changed

21 files changed

+203
-111
lines changed

include/mrdocs/Corpus.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ class MRDOCS_VISIBLE
272272
{
273273
return std::is_lt(cmp);
274274
}
275-
return std::is_lt(
276-
CompareDerived(Polymorphic<Info>(lhsInfo),
277-
Polymorphic<Info>(rhsInfo)));
275+
return std::is_lt(CompareDerived(lhsInfo, rhsInfo));
278276
});
279277
if (!opts.skipInherited)
280278
{

include/mrdocs/Metadata/Info/InfoBase.hpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,6 @@ struct MRDOCS_VISIBLE Info
8484

8585
~Info() override = default;
8686

87-
Info(Info const& Other) = default;
88-
89-
/** Move constructor.
90-
*/
91-
Info(Info&& Other) = default;
92-
93-
/** Construct an Info.
94-
95-
@param kind The kind of symbol
96-
@param ID The unique identifier for this symbol
97-
*/
98-
explicit
99-
Info(
100-
InfoKind const kind,
101-
SymbolID const& ID) noexcept
102-
: id(ID)
103-
, Kind(kind)
104-
{
105-
}
106-
10787
#define INFO(Type) constexpr bool is##Type() const noexcept { \
10888
return Kind == InfoKind::Type; \
10989
}
@@ -152,8 +132,27 @@ struct MRDOCS_VISIBLE Info
152132
auto operator<=>(Info const&) const = default;
153133

154134
protected:
155-
Info() = default;
135+
constexpr Info() = default;
156136

137+
Info(Info const& Other) = default;
138+
139+
/** Move constructor.
140+
*/
141+
Info(Info&& Other) = default;
142+
143+
/** Construct an Info.
144+
145+
@param kind The kind of symbol
146+
@param ID The unique identifier for this symbol
147+
*/
148+
explicit
149+
Info(
150+
InfoKind const kind,
151+
SymbolID const& ID) noexcept
152+
: id(ID)
153+
, Kind(kind)
154+
{
155+
}
157156
};
158157

159158
//------------------------------------------------

include/mrdocs/Metadata/Javadoc/Block/BlockBase.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <mrdocs/Dom.hpp>
1818
#include <mrdocs/Dom/LazyArray.hpp>
1919
#include <mrdocs/Dom/LazyObject.hpp>
20+
#include <mrdocs/Metadata/Javadoc/Inline.hpp>
2021
#include <mrdocs/Metadata/Javadoc/Node/NodeBase.hpp>
21-
#include <mrdocs/Metadata/Javadoc/Text.hpp>
2222
#include <algorithm>
2323
#include <string>
2424

@@ -94,6 +94,9 @@ struct MRDOCS_DECL
9494
void append(std::vector<Polymorphic<Text>> const& otherChildren);
9595

9696
protected:
97+
constexpr
98+
Block() = default;
99+
97100
explicit
98101
Block(
99102
NodeKind const kind_,

include/mrdocs/Metadata/Javadoc/Text.hpp renamed to include/mrdocs/Metadata/Javadoc/Inline.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,45 @@
1010
// Official repository: https://github.com/cppalliance/mrdocs
1111
//
1212

13-
#ifndef MRDOCS_API_METADATA_JAVADOC_TEXT_HPP
14-
#define MRDOCS_API_METADATA_JAVADOC_TEXT_HPP
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_HPP
1515

1616
#include <mrdocs/Platform.hpp>
1717
#include <mrdocs/ADT/Polymorphic.hpp>
18-
#include <mrdocs/Metadata/Javadoc/Text/CopyDetails.hpp>
19-
#include <mrdocs/Metadata/Javadoc/Text/Link.hpp>
20-
#include <mrdocs/Metadata/Javadoc/Text/Reference.hpp>
21-
#include <mrdocs/Metadata/Javadoc/Text/Style.hpp>
22-
#include <mrdocs/Metadata/Javadoc/Text/Styled.hpp>
23-
#include <mrdocs/Metadata/Javadoc/Text/TextBase.hpp>
18+
#include <mrdocs/Metadata/Javadoc/Inline/CopyDetails.hpp>
19+
#include <mrdocs/Metadata/Javadoc/Inline/Link.hpp>
20+
#include <mrdocs/Metadata/Javadoc/Inline/Reference.hpp>
21+
#include <mrdocs/Metadata/Javadoc/Inline/Style.hpp>
22+
#include <mrdocs/Metadata/Javadoc/Inline/Styled.hpp>
23+
#include <mrdocs/Metadata/Javadoc/Inline/Text.hpp>
2424
#include <mrdocs/Support/Concepts.hpp>
2525
#include <mrdocs/Support/Visitor.hpp>
2626
#include <compare>
2727

2828
namespace clang::mrdocs::doc {
2929

30-
/** Visit a text.
30+
/** Visit an inline.
3131
32-
@param text The text to visit.
33-
@param fn The function to call for each text.
32+
@param inline The inline to visit.
33+
@param fn The function to call for each inline.
3434
@param args Additional arguments to pass to the function.
3535
@return The result of calling the function.
3636
*/
3737
template<
38-
class TextTy,
38+
class InlineTy,
3939
class Fn,
4040
class... Args>
41-
requires std::derived_from<TextTy, Text>
41+
requires std::derived_from<InlineTy, Inline>
4242
decltype(auto)
4343
visit(
44-
TextTy& text,
44+
InlineTy& el,
4545
Fn&& fn,
4646
Args&&... args)
4747
{
48-
auto visitor = makeVisitor<Text>(
49-
text, std::forward<Fn>(fn),
48+
auto visitor = makeVisitor<Inline>(
49+
el, std::forward<Fn>(fn),
5050
std::forward<Args>(args)...);
51-
switch(text.Kind)
51+
switch(el.Kind)
5252
{
5353
case NodeKind::link:
5454
return visitor.template visit<Link>();
@@ -65,36 +65,36 @@ visit(
6565
}
6666
}
6767

68-
/** Traverse a list of texts.
68+
/** Traverse a list of inlines.
6969
7070
@param list The list of texts to traverse.
7171
@param f The function to call for each text.
7272
@param args Additional arguments to pass to the function.
7373
*/
7474
template<class F, class T, class... Args>
75-
requires std::derived_from<T, Text>
75+
requires std::derived_from<T, Inline>
7676
void traverse(
7777
std::vector<std::unique_ptr<T>> const& list,
7878
F&& f, Args&&... args)
7979
{
80-
for(auto const& text : list)
81-
visit(*text,
80+
for(auto const& el : list)
81+
visit(*el,
8282
std::forward<F>(f),
8383
std::forward<Args>(args)...);
8484
}
8585

86-
/** Map the Polymorphic Text as a @ref dom::Value object.
86+
/** Map the Polymorphic Inline as a @ref dom::Value object.
8787
8888
@param io The output parameter to receive the dom::Object.
8989
@param I The input object.
9090
@param domCorpus The DOM corpus, or nullptr if not part of a corpus.
9191
*/
92-
template <class IO, polymorphic_storage_for<Text> TextTy>
92+
template <class IO, polymorphic_storage_for<Inline> InlineTy>
9393
void
9494
tag_invoke(
9595
dom::ValueFromTag,
9696
IO& io,
97-
TextTy const& I,
97+
InlineTy const& I,
9898
DomCorpus const* domCorpus)
9999
{
100100
visit(*I, [&](auto const& U)
@@ -109,14 +109,14 @@ tag_invoke(
109109

110110
MRDOCS_DECL
111111
std::strong_ordering
112-
operator<=>(Polymorphic<Text> const& lhs, Polymorphic<Text> const& rhs);
112+
operator<=>(Polymorphic<Inline> const& lhs, Polymorphic<Inline> const& rhs);
113113

114114
inline
115115
bool
116-
operator==(Polymorphic<Text> const& lhs, Polymorphic<Text> const& rhs) {
116+
operator==(Polymorphic<Inline> const& lhs, Polymorphic<Inline> const& rhs) {
117117
return std::is_eq(lhs <=> rhs);
118118
}
119119

120120
} // clang::mrdocs::doc
121121

122-
#endif // MRDOCS_API_METADATA_JAVADOC_TEXT_HPP
122+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_HPP

include/mrdocs/Metadata/Javadoc/Text/CopyDetails.hpp renamed to include/mrdocs/Metadata/Javadoc/Inline/CopyDetails.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
// Official repository: https://github.com/cppalliance/mrdocs
1111
//
1212

13-
#ifndef MRDOCS_API_METADATA_JAVADOC_TEXT_COPYDETAILS_HPP
14-
#define MRDOCS_API_METADATA_JAVADOC_TEXT_COPYDETAILS_HPP
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_COPYDETAILS_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_COPYDETAILS_HPP
1515

1616
#include <mrdocs/Platform.hpp>
17-
#include <mrdocs/Metadata/Javadoc/Text/Reference.hpp>
18-
#include <mrdocs/Metadata/Javadoc/Text/TextBase.hpp>
17+
#include <mrdocs/Metadata/Javadoc/Inline/Reference.hpp>
18+
#include <mrdocs/Metadata/Javadoc/Inline/Text.hpp>
1919
#include <string>
2020

2121
namespace clang::mrdocs::doc {
@@ -77,4 +77,4 @@ tag_invoke(
7777

7878
} // clang::mrdocs::doc
7979

80-
#endif // MRDOCS_API_METADATA_JAVADOC_TEXT_COPYDETAILS_HPP
80+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_COPYDETAILS_HPP
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 (vinnie.falco@gmail.com)
8+
// Copyright (c) 2023 Krystian Stasiowski (sdkrystian@gmail.com)
9+
//
10+
// Official repository: https://github.com/cppalliance/mrdocs
11+
//
12+
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_INLINEBASE_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_INLINEBASE_HPP
15+
16+
#include <mrdocs/Platform.hpp>
17+
#include <mrdocs/Metadata/Javadoc/Node/NodeBase.hpp>
18+
#include <string>
19+
20+
namespace clang::mrdocs::doc {
21+
22+
/** A Node containing a string of text.
23+
24+
There will be no newlines in the text. Otherwise,
25+
this would be represented as multiple text nodes
26+
within a Paragraph node.
27+
*/
28+
struct Inline : Node
29+
{
30+
constexpr ~Inline() override = default;
31+
32+
bool
33+
isBlock() const noexcept final
34+
{
35+
return false;
36+
}
37+
38+
auto operator<=>(Inline const&) const = default;
39+
bool operator==(Inline const&) const noexcept = default;
40+
bool equals(Node const& other) const noexcept override
41+
{
42+
return Kind == other.Kind &&
43+
*this == dynamic_cast<Inline const&>(other);
44+
}
45+
46+
protected:
47+
constexpr Inline() noexcept = default;
48+
49+
Inline(
50+
NodeKind kind_)
51+
: Node(kind_)
52+
{
53+
}
54+
};
55+
56+
/** Map the @ref Inline to a @ref dom::Object.
57+
58+
@param t The tag.
59+
@param io The output object.
60+
@param I The input object.
61+
@param domCorpus The DOM corpus, or nullptr if not part of a corpus.
62+
*/
63+
template <class IO>
64+
void
65+
tag_invoke(
66+
dom::LazyObjectMapTag t,
67+
IO& io,
68+
Inline const& I,
69+
DomCorpus const* domCorpus)
70+
{
71+
tag_invoke(t, io, dynamic_cast<Node const&>(I), domCorpus);
72+
}
73+
74+
/** Return the @ref Inline as a @ref dom::Value object.
75+
*/
76+
inline
77+
void
78+
tag_invoke(
79+
dom::ValueFromTag,
80+
dom::Value& v,
81+
Inline const& I,
82+
DomCorpus const* domCorpus)
83+
{
84+
v = dom::LazyObject(I, domCorpus);
85+
}
86+
87+
} // clang::mrdocs::doc
88+
89+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_INLINEBASE_HPP

include/mrdocs/Metadata/Javadoc/Text/Link.hpp renamed to include/mrdocs/Metadata/Javadoc/Inline/Link.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
// Official repository: https://github.com/cppalliance/mrdocs
1111
//
1212

13-
#ifndef MRDOCS_API_METADATA_JAVADOC_TEXT_LINK_HPP
14-
#define MRDOCS_API_METADATA_JAVADOC_TEXT_LINK_HPP
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_LINK_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_LINK_HPP
1515

1616
#include <mrdocs/Platform.hpp>
17-
#include <mrdocs/Metadata/Javadoc/Text/TextBase.hpp>
17+
#include <mrdocs/Metadata/Javadoc/Inline/Text.hpp>
1818
#include <string>
1919

2020
namespace clang::mrdocs::doc {
@@ -79,4 +79,4 @@ tag_invoke(
7979

8080
} // clang::mrdocs::doc
8181

82-
#endif // MRDOCS_API_METADATA_JAVADOC_TEXT_LINK_HPP
82+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_LINK_HPP

include/mrdocs/Metadata/Javadoc/Text/Parts.hpp renamed to include/mrdocs/Metadata/Javadoc/Inline/Parts.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// Official repository: https://github.com/cppalliance/mrdocs
1111
//
1212

13-
#ifndef MRDOCS_API_METADATA_JAVADOC_TEXT_PARTS_HPP
14-
#define MRDOCS_API_METADATA_JAVADOC_TEXT_PARTS_HPP
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_PARTS_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_PARTS_HPP
1515

1616
#include <mrdocs/Platform.hpp>
1717
#include <mrdocs/Dom.hpp>
@@ -54,4 +54,4 @@ tag_invoke(
5454

5555
} // clang::mrdocs::doc
5656

57-
#endif // MRDOCS_API_METADATA_JAVADOC_TEXT_PARTS_HPP
57+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_PARTS_HPP

include/mrdocs/Metadata/Javadoc/Text/Reference.hpp renamed to include/mrdocs/Metadata/Javadoc/Inline/Reference.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
// Official repository: https://github.com/cppalliance/mrdocs
1111
//
1212

13-
#ifndef MRDOCS_API_METADATA_JAVADOC_TEXT_REFERENCE_HPP
14-
#define MRDOCS_API_METADATA_JAVADOC_TEXT_REFERENCE_HPP
13+
#ifndef MRDOCS_API_METADATA_JAVADOC_INLINE_REFERENCE_HPP
14+
#define MRDOCS_API_METADATA_JAVADOC_INLINE_REFERENCE_HPP
1515

1616
#include <mrdocs/Platform.hpp>
1717
#include <mrdocs/Metadata/Info/SymbolID.hpp>
18-
#include <mrdocs/Metadata/Javadoc/Text/TextBase.hpp>
18+
#include <mrdocs/Metadata/Javadoc/Inline/Text.hpp>
1919
#include <string>
2020

2121
namespace clang::mrdocs::doc {
@@ -86,4 +86,4 @@ tag_invoke(
8686

8787
} // clang::mrdocs::doc
8888

89-
#endif // MRDOCS_API_METADATA_JAVADOC_TEXT_REFERENCE_HPP
89+
#endif // MRDOCS_API_METADATA_JAVADOC_INLINE_REFERENCE_HPP

0 commit comments

Comments
 (0)