Skip to content

refactor: simplify handlebars generators #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 13, 2024
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
13 changes: 11 additions & 2 deletions include/mrdocs/Generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ class MRDOCS_VISIBLE
depending on the generator and how it is
configured.

The default implentation assumes the output
is single-page and emits the file `reference.ext`
using @ref buildOne to generate the content.

The typical implementation will have behavior
similar to the default implementation if the
output is single-page, or will iterate over
the symbols in the corpus to generate multiple
files if the output is multi-page.

@return The error, if any occurred.

@param outputPath An existing directory or
a filename.
@param outputPath A directory or filename.

@param corpus The symbols to emit. The
generator may modify the contents of
Expand Down
7 changes: 7 additions & 0 deletions include/mrdocs/Support/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2747,6 +2747,13 @@ void
setMinimumLevel(
Level level) noexcept;

/** If true, source location information will be
printed with warnings, errors, and fatal messages.
*/
MRDOCS_DECL
void
setSourceLocationWarnings(bool b) noexcept;

/** Report a message to the console.

@param text The message to print. A
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
{{! The section with a symbol in single page output or the symbol page in multi page output }}
{{#if relfileprefix}}:relfileprefix: {{relfileprefix}}{{/if}}
[#{{#if (is_multipage)}}{{symbol.id}}{{else}}{{symbol.ref}}{{/if}}]

{{> (concat 'symbols' '/' (lookup symbol 'kind')) symbol=symbol}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- alias --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- concept --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent includeNamespace=true}}{{symbol.name}}</h2>
{{symbol.doc.brief}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- enum --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{#if symbol.name}}Enum {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed enum{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- enumerator --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>Enumerator {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- field --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- friend --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>Friend {{#if symbol.symbol}}{{symbol.symbol.name}}{{else}}{{symbol.type.name}}{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- function --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>Function {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- guides --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>Deduction guide {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- namespace --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{#if symbol.name}}Namespace {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else if symbol.parent}}Unnamed namespace{{else}}Global namespace{{/if}}</h2>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- record --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{#if symbol.name}}Class {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed class{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- typedef --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- symbols/using.html.hbs --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>Using {{#if (eq symbol.class "namespace")}}Directive: {{symbol.qualifier.name}}{{else}}Declaration: {{symbol.name}}{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- variable --}}
<div id="{{symbol.id}}">
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/Dom/LazyObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ namespace detail
}
}
};

// Deduction guide
template <class MapFn, class DeferFn = void*>
LazyObjectIO(MapFn, DeferFn = {}) -> LazyObjectIO<MapFn, DeferFn>;
}

template <class T, class Context>
Expand All @@ -274,7 +278,7 @@ std::size_t
LazyObjectImpl<T, Context>::
size() const
{
std::size_t result;
std::size_t result = 0;
detail::LazyObjectIO io(
[&result, this](std::string_view name, auto const& /* value or deferred */)
{
Expand Down
Loading