Skip to content

Commit

Permalink
fix: adoc multipage wrapper includes relfileprefix
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Dec 3, 2024
1 parent 8693504 commit 111b424
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
27 changes: 26 additions & 1 deletion share/mrdocs/addons/generator/adoc/layouts/wrapper.adoc.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,32 @@
Breadcrumbs are included in the symbol template as an alternative.
}}
= {{> symbol/qualified-name symbol nolink=true }}
= {{> symbol/qualified-name symbol }}
{{!
Antora does not support relative links to pages in
parent directories. Therefore, unlike in HTML templates,
links are not relativized.
However, while Antora interprets xref as relative
to the root of the module, these xref are
interpreted as relative to the current directory
because it has no concept of modules. This means
links would be broken with either Antora or Asciidoc.
Even more, Antora uses the same rule as Asciidoc
for breadcrumbs and the page title, where links
would also be broken.
The solution is to set the relfileprefix attribute,
which includes the relative location of the root
directory and makes all links relative to it.
This relfileprefix affects Asciidoc links, the
Antora title, and the Antora breadcrumbs.
See https://docs.asciidoctor.org/asciidoc/latest/macros/inter-document-xref/#mapping-references-to-a-different-structure
}}
:relfileprefix: {{{ repeat "../" (count (remove_prefix symbol.url '/') '/') }}}
{{else}}
{{! Single page documentation: symbol is not available to the wrapper }}
= Reference
Expand Down
12 changes: 0 additions & 12 deletions share/mrdocs/addons/generator/adoc/partials/symbol.adoc.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
{{#if symbol.doc.brief}}
{{{symbol.doc.brief}}}

{{/if}}
{{! Breadcrumbs
The antora breadcrumbs do not work with the multipage documentation.
This includes symbol/qualified-name here as an alternative for users
to visit parent scopes.
}}
{{#if @root.config.multipage }}
{{#> markup/code-block }}
{{> symbol/qualified-name symbol }}
{{/markup/code-block}}
{{/if}}
{{! Synopsis }}
{{#unless (eq symbol.kind "namespace")}}
Expand Down

0 comments on commit 111b424

Please sign in to comment.