Skip to content
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

docs: fix janky rendering of toc on docs.docker.com #5653

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

dvdksn
Copy link
Contributor

@dvdksn dvdksn commented Nov 28, 2024

The right-hand toc was rendering in a janky way due to empty anchor tags

image image

@dvdksn dvdksn requested review from thaJeztah and a team as code owners November 28, 2024 14:03
@dvdksn
Copy link
Contributor Author

dvdksn commented Nov 28, 2024

cc @corhere

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.49%. Comparing base (682cf57) to head (0f05804).
Report is 11 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5653   +/-   ##
=======================================
  Coverage   59.49%   59.49%           
=======================================
  Files         346      346           
  Lines       29371    29371           
=======================================
  Hits        17474    17474           
  Misses      10922    10922           
  Partials      975      975           

#### <a name="log-format"></a> Daemon logging format
#### Daemon logging format {#log-format}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use this approach for all of the CLI reference docs (and use that format to match sections with the options table); is it an issue for those as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there it works because they use a different templating logic.

The default toc rendering uses a recursive template on Hugo's heading fragments, which are parsed out of the markdown file: https://github.com/docker/docs/blob/main/layouts/partials/pagemeta.html

The CLI reference docs are rendered from yaml files, so we can't use the same API. Instead, we construct the toc manually using a page store, and render that: https://github.com/docker/docs/blob/380ca6cc9de0143e462cd36c14f91319de22aece/layouts/_default/cli.html#L197-L224

Funny thing is that the markdown-in-yaml of the CLI reference files also contain the {#syntax} for heading IDs. It's just the source markdown files in these upstream repos that have the <a name=""></a> markup. The empty links are converted to {#syntax} by cli-docs-tool; https://github.com/docker/cli-docs-tool/blob/53293118a80f36cef8740c257aadba0507bdf572/markdown.go#L87-L100

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! That way, gotcha

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 41fba28 into docker:master Nov 28, 2024
95 checks passed
@thaJeztah thaJeztah added this to the 28.0.0 milestone Nov 28, 2024
@thaJeztah
Copy link
Member

@dvdksn can you open a backport for the 27.x branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants