Skip to content

Commit 03d1a75

Browse files
Nerixyzalandefreitas
authored andcommitted
fix: use arguments to \par if available
1 parent f92f1f2 commit 03d1a75

File tree

5 files changed

+187
-16
lines changed

5 files changed

+187
-16
lines changed

src/lib/AST/ParseJavadoc.cpp

+24-16
Original file line numberDiff line numberDiff line change
@@ -1026,22 +1026,30 @@ visitBlockCommandComment(
10261026
visitChildren(C->getParagraph());
10271027
if(! paragraph.children.empty())
10281028
{
1029-
// the first TextComment is the heading text
1030-
doc::String text(std::move(
1031-
paragraph.children.front()->string));
1032-
1033-
// VFALCO Unfortunately clang puts at least
1034-
// one space in front of the text, which seems
1035-
// incorrect.
1036-
auto const s = trim(text);
1037-
if(s.size() != text.size())
1038-
text = s;
1039-
1040-
doc::Heading heading(std::move(text));
1041-
jd_.emplace_back(std::move(heading));
1042-
1043-
// remaining TextComment, if any
1044-
paragraph.children.erase(paragraph.children.begin());
1029+
if (C->getNumArgs() > 0)
1030+
{
1031+
jd_.emplace_back(doc::Heading(C->getArgText(0).str()));
1032+
}
1033+
else
1034+
{
1035+
// the first TextComment is the heading text
1036+
doc::String text(std::move(
1037+
paragraph.children.front()->string));
1038+
1039+
// VFALCO Unfortunately clang puts at least
1040+
// one space in front of the text, which seems
1041+
// incorrect.
1042+
auto const s = trim(text);
1043+
if(s.size() != text.size())
1044+
text = s;
1045+
1046+
doc::Heading heading(std::move(text));
1047+
jd_.emplace_back(std::move(heading));
1048+
1049+
// remaining TextComment, if any
1050+
paragraph.children.erase(paragraph.children.begin());
1051+
}
1052+
10451053
if(! paragraph.children.empty())
10461054
jd_.emplace_back(std::move(paragraph));
10471055
}

test-files/golden-tests/para-3.adoc

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
=== Functions
8+
[cols=2]
9+
|===
10+
| Name | Description
11+
12+
| <<#my_function,`my&lowbar;function`>>
13+
| A function
14+
15+
|===
16+
17+
[#my_function]
18+
== my&lowbar;function
19+
20+
A function
21+
22+
=== Synopsis
23+
24+
Declared in `&lt;para&hyphen;3&period;cpp&gt;`
25+
26+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
27+
----
28+
void
29+
my&lowbar;function();
30+
----
31+
32+
=== Description
33+
34+
35+
=== A heading&period;
36+
Some text&period;
37+
38+
More text&period;&period;&period;
39+
40+
Another paragraph
41+
Next line
42+
43+
44+
=== Exception safety
45+
No&hyphen;throw guarantee&period;
46+
47+
48+
49+
50+
51+
[.small]#Created with https://www.mrdocs.com[MrDocs]#

test-files/golden-tests/para-3.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* \brief A function
3+
*
4+
* \par
5+
* A heading.
6+
* Some text.
7+
*
8+
* More text...
9+
*
10+
* Another paragraph
11+
* Next line
12+
*
13+
* \par Exception safety
14+
* No-throw guarantee.
15+
*/
16+
void my_function();

test-files/golden-tests/para-3.html

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<html lang="en">
2+
<head>
3+
<title>Reference</title>
4+
</head>
5+
<body>
6+
<div>
7+
<h1>Reference</h1>
8+
<div>
9+
<div>
10+
<h2 id="index">Global namespace</h2>
11+
</div>
12+
<h2>Functions</h2>
13+
<table style="table-layout: fixed; width: 100%;">
14+
<thead>
15+
<tr>
16+
<th>Name</th><th>Description</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td><a href="#my_function"><code>my_function</code></a> </td><td><span><span>A function</span></span>
22+
</td></tr>
23+
</tbody>
24+
</table>
25+
</div>
26+
<div>
27+
<div>
28+
<h2 id="my_function">my_function</h2>
29+
<div>
30+
<span><span>A function</span></span>
31+
32+
</div>
33+
</div>
34+
<div>
35+
<h3>Synopsis</h3>
36+
<div>
37+
Declared in <code>&lt;para-3.cpp&gt;</code></div>
38+
<pre>
39+
<code class="source-code cpp">
40+
void
41+
my_function();
42+
</code>
43+
</pre>
44+
</div>
45+
<div>
46+
<h3>Description</h3>
47+
<h3>A heading.</h3>
48+
<p><span>Some text.</span></p>
49+
50+
<p><span>More text...</span></p>
51+
52+
<p><span>Another paragraph</span> <span>Next line</span></p>
53+
54+
<h3>Exception safety</h3>
55+
<p><span>No-throw guarantee.</span></p>
56+
57+
58+
59+
</div>
60+
</div>
61+
62+
</div>
63+
<div>
64+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
65+
</div>
66+
</body>
67+
</html>

test-files/golden-tests/para-3.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<mrdocs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc">
4+
<namespace id="//////////////////////////8=">
5+
<function name="my_function" id="jv2AC4inoS2L4+tVOPxfYiZpb3g=">
6+
<file path="para-3.cpp" line="16"/>
7+
<doc>
8+
<brief>
9+
<text>A function</text>
10+
</brief>
11+
<head>A heading.</head>
12+
<para>
13+
<text> Some text.</text>
14+
</para>
15+
<para>
16+
<text>More text...</text>
17+
</para>
18+
<para>
19+
<text>Another paragraph</text>
20+
<text> Next line</text>
21+
</para>
22+
<head>Exception safety</head>
23+
<para>
24+
<text>No-throw guarantee.</text>
25+
</para>
26+
</doc>
27+
</function>
28+
</namespace>
29+
</mrdocs>

0 commit comments

Comments
 (0)