Skip to content

Commit dd76a20

Browse files
committed
support throw symbols
#feat
1 parent 741047c commit dd76a20

File tree

17 files changed

+1153
-32
lines changed

17 files changed

+1153
-32
lines changed

include/mrdocs/Metadata/Javadoc.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ struct TParam : Paragraph
683683
*/
684684
struct Throws : Paragraph
685685
{
686-
String exception;
686+
Reference exception;
687687

688688
static constexpr Kind static_kind = Kind::throws;
689689

src/lib/AST/ParseJavadoc.cpp

+6-20
Original file line numberDiff line numberDiff line change
@@ -1143,28 +1143,14 @@ visitBlockCommandComment(
11431143
doc::Throws throws;
11441144
auto scope = enterScope(throws);
11451145
visitChildren(C->getParagraph());
1146-
// KRYSTIAN NOTE: clang doesn't consider these commands
1147-
// to have any arguments, so we have to extract the exception
1148-
// type manually
1149-
if(! throws.children.empty())
1146+
if (C->getNumArgs())
11501147
{
1151-
// string will start with a non-whitespace character
1152-
doc::String& text =
1153-
throws.children.front()->string;
1154-
constexpr char ws[] = " \t\n\v\f\r";
1155-
const auto except_end = text.find_first_of(ws);
1156-
throws.exception = text.substr(0, except_end);
1157-
// find the start of the next word, ignoring whitespace
1158-
const auto word_start =
1159-
text.find_first_not_of(ws, except_end);
1160-
// if we ran out of string, remove this block
1161-
if(word_start == doc::String::npos)
1162-
throws.children.erase(throws.children.begin());
1163-
// otherwise, trim the string to exclude the argument
1164-
else
1165-
text.erase(0, word_start);
1148+
throws.exception.string = C->getArgText(0);
1149+
}
1150+
else
1151+
{
1152+
throws.exception.string = "undefined";
11661153
}
1167-
11681154
jd_.emplace_back(std::move(throws));
11691155
return;
11701156
}

src/lib/Gen/hbs/HandlebarsCorpus.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ domCreate(
8080
const HandlebarsCorpus& corpus)
8181
{
8282
dom::Object::storage_type entries = {
83-
{ "exception", I.exception }
83+
{ "exception", I.exception.string }
8484
};
8585
std::string s = corpus.toStringFn(corpus, I);
8686
if (!s.empty())

test-files/golden-tests/core/libcxx.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ This function calculates the square root of a given integral value using bit
6464
|===
6565
| Name | Thrown on
6666

67-
| `if`
68-
| the input value is negative.
67+
| `std::invalid_argument`
68+
| if the input value is negative.
6969

7070

7171
|===

test-files/golden-tests/core/libcxx.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ <h3>Exceptions</h3>
7979
</thead>
8080
<tbody>
8181
<tr>
82-
<td><code>if</code></td>
83-
<td><p><span>the input value is negative.</span></p>
82+
<td><code>std::invalid_argument</code></td>
83+
<td><p><span>if the input value is negative.</span></p>
8484
</td>
8585
</tr>
8686
</tbody>

test-files/golden-tests/core/libcxx.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<text>This function calculates the square root of a given integral value using bit manipulation.</text>
2323
</para>
2424
<throws>
25-
<text>the input value is negative.</text>
25+
<text>if the input value is negative.</text>
2626
</throws>
2727
<tparam name="T">
2828
<text>The type of the input value. Must be an integral type. </text>
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
8+
=== Functions
9+
10+
[cols=2]
11+
|===
12+
| Name | Description
13+
14+
| <<f,`f`>>
15+
| brief
16+
17+
18+
19+
|===
20+
21+
[#f]
22+
== f
23+
24+
25+
brief
26+
27+
28+
29+
=== Synopsis
30+
31+
32+
Declared in `&lt;throw&period;cpp&gt;`
33+
34+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
35+
----
36+
void
37+
f();
38+
----
39+
40+
=== Exceptions
41+
42+
43+
|===
44+
| Name | Thrown on
45+
46+
| `std&colon;&colon;length&lowbar;error`
47+
| `dest&lowbar;size &lt; ipv4&lowbar;address&colon;&colon;max&lowbar;str&lowbar;len`
48+
49+
50+
|===
51+
52+
53+
54+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** brief
2+
3+
@throw std::length_error `dest_size < ipv4_address::max_str_len`
4+
*/
5+
void f();
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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="#f"><code>f</code></a> </td><td><p><span>brief</span></p>
22+
23+
</td></tr>
24+
</tbody>
25+
</table>
26+
</div>
27+
<div>
28+
<div>
29+
<h2 id="f">f</h2>
30+
<div>
31+
<p><span>brief</span></p>
32+
33+
34+
</div>
35+
</div>
36+
<div>
37+
<h3>Synopsis</h3>
38+
<div>
39+
Declared in <code>&lt;throw.cpp&gt;</code></div>
40+
<pre>
41+
<code class="source-code cpp">
42+
void
43+
f();
44+
</code>
45+
</pre>
46+
</div>
47+
<div>
48+
<h3>Exceptions</h3>
49+
<table>
50+
<thead>
51+
<tr>
52+
<th>Name</th>
53+
<th>Thrown on</th>
54+
</tr>
55+
</thead>
56+
<tbody>
57+
<tr>
58+
<td><code>std::length_error</code></td>
59+
<td><p><code>dest_size &lt; ipv4_address::max_str_len</code></p>
60+
</td>
61+
</tr>
62+
</tbody>
63+
</table>
64+
</div>
65+
</div>
66+
67+
</div>
68+
<div>
69+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
70+
</div>
71+
</body>
72+
</html>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
6+
<file path="throw.cpp" line="5"/>
7+
<doc>
8+
<para>
9+
<text>brief</text>
10+
</para>
11+
<throws>
12+
<mono>dest_size &lt; ipv4_address::max_str_len</mono>
13+
</throws>
14+
</doc>
15+
</function>
16+
</namespace>
17+
</mrdocs>

0 commit comments

Comments
 (0)