Skip to content

Commit 16ea2bd

Browse files
committed
render orphan @Par headings
Render @Par headings when the @Par has no children paragraphs #feat fix #787
1 parent cbcadbe commit 16ea2bd

File tree

8 files changed

+452
-10
lines changed

8 files changed

+452
-10
lines changed

src/lib/AST/ParseJavadoc.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,24 +1233,26 @@ visitBlockCommandComment(
12331233
doc::Paragraph paragraph;
12341234
auto scope = enterScope(paragraph);
12351235
visitChildren(C->getParagraph());
1236-
if(! paragraph.children.empty())
1236+
if (C->getNumArgs() > 0)
12371237
{
1238-
if (C->getNumArgs() > 0)
1239-
{
1240-
jd_.emplace_back(doc::Heading(C->getArgText(0).str()));
1241-
}
1242-
else
1238+
jd_.emplace_back(doc::Heading(C->getArgText(0).str()));
1239+
}
1240+
if (!paragraph.children.empty())
1241+
{
1242+
// the first TextComment is the heading text
1243+
if (C->getNumArgs() == 0)
12431244
{
1244-
// the first TextComment is the heading text
12451245
doc::String text(std::move(
12461246
paragraph.children.front()->string));
12471247

12481248
// VFALCO Unfortunately clang puts at least
12491249
// one space in front of the text, which seems
12501250
// incorrect.
1251-
auto const s = trim(text);
1252-
if(s.size() != text.size())
1251+
if (auto const s = trim(text);
1252+
s.size() != text.size())
1253+
{
12531254
text = s;
1255+
}
12541256

12551257
doc::Heading heading(std::move(text));
12561258
jd_.emplace_back(std::move(heading));
@@ -1259,8 +1261,10 @@ visitBlockCommandComment(
12591261
paragraph.children.erase(paragraph.children.begin());
12601262
}
12611263

1262-
if(! paragraph.children.empty())
1264+
if (!paragraph.children.empty())
1265+
{
12631266
jd_.emplace_back(std::move(paragraph));
1267+
}
12641268
}
12651269
return;
12661270
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
8+
=== Functions
9+
10+
[cols=2]
11+
|===
12+
| Name | Description
13+
14+
| <<f1,`f1`>>
15+
| Brief
16+
17+
18+
19+
| <<f2,`f2`>>
20+
| Brief
21+
22+
23+
24+
| <<f3,`f3`>>
25+
| Brief
26+
27+
28+
29+
| <<f4,`f4`>>
30+
| Brief
31+
32+
33+
34+
|===
35+
36+
[#f1]
37+
== f1
38+
39+
40+
Brief
41+
42+
43+
44+
=== Synopsis
45+
46+
47+
Declared in `&lt;par&hyphen;1&period;cpp&gt;`
48+
49+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
50+
----
51+
void
52+
f1();
53+
----
54+
55+
=== Description
56+
57+
58+
59+
=== Custom par
60+
61+
Paragraph 1
62+
63+
[,cpp]
64+
----
65+
void f1();
66+
----
67+
68+
69+
[#f2]
70+
== f2
71+
72+
73+
Brief
74+
75+
76+
77+
=== Synopsis
78+
79+
80+
Declared in `&lt;par&hyphen;1&period;cpp&gt;`
81+
82+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
83+
----
84+
void
85+
f2();
86+
----
87+
88+
=== Description
89+
90+
91+
92+
=== Custom par
93+
94+
Paragraph 2
95+
96+
[,cpp]
97+
----
98+
void f2();
99+
----
100+
101+
102+
[#f3]
103+
== f3
104+
105+
106+
Brief
107+
108+
109+
110+
=== Synopsis
111+
112+
113+
Declared in `&lt;par&hyphen;1&period;cpp&gt;`
114+
115+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
116+
----
117+
void
118+
f3();
119+
----
120+
121+
=== Description
122+
123+
124+
125+
=== Custom par
126+
127+
[,cpp]
128+
----
129+
void f3();
130+
----
131+
132+
133+
[#f4]
134+
== f4
135+
136+
137+
Brief
138+
139+
140+
141+
=== Synopsis
142+
143+
144+
Declared in `&lt;par&hyphen;1&period;cpp&gt;`
145+
146+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
147+
----
148+
void
149+
f4();
150+
----
151+
152+
=== Description
153+
154+
155+
156+
=== Custom par
157+
158+
[,cpp]
159+
----
160+
void f4();
161+
----
162+
163+
164+
165+
166+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/** Brief
2+
3+
@par Custom par
4+
Paragraph 1
5+
6+
@code
7+
void f1();
8+
@endcode
9+
10+
*/
11+
void f1();
12+
13+
/** Brief
14+
15+
@par Custom par
16+
17+
Paragraph 2
18+
19+
@code
20+
void f2();
21+
@endcode
22+
23+
*/
24+
void f2();
25+
26+
/** Brief
27+
28+
@par Custom par
29+
@code
30+
void f3();
31+
@endcode
32+
*/
33+
void f3();
34+
35+
/** Brief
36+
37+
@par Custom par
38+
39+
@code
40+
void f4();
41+
@endcode
42+
*/
43+
void f4();

0 commit comments

Comments
 (0)