Skip to content

[rustdoc, request] Please bundle local relative resources (favicon, logo, whatever) #79254

Open
@jnqnfe

Description

@jnqnfe

For some of my crates I have a favicon and logo within the repo but have to point to them via public links like this:

#![doc(html_logo_url = "https://github.com/jnqnfe/pulse-binding-rust/raw/master/logo.png",
       html_favicon_url = "https://github.com/jnqnfe/pulse-binding-rust/raw/master/favicon.ico")]

What I would love (and have long wanted) is if I could simply refer to the files with a relative path like this...:

#![doc(html_logo_url = "../../logo.png", html_favicon_url = "../../favicon.ico")]

...and cargo doc would then bundle them into the set of generated documentation files, such that when viewing the documentation offline locally, these resources are loaded from the target/doc/ directory, and for the docs.rs copy, docs.rs would serve them along with the rest of the page components.

This would include the following advantages:

  • The favicon and logo would actually get loaded properly when viewing documentation offline. (It's very annoying that they don't, and loading them once at some point when you are online is not sufficient to subsequently ensure they are shown from cache in my experience).
  • Helps ensure in future that a change such as a move of the repo from github to gitlab, or move/rename of the files within the master copy of the public repo, does not break display of these items for older published versions of crates due to broken links.
  • Helps avoid in future trouble replacing favicon/logo images with new ones for new releases without replacing the older copies for older versions of the documentation, without making a mess of maintaining multiple versions of the file within the repo.
  • Helps alleviate any privacy concerns from loading such resources while online but reading local documentation.

Perhaps this could be applied to all such local relatively referenced image resources (others too?), not just favicon and logo, to cover situations where repos include images to embed in docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions