Proposed lint: `rustdoc::unprefixed_html_id`

I think there might be a bit of misunderstanding about what this point means:

  • Do not embed CSS or JavaScript in doc comments to customize rustdoc's UI. If you want to publish documentation with a customized UI, invoke rustdoc with the --html-in-header [command-line parameter] to generate it with your custom stylesheet or script, then publish the result as pre-built HTML.

If you are using custom classes or IDs in your doc comments themselves, those aren't actually part of rustdoc's UI. They're part of the doc author's UI, and their scripts should probably be embedded in the doc comment itself so that it gets inlined along with the documentation itself.

Does this new version of the bullet point make the idea a bit clearer?

  • Embedded CSS and JavaScript in doc comments should touch classes and IDs that are declared in the doc comment itself, and should not be used to customize rustdoc's UI. If you want to publish documentation with a customized UI, invoke rustdoc with the --html-in-header [command-line parameter] to generate it with your custom stylesheet or script, then publish the result as pre-built HTML.
2 Likes