Skip to content

Conversation

antonincms
Copy link

@antonincms antonincms commented Nov 27, 2024

Implementation

This PR fixes links to multi-version CRDs by adding a reference to the version in the anchor and the link.

Approach

I considered implementing links in pure Markdown, like #### v1.Embedded1, but preferred to use HTML links instead, like #### <a id="github-com-elastic-crd-ref-docs-api-v1-embedded1">Embedded1</a>. This approach is closer to what is done in Asciidoc and the final result seems more readable to me (especially in multigroup APIs where it would look like #### mygroupname-v2alpha1.Embedded1). I guess supporting both methods could be an option, but it would require two functions to render links, and users would need to know how to adjust their templating accordingly.

This change will also break existing links in custom Markdown templates, as it now uses GroupVersionID to link to resources. To fix this, replace ## {{ $gv.GroupVersionString }} in gv_details.tpl with ## <a id="{{ markdownGroupVersionID $gv | markdownSafeID }}">{{ $gv.GroupVersionString }}</a>.

As explained in #60 I could not find a way to implement this change in a backward-compatible manner for users having custom markdown templating, except by introducing a new function like markdownRenderHTMLTypeLink. However, I wanted to get feedback before implementing this approach because:

  • the current rendering method is broken for multiversion APIs
  • crd-ref-docs is still in v0.x.y so I think we could tolerate breaking custom templates for markdown
  • this change would align Markdown output more closely with AsciiDoc

Fixes #60

Copy link

cla-checker-service bot commented Nov 27, 2024

💚 CLA has been signed

This change will break existing links in custom Markdown templates, as it now uses GroupVersionID to link to resources.
To fix this, replace `## {{ $gv.GroupVersionString }}` in gv_details.tpl with `## <a id="{{ markdownGroupVersionID $gv | markdownSafeID }}">{{ $gv.GroupVersionString }}</a>`.
@antonincms antonincms force-pushed the improve-markdown-links branch from 3657ae5 to 0f1bcf0 Compare August 6, 2025 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Incorrect links to multi-version CRDs

1 participant