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

Insert package name/version in API docs #1681

Closed
bluss opened this issue Jun 3, 2015 · 5 comments · Fixed by #7903
Closed

Insert package name/version in API docs #1681

bluss opened this issue Jun 3, 2015 · 5 comments · Fixed by #7903
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc

Comments

@bluss
Copy link
Member

bluss commented Jun 3, 2015

Find a way to insert package name/version in generated docs by cargo doc.

Currently I use sed to add the version of my package to the title of all doc pages. Adding this feature to cargo would spread this convention further, which would be useful, and I wouldn't have to use make & sed to script it 😄

@manuel-woelker
Copy link

So what is the best solution for handling this?

  1. Have rustdoc parse the Cargo.toml and extract the version (but should rust know about cargo?)
  2. Have cargo set a parameter when invoking rustdoc to set version (roundabout but somewhat clean)
  3. fixup the html after rustdoc has done its job (no changes to rustdoc, but messy and error-prone)

@Razican
Copy link

Razican commented Sep 6, 2016

I would say 2 should be the way to go.

@softprops
Copy link

fwiw worth, these env vars should be available to any cargo triggered process, included CARGO_PKG_NAME, CARGO_PKG_VERSION. I've often found them to be vary useful for generating automated cli output for versions and user agent strings for http clients. They may also be helpful here.

@carols10cents carols10cents added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc labels Sep 10, 2017
@bluss
Copy link
Member Author

bluss commented Sep 16, 2017

Those that still don't use docs.rs like https://docs.serde.rs/serde/ or other big projects -- I would still like to see the crate version right in their API doc, so if rustdoc or cargo makes this easy to do, we could see it more even in the projects that host their own docs.

@aleksator
Copy link
Contributor

I've noticed that there is already an unstable option in rustdoc to include crate version, added in this PR, with the systax being
rustdoc src/main.rs -Z unstable-options --crate-version 0.0.1

I added a corresponding unstable option to cargo.

Thanks @ehuss for providing some guidance over Discord's #cargo channel.

This is my first issue in cargo project, so feedback would be very appreciated!

bors added a commit that referenced this issue Feb 21, 2020
Add an option to include crate versions to the generated docs

Fixes #1681
@bors bors closed this as completed in 1ea41ba Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-doc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants