Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ struct TParam : Paragraph
*/
struct Throws : Paragraph
{
String exception;
Reference exception;

static constexpr Kind static_kind = Kind::throws;

Expand Down
26 changes: 6 additions & 20 deletions src/lib/AST/ParseJavadoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,28 +1143,14 @@ visitBlockCommandComment(
doc::Throws throws;
auto scope = enterScope(throws);
visitChildren(C->getParagraph());
// KRYSTIAN NOTE: clang doesn't consider these commands
// to have any arguments, so we have to extract the exception
// type manually
if(! throws.children.empty())
if (C->getNumArgs())
{
// string will start with a non-whitespace character
doc::String& text =
throws.children.front()->string;
constexpr char ws[] = " \t\n\v\f\r";
const auto except_end = text.find_first_of(ws);
throws.exception = text.substr(0, except_end);
// find the start of the next word, ignoring whitespace
const auto word_start =
text.find_first_not_of(ws, except_end);
// if we ran out of string, remove this block
if(word_start == doc::String::npos)
throws.children.erase(throws.children.begin());
// otherwise, trim the string to exclude the argument
else
text.erase(0, word_start);
throws.exception.string = C->getArgText(0);
}
else
{
throws.exception.string = "undefined";
}

jd_.emplace_back(std::move(throws));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Gen/hbs/HandlebarsCorpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ domCreate(
const HandlebarsCorpus& corpus)
{
dom::Object::storage_type entries = {
{ "exception", I.exception }
{ "exception", I.exception.string }
};
std::string s = corpus.toStringFn(corpus, I);
if (!s.empty())
Expand Down
4 changes: 2 additions & 2 deletions test-files/golden-tests/core/libcxx.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ This function calculates the square root of a given integral value using bit
|===
| Name | Thrown on

| `if`
| the input value is negative.
| `std::invalid_argument`
| if the input value is negative.


|===
Expand Down
4 changes: 2 additions & 2 deletions test-files/golden-tests/core/libcxx.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ <h3>Exceptions</h3>
</thead>
<tbody>
<tr>
<td><code>if</code></td>
<td><p><span>the input value is negative.</span></p>
<td><code>std::invalid_argument</code></td>
<td><p><span>if the input value is negative.</span></p>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion test-files/golden-tests/core/libcxx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<text>This function calculates the square root of a given integral value using bit manipulation.</text>
</para>
<throws>
<text>the input value is negative.</text>
<text>if the input value is negative.</text>
</throws>
<tparam name="T">
<text>The type of the input value. Must be an integral type. </text>
Expand Down
54 changes: 54 additions & 0 deletions test-files/golden-tests/javadoc/throw.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
= Reference
:mrdocs:

[#index]
== Global namespace


=== Functions

[cols=2]
|===
| Name | Description

| <<f,`f`>>
| brief



|===

[#f]
== f


brief



=== Synopsis


Declared in `&lt;throw&period;cpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
f();
----

=== Exceptions


|===
| Name | Thrown on

| `std&colon;&colon;length&lowbar;error`
| `dest&lowbar;size &lt; ipv4&lowbar;address&colon;&colon;max&lowbar;str&lowbar;len`


|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
5 changes: 5 additions & 0 deletions test-files/golden-tests/javadoc/throw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** brief

@throw std::length_error `dest_size < ipv4_address::max_str_len`
*/
void f();
72 changes: 72 additions & 0 deletions test-files/golden-tests/javadoc/throw.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<html lang="en">
<head>
<title>Reference</title>
</head>
<body>
<div>
<h1>Reference</h1>
<div>
<div>
<h2 id="index">Global namespace</h2>
</div>
<h2>Functions</h2>
<table style="table-layout: fixed; width: 100%;">
<thead>
<tr>
<th>Name</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#f"><code>f</code></a> </td><td><p><span>brief</span></p>

</td></tr>
</tbody>
</table>
</div>
<div>
<div>
<h2 id="f">f</h2>
<div>
<p><span>brief</span></p>


</div>
</div>
<div>
<h3>Synopsis</h3>
<div>
Declared in <code>&lt;throw.cpp&gt;</code></div>
<pre>
<code class="source-code cpp">
void
f();
</code>
</pre>
</div>
<div>
<h3>Exceptions</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Thrown on</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>std::length_error</code></td>
<td><p><code>dest_size &lt; ipv4_address::max_str_len</code></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>

</div>
<div>
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions test-files/golden-tests/javadoc/throw.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<mrdocs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc">
<namespace id="//////////////////////////8=">
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
<file path="throw.cpp" line="5"/>
<doc>
<para>
<text>brief</text>
</para>
<throws>
<mono>dest_size &lt; ipv4_address::max_str_len</mono>
</throws>
</doc>
</function>
</namespace>
</mrdocs>
Loading
Loading