Skip to content

Commit e6ee971

Browse files
committed
refactor: simplify handlebars generators
Apart from the DocVisitor, the Adoc and HTML generators are nearly 100% duplicated code. This is the main reason the HTML Generator is always behind the Adoc Generator: simple features were not duplicated in the HTML generator. This even justified #656, where we would temporarily remove the HTML generator. This commit unifies the standard code to remove duplicated code, simplify maintenance, and ensure that both generators always have access to the same features. In passing, many missing features in the HTML generator are now available. fix #656
1 parent 0823b48 commit e6ee971

File tree

190 files changed

+3834
-7028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+3834
-7028
lines changed

include/mrdocs/Generator.hpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,19 @@ class MRDOCS_VISIBLE
8282
depending on the generator and how it is
8383
configured.
8484
85+
The default implentation assumes the output
86+
is single-page and emits the file `reference.ext`
87+
using @ref buildOne to generate the content.
88+
89+
The typical implementation will have behavior
90+
similar to the default implementation if the
91+
output is single-page, or will iterate over
92+
the symbols in the corpus to generate multiple
93+
files if the output is multi-page.
94+
8595
@return The error, if any occurred.
8696
87-
@param outputPath An existing directory or
88-
a filename.
97+
@param outputPath A directory or filename.
8998
9099
@param corpus The symbols to emit. The
91100
generator may modify the contents of

include/mrdocs/Support/Error.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,13 @@ void
27472747
setMinimumLevel(
27482748
Level level) noexcept;
27492749

2750+
/** If true, source location information will be
2751+
printed with warnings, errors, and fatal messages.
2752+
*/
2753+
MRDOCS_DECL
2754+
void
2755+
setSourceLocationWarnings(bool b) noexcept;
2756+
27502757
/** Report a message to the console.
27512758
27522759
@param text The message to print. A
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
{{! The section with a symbol in single page output or the symbol page in multi page output }}
2-
{{#if relfileprefix}}:relfileprefix: {{relfileprefix}}{{/if}}
3-
[#{{#if (is_multipage)}}{{symbol.id}}{{else}}{{symbol.ref}}{{/if}}]
4-
52
{{> (concat 'symbols' '/' (lookup symbol 'kind')) symbol=symbol}}

share/mrdocs/addons/generator/html/partials/symbols/alias.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- alias --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/concept.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- concept --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{>types/nested-name-specifier symbol=symbol.parent includeNamespace=true}}{{symbol.name}}</h2>
55
{{symbol.doc.brief}}

share/mrdocs/addons/generator/html/partials/symbols/enum.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- enum --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{#if symbol.name}}Enum {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed enum{{/if}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/enumerator.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- enumerator --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>Enumerator {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/field.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- field --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/friend.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- friend --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>Friend {{#if symbol.symbol}}{{symbol.symbol.name}}{{else}}{{symbol.type.name}}{{/if}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/function.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- function --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>Function {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/guide.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- guides --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>Deduction guide {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/namespace.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- namespace --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<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>
55
</div>

share/mrdocs/addons/generator/html/partials/symbols/record.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- record --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{#if symbol.name}}Class {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed class{{/if}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/typedef.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- typedef --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/using.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- symbols/using.html.hbs --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>Using {{#if (eq symbol.class "namespace")}}Directive: {{symbol.qualifier.name}}{{else}}Declaration: {{symbol.name}}{{/if}}</h2>
55
{{{symbol.doc.brief}}}

share/mrdocs/addons/generator/html/partials/symbols/variable.html.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{!-- variable --}}
2-
<div id="{{symbol.id}}">
2+
<div {{#if sectionref}}id="{{sectionref}}"{{/if}}>
33
<div>
44
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
55
{{{symbol.doc.brief}}}

0 commit comments

Comments
 (0)