Questions tagged [rustdoc]

rustdoc is the documentation generator for the Rust programming language.

75 questions
2
votes
2 answers

Rust discovery, config file not working as expected

I am trying to avoid entering the same commands in each GDB sessions. For this, I have followed the instructions in rust discovery book but the program is not working as mentioned in the book when I run the program through cargo run it is giving the…
Jawwad Turabi
  • 322
  • 4
  • 12
2
votes
1 answer

How to use a module with the `test` attribute within doc tests?

I have a module which I would like to use within a code block in my documentation. This module is only used for tests, so it has the #![cfg(test)] attribute which it should keep. However, as a result, this file does not seem to be included when…
Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
2
votes
2 answers

Can I externalize parts of a Rust documentation test to an external file?

When writing Rust documentation tests, is it possible to externalize parts of the code to an external file to keep the example short?
1
vote
0 answers

How to make cargo doc warn about missing documentation for public functions in module in a binary crate?

When I add #![warn(missing_docs)] to my main.rs the only warning that it gives me is that the that there is no documentation for the crate (as it should), but I would like that the modules in my project also warn me that there is missing…
1
vote
1 answer

Idiomatic way to repeat a paragraph in rustdoc

I am finally taking some time to properly document my first Rust library and I would like to keep my doc as idiomatic as possible. In my library, there are two classes (I will call them Alpha and Beta for simplicity) that represent the same data in…
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
1
vote
1 answer

Rustdoc Doesn't Recognize Imported Dependencies

I just created a new Rust project and introduced one dependency in main.rs. When I try to run rustdoc src/main.rs, I get the following error: error[E0433]: failed to resolve: maybe a missing crate `rand`? --> src/main.rs:4:5 Even though Cargo.toml…
zarnoevic
  • 329
  • 3
  • 12
1
vote
1 answer

How to try doctesting in play.rust-lang.org? Rust Doctest example doesn't work

The doctest example off Rust-lang's rust-by-example page doesn't work, ironically hehe. How do I use doctesting? I successfully learned how to do unit testing in Rust, the chapter before…
SwimBikeRun
  • 4,192
  • 11
  • 49
  • 85
1
vote
1 answer

Target binary file level generated documentation in Rust project

I have a Rust project consisting of two binary sources sharing the same library: Cargo.toml: <...> [[bin]] name = "quoter_xml" path = "src/quoter_xml.rs" [[bin]] name = "quoter" path = "src/quoter.rs" <...> src/quoter_xml.rs: use <...> fn…
Ivan Olshansky
  • 889
  • 2
  • 17
  • 23
1
vote
0 answers

How to make infra-doc link to crate without adding crate to dependencies

Rust allows to make links in documentation in the form /// link to structure [Foo](foo::Foo) in crate foo To make this work the linked crate should be in dependencies section in Cargo.toml: [dependencies] foo = "1.0" What to do if I want to make…
Michael Ilyin
  • 717
  • 8
  • 15
1
vote
1 answer

How can I make the 'rustdoc::broken_intra_doc_links' lint an error from the command line

Rustdoc has a lint called rustdoc::broken_intra_doc_links for checking doc status. I would like to make this lint into an error via command line flags. Most rust lints can be configured via -D flags but I can't figure out how to do it for rustdoc,…
Derek Thurn
  • 14,953
  • 9
  • 42
  • 64
1
vote
0 answers

Compile all rustdoc comments in project folder into single markdown file

Let's say I have the following directory structure in a VSCode project: - MY_EXAMPLES - Example_1 - src - main.rs - Cargo.lock - Cargo.toml - Example_2 - src - main.rs - Cargo.lock - Cargo.toml Now I want to compile the…
ANimator120
  • 2,556
  • 1
  • 20
  • 52
1
vote
0 answers

What is the standard for showing tooltip warnings in rustdocs?

In decl_storage!, it appears that the syntax used for tooltip warnings appears to be /!\ (i.e. /!\ Be careful ...). If it's a tooltip warning it may be preferable to show it in bold or italic text by using HTML syntax (i.e. using HTML such as…
Luke Schoen
  • 4,129
  • 2
  • 27
  • 25
1
vote
1 answer

How to generate rustdoc documentation for the [build-dependencies] in Cargo.toml?

I am working on a small project that uses a build.rs file intensively. It seems that cargo doc --all generates the documentation for the [dependencies] but not for the [build-dependencies] in Cargo.toml. How can I generate the offline documentation…
1
vote
1 answer

How do I add examples to macro documentation in rust?

When writing a macro, I would like to document it proprerly, and this includes examples. But when I try to do that in the same way as a regular function I get: [E0468]: an `extern crate` loading macros must be at the crate root I run cargo test on…
techhazard
  • 13
  • 2
1
vote
0 answers

Obtaining rustdoc for particular function or trait

Is it possible to obtain a rustdoc fragment for particular function or trait from a programming library written in Rust like it's done in Javadoc tooling? Is there some tool for this?
macropas
  • 3,100
  • 3
  • 22
  • 25