Skip to content

fix asciidoc link issues #899

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 3 commits into from
Apr 9, 2025
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
11 changes: 11 additions & 0 deletions include/mrdocs/Support/Handlebars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,17 @@ MRDOCS_DECL
void
registerContainerHelpers(Handlebars& hbs);

/** Register type helpers into a Handlebars instance

This function registers a number of common helpers that operate on
types, such as identity, type checking, and type conversion.

@param hbs The Handlebars instance to register the helpers into
*/
MRDOCS_DECL
void
registerTypeHelpers(Handlebars& hbs);

/** "and" helper function
*
* The "and" helper returns true if all of the values are truthy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
https://gitlab.com/antora/antora/-/issues/428
}}
{{#if (starts_with href "#")~}}
<<{{{remove_prefix href "#"}}},{{> @partial-block }}>>
link:{{{ href }}}[{{> @partial-block }}]
{{~else if (starts_with href "/")~}}
xref:{{{remove_prefix href "/"}}}[{{> @partial-block }}]
{{~else if (starts_with href ".")~}}
Expand Down
10 changes: 3 additions & 7 deletions share/mrdocs/addons/generator/adoc/partials/symbol.adoc.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@
| Name
| Description
{{#each (filter_by symbol.constants "isRegular" "isSeeBelow")}}
{{#if (ne kind "enum-constant")}}
|xref:{{{anchor}}}[`{{>symbol/name . nolink=true}}`]
{{else}}
|`{{>symbol/name . nolink=true}}`
{{/if}}
|`{{>symbol/name-text .}}`
|{{> javadoc/inline-brief doc.brief }}
{{/each}}
|===
Expand Down Expand Up @@ -121,9 +117,9 @@
| Description
{{#each symbol.derived}}
| {{#if url~}}
{{#>markup/a href=url}}{{#>markup/code}}{{> symbol/name-info . nolink=true}}{{/markup/code}}{{/markup/a}}
{{#>markup/a href=url}}{{#>markup/code}}{{> type/name-info-text . }}{{/markup/code}}{{/markup/a}}
{{else~}}
{{> symbol/name-info . nolink=true}}
{{> type/name-info-text . }}
{{/if}}
| {{> javadoc/inline-brief doc.brief }}
{{/each}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
{{#>markup/tr}}
{{#>markup/td~}}
{{~#if isName~}}
{{!~ The first row is a name-info ~}}
{{~#if symbol.url~}}
{{~#>markup/a href=symbol.url}}{{#>markup/code}}{{> symbol/name-info . nolink=true}}{{/markup/code}}{{/markup/a~}}
{{~#>markup/a href=symbol.url}}{{#>markup/code}}{{> type/name-info-text . }}{{/markup/code}}{{/markup/a~}}
{{~else~}}
{{~> symbol/name-info . nolink=true~}}
{{~> type/name-info-text . ~}}
{{~/if~}}
{{~else~}}
{{!~ The first row is a name-info ~}}
{{~#>markup/a href=url}}{{#>markup/code}}{{>symbol/name-text .}}{{/markup/code}}{{/markup/a}} {{>symbol/special-function-suffix .~}}
{{~/if~}}
{{~/markup/td}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@

Expected Context: {Symbol Object}

Optional parameters:
nolink: If true, types and symbols will not be linked.
link: Symbol that should be linked to, regardless of the original symbol.

Example:
{{> declarator symbol }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~#if (and (eq kind "function") (eq functionClass "conversion"))~}}
{{! Conversion operator: "operator" and the type declarator ~}}
operator {{>type/declarator return nolink=true~}}
operator {{>type/declarator-text return ~}}
{{~else if (eq kind "guide")~}}
{{! Deduction guide: "deduced" type declarator ~}}
{{>type/declarator deduced nolink=true~}}
{{>type/declarator-text deduced ~}}
{{~else~}}
{{! Symbol with URL: link to the symbol documentation ~}}
{{~#if name~}}
Expand All @@ -32,6 +28,6 @@
{{~/if~}}
{{~#if (contains (arr "explicit" "partial") template.kind)~}}
{{! Explicit or partial template: render the template arguments ~}}
{{>template/args args=template.args nolink=true~}}
{{>template/args-text args=template.args ~}}
{{~/if~}}
{{~/if~}}
9 changes: 3 additions & 6 deletions share/mrdocs/addons/generator/common/partials/symbol/name.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@

Expected Context: {Symbol Object}

Optional parameters:
nolink: If true, types and symbols will not be linked.

Example:
{{> declarator symbol }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~#if (and (eq kind "function") (eq functionClass "conversion"))~}}
{{! Conversion operator: "operator" and the type declarator ~}}
operator {{>type/declarator return nolink=false~}}
operator {{>type/declarator return ~}}
{{~else if (eq kind "guide")~}}
{{! Deduction guide: "deduced" type declarator ~}}
{{>type/declarator deduced nolink=false~}}
{{~else if (and url (not nolink))~}}
{{>type/declarator deduced ~}}
{{~else if url~}}
{{#>markup/a href=url}}{{>symbol/name-text}}{{/markup/a~}}
{{~else~}}
{{~>symbol/name-text~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
{{~> symbol/name . ~}}
{{~/if~}}
{{~else if (eq kind "guide")~}}
{{>type/declarator deduced nolink=false~}}
{{>type/declarator deduced ~}}
{{~else if (contains (arr "explicit" "partial") template.kind)~}}
{{!~ If the last part is a template specialization, we include links to primary template and the arguments. ~}}
{{!~ If the primary template wasn't correctly extracted for some reason, we just print the name as usual. ~}}
{{#if template.primary }}{{~>symbol/name template.primary ~}}{{else}}{{ name }}{{/if}}{{>template/args args=template.args nolink=false~}}
{{#if template.primary }}{{~>symbol/name template.primary ~}}{{else}}{{ name }}{{/if}}{{>template/args args=template.args ~}}
{{~else~}}
{{~> symbol/name-text . ~}}
{{~/if~}}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~#if (and url (not nolink))~}}
{{~#if url~}}
{{#>markup/a href=url}}{{>symbol/qualified-name-text}}{{/markup/a~}}
{{~else~}}
{{~>symbol/qualified-name-text~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{> (concat 'symbol/signature/' kind) nolink=nolink }}
{{> (concat 'symbol/signature/' kind) }}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{~else if (eq functionClass "conversion")~}}
{{>symbol/name symbol }}
{{~else if (contains (arr "explicit" "partial") template.kind)~}}
{{>symbol/name template.primary ~}}{{>template/args args=template.args nolink=true~}}
{{>symbol/name template.primary ~}}{{>template/args-text args=template.args ~}}
{{~else~}}
{{>symbol/name-text symbol }}
{{~/if~}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
namespace {{ name }} = {{> symbol/name-info aliasedSymbol }};
namespace {{ name }} = {{> type/name-info aliasedSymbol }};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/if~}}
{{#if isFriend}}friend {{/if~}}
{{~tag}} {{#if (contains (arr "explicit" "partial") template.kind)~}}
{{>symbol/name template.primary ~}}{{>template/args args=template.args nolink=nolink~}}
{{>symbol/name template.primary ~}}{{>template/args args=template.args ~}}
{{~else~}}
{{>symbol/name-text symbol ~}}
{{~/if}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using {{#if (contains (arr "typename" "enum") usingClass)}} {{usingClass}}
{{~/if~}}
{{~#if qualifier~}}
{{>symbol/name-info qualifier }}::
{{>type/name-info qualifier }}::
{{~/if}}{{name}};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{!--
Renders a template argument as text.

This partial renders a template argument for a template instantiation.

Expected Context: {TArg}

Example:
{{> template/arg symbol.template.args[0] }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~>template/arg . link-components-impl=false ~}}
13 changes: 9 additions & 4 deletions share/mrdocs/addons/generator/common/partials/template/arg.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{!--

Renders a template argument.
Renders a template argument with links to any named component.

This partial renders a template argument for a template instantiation.

Expand All @@ -13,13 +12,19 @@
--}}
{{#if (eq kind "type")~}}
{{! TArg is a type: render the declarator ~}}
{{~>type/declarator type nolink=nolink~}}
{{~>type/declarator type link-components-impl=link-components-impl~}}
{{else if (eq kind "non-type")~}}
{{! TArg is a non-type: render the value string as is ~}}
{{~value~}}
{{else if (eq kind "template")~}}
{{! TArg is another template: render the template head ~}}
{{#if (and template (not nolink))}}{{#>markup/a href=template.url}}{{name}}{{/markup/a}}{{else~}}{{name~}}{{/if~}}
{{~#if (and template template.url (or link-components-impl (is_undefined link-components-impl)))~}}
{{~#>markup/a href=template.url~}}
{{~name~}}
{{~/markup/a~}}
{{~else~}}
{{name~}}
{{~/if~}}
{{/if~}}
{{~#if is-pack~}}
{{ str "..." }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{!--
Renders all template arguments as text.

This partial renders all template arguments for a template instantiation.

Expected Context: {Template Info}

Example:
{{> template/args symbol.template.args }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~>template/args link-components-impl=false~}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{!--

Renders all template arguments.
Renders all template arguments with links to any named component.

This partial renders all template arguments for a template instantiation.

Expand All @@ -12,6 +11,6 @@
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{ str '<' }}{{~#each args~}}
{{~>template/arg nolink=../nolink~}}
{{~>template/arg link-components-impl=../link-components-impl~}}
{{~#if (not @last)}}, {{/if~}}
{{~/each~}}{{ str '>' }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{!--
Renders the template head for a template declaration as text.

This partial renders the template head with all the template parameters.

Expected Context: {Template Info}

Example:
{{> template/head symbol.template }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~>template/head-text link-components-impl=link-components-impl~}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!--
Renders the template head for a template declaration.
Renders the template head for a template declaration with links to any named component.

This partial renders the template head with all the template parameters.

Expand All @@ -11,7 +11,7 @@
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
template{{ str '<' }}{{#each params}}{{#unless (and @first @last)}}
{{/unless}}{{>template/param~}}
{{/unless}}{{>template/param link-components-impl=link-components-impl~}}
{{#unless @last}},{{/unless~}}
{{/each}}{{ str '>' }}{{#if requires}}
requires {{requires}}{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{!--
Renders a template parameter as text.

If the template parameter is a type, the templated type name is rendered.
If the template parameter is a non-type, the declarator of the type is rendered.
If the template parameter is a template, the template head is rendered.

Expected Context: {TParam}

Example:
{{> template/param tparam }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~> template/param . link-components-impl=false ~}}
13 changes: 6 additions & 7 deletions share/mrdocs/addons/generator/common/partials/template/param.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{!--

Renders a template parameter.
Renders a template parameter with links to any named components.

If the template parameter is a type, the templated type name is rendered.
If the template parameter is a non-type, the declarator of the type is rendered.
Expand All @@ -14,15 +13,15 @@
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{#if (eq kind "type")~}}
{{#if constraint}}{{>symbol/name-info constraint }}{{else}}{{key}}{{/if~}}
{{#if constraint}}{{>type/name-info constraint link-components-impl=link-components-impl }}{{else}}{{key}}{{/if~}}
{{#if is-pack}}{{ str "..." }}{{/if~}}
{{#if name}} {{name}}{{/if~}}
{{#if default}} = {{>template/arg default~}}{{/if~}}
{{#if default}} = {{>template/arg default link-components-impl=link-components-impl ~}}{{/if~}}
{{else if (eq kind "non-type")~}}
{{>type/declarator type decl-name=name}}{{#if is-pack}}{{ str "..." }}{{/if~}}
{{#if default}} = {{>template/arg default~}}{{/if~}}
{{>type/declarator type decl-name=name link-components-impl=link-components-impl }}{{#if is-pack}}{{ str "..." }}{{/if~}}
{{#if default}} = {{>template/arg default link-components-impl=link-components-impl~}}{{/if~}}
{{else if (eq kind "template")~}}
{{>template/head}} typename{{#if is-pack}}{{ str "..." }}{{/if~}}
{{#if name}} {{name}}{{/if~}}
{{#if default}} = {{>template/arg default~}}{{/if~}}
{{#if default}} = {{>template/arg default link-components-impl=link-components-impl~}}{{/if~}}
{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{!--
Renders declaration prefix of a Type Info Object as text.

The prefix is the part of the declaration that comes before the type name.
It includes the pointer, array, and function declarators.

Expected Context: {Type Info}

Example:
{{> declarator-prefix type }}

See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
--}}
{{~>type/declarator-prefix . link-components-impl=false ~}}
Loading
Loading