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
12 changes: 8 additions & 4 deletions include/mrdocs/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@ struct MRDOCS_DECL

bool operator==(const Block& other) const noexcept
{
if(kind != other.kind)
if (kind != other.kind)
{
return false;
}
return std::equal(children.begin(), children.end(),
other.children.begin(), other.children.end(),
[](const auto& a, const auto& b)
Expand All @@ -410,6 +412,8 @@ struct MRDOCS_DECL

void append(List<Node>&& blocks);

void append(List<Text> const& otherChildren);

protected:
explicit
Block(
Expand Down Expand Up @@ -892,7 +896,7 @@ void traverse(

struct Overview
{
Paragraph const* brief = nullptr;
std::shared_ptr<Paragraph> brief = nullptr;
std::vector<Block const*> blocks;
Returns const* returns = nullptr;
std::vector<Param const*> params;
Expand All @@ -916,6 +920,8 @@ class Corpus;
class MRDOCS_DECL
Javadoc
{
doc::List<doc::Block> blocks_;

public:
/** Constructor.
*/
Expand Down Expand Up @@ -1015,8 +1021,6 @@ class MRDOCS_DECL

private:
std::string emplace_back(std::unique_ptr<doc::Block>);

doc::List<doc::Block> blocks_;
};

/** Return the Javadoc as a @ref dom::Value.
Expand Down
8 changes: 7 additions & 1 deletion include/mrdocs/Support/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2702,6 +2702,10 @@ void
setMinimumLevel(
Level level) noexcept;

MRDOCS_DECL
Level
getMinimumLevel() noexcept;

/** If true, source location information will be
printed with warnings, errors, and fatal messages.
*/
Expand Down Expand Up @@ -2787,9 +2791,11 @@ log_impl(
Level level,
Located<std::string_view> fs)
{
std::string str = fmt::vformat(
fs.value, fmt::make_format_args());
return print(
level,
{},
str,
&fs.where);
}
}
Expand Down
4 changes: 2 additions & 2 deletions mrdocs.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ grammar
BlockNode = (
Admonition | Brief | Code | Heading | ListItem |
Paragraph | Param | Returns | TParam | Throws |
See | Precondition | Postcondition)
See | Precondition | Postcondition | Details)

Admonition = Paragraph
Brief = element brief { TextNode * }
Expand All @@ -411,7 +411,7 @@ grammar
TextNode * }
Precondition = element pre { TextNode * }
Postcondition = element post { TextNode * }

Details = element details { TextNode * }

TextNode = ( Link | Styled | Text | Reference | Copied )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{{else~}}
{{#each (unique (pluck (pluck members "doc") "brief"))~}}
{{{.}}}

{{/each~}}
{{/if~}}
{{~/markup/td~}}
Expand Down
10 changes: 2 additions & 8 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,16 +1774,10 @@ generateJavadoc(
{
RawComment const* RC =
D->getASTContext().getRawCommentForDeclNoCache(D);
if (!RC)
{
return false;
}
MRDOCS_CHECK_OR(RC, false);
comments::FullComment* FC =
RC->parse(D->getASTContext(), &sema_.getPreprocessor(), D);
if (!FC)
{
return false;
}
MRDOCS_CHECK_OR(FC, false);
parseJavadoc(javadoc, FC, D, config_, diags_);
return true;
}
Expand Down
18 changes: 12 additions & 6 deletions src/lib/Gen/adoc/DocVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ operator()(
fmt::format_to(ins_, "\n=== {}\n\n", AdocEscape(I.string));
}

// Also handles doc::Brief
void
DocVisitor::
operator()(
Expand Down Expand Up @@ -135,14 +134,21 @@ operator()(
{
return;
}
bool non_empty = write(*children.front(), *this);
for(auto const& child : children.subspan(1))

std::size_t i = 0;
for (auto it = children.begin(); it != children.end(); ++it)
{
if (non_empty)
auto& child = *it;
if (i == 0)
{
dest_.push_back('\n');
child->string = ltrim(child->string);
}
non_empty = write(*child, *this);
if (i == children.size() - 1)
{
child->string = rtrim(child->string);
}
write(*child, *this);
i = i + 1;
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/lib/Gen/hbs/HandlebarsCorpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ getJavadoc(Javadoc const& jd) const
When the string is empty, the object key
is undefined.
*/
auto emplaceString = [&](
std::string_view key,
auto const& I)
auto emplaceString = [&]<typename T>(
std::string_view key, T const& I)
{
std::string s;
using T = std::decay_t<decltype(I)>;
if constexpr (std::derived_from<T, doc::Node>)
{
// doc::visit(*t, visitor);
Expand Down Expand Up @@ -232,13 +230,17 @@ getJavadoc(Javadoc const& jd) const
elements.reserve(nodes.size());
for(auto const& elem : nodes)
{
if(!elem)
if (!elem)
{
continue;
}
elements.emplace_back(
domCreate(*elem, *this));
}
if(elements.empty())
if (elements.empty())
{
return;
}
objKeyValues.emplace_back(key, dom::newArray<
dom::DefaultArrayImpl>(std::move(elements)));
};
Expand Down
35 changes: 24 additions & 11 deletions src/lib/Gen/html/DocVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,38 @@ DocVisitor::
operator()(
doc::Brief const& I) const
{
if (I.children.empty())
{
return;
}

dest_.append("<span>");
for(auto const& it : RangeFor(I.children))
std::size_t i = 0;
for (auto it = I.children.begin(); it != I.children.end(); ++it)
{
auto const n = dest_.size();
doc::visit(*it.value, *this);
// detect empty text blocks
if(! it.last && dest_.size() > n)
auto& child = *it;
if (i == 0)
{
// wrap past 80 cols
if (dest_.size() < 80)
child->string = ltrim(child->string);
}
else if (auto prevIt = std::prev(it);
!(*prevIt)->string.empty() && !child->string.empty())
{
char const pc = (*(prevIt))->string.back();
char const cc = child->string.front();
if (!std::isspace(pc) && !std::isspace(cc))
{
dest_.push_back(' ');
} else
{
dest_.push_back('\n');
}
}
if (i == I.children.size() - 1)
{
child->string = rtrim(child->string);
}
write(*child, *this);
i = i + 1;
}
dest_.append("</span>");
dest_.append("</span>\n");
}

void
Expand Down
Loading