rustdoc is the documentation generator for the Rust programming language.
Questions tagged [rustdoc]
75 questions
6
votes
2 answers
Can't use a dependent crate in Rust documentation tests
I'm trying to write docs for a project I'm writing in Rust. One of the docs requires using regex::Regex. Here's the doc I'm trying to write:
/// Return a list of the offsets of the tokens in `s`, as a sequence of `(start, end)`
/// tuples, by…

erip
- 16,374
- 11
- 66
- 121
6
votes
1 answer
How do I view rustdoc for a library my project depends on?
I'd like to view the rust docs for a library that my program depends on. How can I pull these down? I found a question with the answer for the standard library but I'm looking specifically for crates.io dependencies.

Daenyth
- 35,856
- 13
- 85
- 124
5
votes
1 answer
Cargo doc does not generate documentation for private items in a project that is both a library and binary
When I run cargo doc, it does not seem to generate documentation for the library in my project. I am using the latest version of Rust as answered by this post: How can I include private modules when generating documentation via Cargo?
This is my…

l3utterfly
- 2,106
- 4
- 32
- 58
5
votes
1 answer
How to use a local file as crate logo when generating rustdoc?
It is possible to set both the favicon and the logo of the rustdoc for a crate by using:
#![doc(html_favicon_url = "/favicon.ico")]
#![doc(html_logo_url = "/logo.png")]
as documented here.
However I do not want to upload my logo…

frankenapps
- 5,800
- 6
- 28
- 69
5
votes
3 answers
How is it possible to keep Rust module documentation in separate Markdown files?
This section of the Rust book seems to imply that it is possible to keep Rust documentation in separate .md files, but it does not say how these .md files can then be included back. How does this work?
user8370684
5
votes
1 answer
Is it possible to group sections of an API with rustdoc?
Is it possible to group sections of an API? related functions, types or constants for example.
Doxygen for example supports grouping like this:
/** \name Some API Grouping
* \{ */
// code //
/* \} */
Is rustdoc capable of something similar?

ideasman42
- 42,413
- 44
- 197
- 320
5
votes
1 answer
Indicating which version of a crate generated docs are for
When you generate documentation for a Rust crate with Cargo and rustdoc, I don't see any indication in the generated pages which version of the crate it's for. For example, take a look at the log crate's documentation. Is there a way to know which…

Jimmy
- 35,686
- 13
- 80
- 98
4
votes
1 answer
How to turn off cargo doc test and compile for a specific module in Rust
I have some generated .rs code (from grpc proto files) and they are checked in with my normal Rust code under src but in some sub modules. The issue is that when doing cargo test the doc test will run and some of the generated .rs have comments with…

Fuyang Liu
- 1,496
- 13
- 26
4
votes
1 answer
How to conveniently host a crate's up-to-date documentation?
I recently published my first crate on crates.io and I am wondering if I can maintain its documentation in an easier way.
Quite a few crates' docs are hosted on GitHub pages, so I thought I would give it a shot. I created a user.github.io repo,…

ljedrz
- 20,316
- 4
- 69
- 97
4
votes
2 answers
How to check standard library documentation offline?
I found rustdoc command and I kind of expected it to work like pydoc. Unfortunately, rustdoc std::io:stdin doesn't do what I'd like it to. Is there a way to view standard library documentation in an offline form, either via command line or some kind…

d33tah
- 10,999
- 13
- 68
- 158
4
votes
2 answers
How would one achieve conditional compilation with Rust projects that have doctests?
I've used conditional compilation to change the type signature of a function, and now the same doctest can't be run for both "feature" modes, so I need a way to opt-out of the doctests.
I've tried merging #[cfg_attr(feature = "rss_loose", ignore)]…

Michael Yoo
- 489
- 1
- 6
- 14
3
votes
1 answer
How to force --document-private-items from Cargo.toml?
Is there a way of forcing private items documentation on docs build?
It can be done manually adding the doc flag --document-private-items, but I would like to force it in Cargo.toml level for example.

Netwave
- 40,134
- 6
- 50
- 93
3
votes
1 answer
Is there a way to name a Rust doctest?
Doctests commandeer the language identifier to allow you to add "attributes" that affect the behavior of the test.
However, there doesn't appear to be a way to add a name to a documentation test. Is there a way I can better identify them when…

Jk Jensen
- 339
- 2
- 4
- 16
3
votes
1 answer
Is is possible to generate documentation for one private function?
How can I force rustdoc documentation for one private function?
In my project, there are many private functions. I do not want them to be part of the generated rustdoc output (command cargo doc). It's unnecessary for library users to read about…

JamesThomasMoon
- 6,169
- 7
- 37
- 63
3
votes
1 answer
rustdoc only show the type of a constant, not the actual value
I'm making a library in Rust and I've started writing documentation for it. I notice that on e.g. https://doc.rust-lang.org/std/primitive.u128.html, the values of constants such as u128::BITS are hidden, and only pub const BITS: u32 is displayed.…

isaacholt100
- 388
- 3
- 11