Skip to content

Commit

Permalink
fix: doc::Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Jul 9, 2023
1 parent 04fc1dd commit f8e72bb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 6 deletions.
29 changes: 28 additions & 1 deletion lib/-adoc/AdocCorpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <fmt/format.h>
#include <iterator>

#include <llvm/Support/raw_ostream.h>

namespace clang {
namespace mrdox {
namespace adoc {
Expand Down Expand Up @@ -58,7 +60,29 @@ DocVisitor::
operator()(
doc::Admonition const& I)
{
//dest_ += I.string;
std::string_view label;
switch(I.admonish)
{
case doc::Admonish::note:
label = "NOTE";
break;
case doc::Admonish::tip:
label = "TIP";
break;
case doc::Admonish::important:
label = "IMPORTANT";
break;
case doc::Admonish::caution:
label = "CAUTION";
break;
case doc::Admonish::warning:
label = "WARNING";
break;
default:
MRDOX_UNREACHABLE();
}
dest_ += fmt::format("[{}]\n", label);
(*this)(static_cast<doc::Paragraph const&>(I));
}

void
Expand Down Expand Up @@ -123,6 +147,7 @@ operator()(
}
}
dest_.push_back('\n');
dest_.push_back('\n');
}

void
Expand Down Expand Up @@ -276,7 +301,9 @@ class DomJavadoc : public dom::LazyObjectImpl
for(auto const& t : nodes)
doc::visit(*t, visitor);
if(! s.empty())
{
list.emplace_back(key, std::move(s));
}
};

dom::Object
Expand Down
7 changes: 5 additions & 2 deletions lib/Metadata/Javadoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ makeOverview(
TParam const*>(it->get()));
break;
case Kind::paragraph:
ov.brief = static_cast<
Paragraph const*>(it->get());
if(! ov.brief)
ov.brief = static_cast<
Paragraph const*>(it->get());
else
ov.blocks.push_back(it->get());
break;
default:
ov.blocks.push_back(it->get());
Expand Down
28 changes: 27 additions & 1 deletion test-files/adoc/test.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
struct T {};
/** The type of string_view used by the library
String views are used to pass character
buffers into or out of functions. Ownership
of the underlying character buffer is not
transferred; the caller is responsible for
ensuring that the lifetime of character
buffer extends until it is no longer
referenced.
@note This alias is no longer supported and
should not be used in new code. Please use
`core::string_view` instead.
This alias is included for backwards
compatibility with earlier versions of the
library.
However, it will be removed in future releases,
and using it in new code is not recommended.
Please use the updated version instead to
ensure compatibility with future versions of
the library.
*/
struct string_view{};
40 changes: 38 additions & 2 deletions test-files/adoc/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,44 @@
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
<namespace>
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
<file path="test.cpp" line="1" class="def"/>
<struct name="string_view" id="AbyPschn1Km27CQSV03D1w7MAo0=">
<file path="test.cpp" line="27" class="def"/>
<doc>
<para>
<text> The type of string_view used by the library</text>
</para>
<para>
<text> String views are used to pass character</text>
<text> buffers into or out of functions. Ownership</text>
<text> of the underlying character buffer is not</text>
<text> transferred; the caller is responsible for</text>
<text> ensuring that the lifetime of character</text>
<text> buffer extends until it is no longer</text>
<text> referenced.</text>
</para>
<para>
<text></text>
</para>
<para class="note">
<text> This alias is no longer supported and</text>
<text> should not be used in new code. Please use</text>
<text> `core::string_view` instead.</text>
</para>
<para>
<text> This alias is included for backwards</text>
<text> compatibility with earlier versions of the</text>
<text> library.</text>
</para>
<para>
<text> However, it will be removed in future releases,</text>
<text> and using it in new code is not recommended.</text>
</para>
<para>
<text> Please use the updated version instead to</text>
<text> ensure compatibility with future versions of</text>
<text> the library.</text>
</para>
</doc>
</struct>
</namespace>
</mrdox>

0 comments on commit f8e72bb

Please sign in to comment.