Questions tagged [rustdoc]

rustdoc is the documentation generator for the Rust programming language.

75 questions
3
votes
0 answers

How to document Cargo features?

I'm using Cargo features for conditional compilation of some things in a library. As I'm documenting the library, I noticed that the Cargo features appear nowhere in the generated documentation. When I generated the docs with cargo doc…
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
3
votes
0 answers

How to protect nightly feature 'extended_key_value_attributes' behind a crate feature?

I run code using stable and document it using nightly, mostly because of the automatic links. I tried to include a long inner documentation by #![doc = include_str!("doc.md")] in the code, but only use it if using nightly, as it is unstable. The…
Shadok
  • 144
  • 5
3
votes
2 answers

Is there a way to enable a Cargo feature only when rustdoc verifies examples?

I have the following piece in the crate documentation: //! # Examples //! ```rust,no_run //! extern crate stm32f103xx; //! // ... //! ``` The problem is that the dependency on stm32f103xx crate is optional. Everything works fine if I enable feature…
Ivan Dubrov
  • 4,778
  • 2
  • 29
  • 41
3
votes
1 answer

How to document macros from a Rust compiler plugin?

I notice that compiler plugins frequently provide macros that the documentation wont even mention. They're registered and created programmatically rather than being defined in a syntax rustdoc recognizes. Naturally, no documentation can be…
mako
  • 1,201
  • 14
  • 30
3
votes
1 answer

Documentation as tests in Ruby?

There is a great tool rustdoc (currently used by cargo) to test examples of documentation comments in Rust. Does rdoc or yard give us something similar in Ruby?
Vitalii Elenhaupt
  • 7,146
  • 3
  • 27
  • 43
2
votes
1 answer

How to hide Statics and Functions generated by the lazy_static crate from cargo doc?

I was documenting a module for a rust project that contains 2 lazy_static macro invocations and when evaluating the documentation generated by cargo doc I saw that there was a bunch of Structs, Statics and Functions with a lock beside them that are…
2
votes
1 answer

Rustdoc bring module into scope?

I am writing a documentation for crate and I noticed I am having lot's references like this: /// A struct [`MyStruct`][`modA::subB::subC::MyStruct`] is very beautiful. Is there a way to bring module subC into scope within the doc comment? It would…
Samuel Hapak
  • 6,950
  • 3
  • 35
  • 58
2
votes
1 answer

How to make rustdoc link to private item from submodule?

I am documenting my binary project that is split to multiple submodules. I have two files in src/: // src/main.rs //! # My Lovely Crate //! //! I can reference [`sub::Public`]. //! But, can't reference [`sub::Private`]. mod sub; and //…
Samuel Hapak
  • 6,950
  • 3
  • 35
  • 58
2
votes
1 answer

Avoid duplicating use statements at beginning of doctests

When writing doctests for methods on a struct or trait or functions in a file, etc. I often find myself putting the same use my_crate::{MyStruct, MyTrait, Etc} at the beginning of each doctest. Is there any way to avoid this duplication, like some…
Thayne
  • 6,619
  • 2
  • 42
  • 67
2
votes
0 answers

How to document feature-gated derived traits?

I understand that I can use the cfg_attr attribute to conditionally derive Trait implementations for types. For example, A struct MyStruct which always implements Clone, Copy, and Debug, but which implements PartialEq if and only if the my-feature…
RBF06
  • 2,013
  • 2
  • 21
  • 20
2
votes
0 answers

How can I define global links in Rust documentation?

It seems that if you define a link in an item's doc comment, it is evidently only defined for that particular item. As an example: /// This is some example [documentation] /// /// [documentation]: https://www.rust-lang.org/learn If I try to use…
kyp4
  • 133
  • 5
2
votes
1 answer

Interactive dependency map on rustdoc?

When I make projects with C++, I often use doxygen to generate the documentations, doxygen has a neat feature that generates interactive dependency graphs (like call dependencies, inheritance dependencies etc...) This tool, embedded in the html…
Makogan
  • 8,208
  • 7
  • 44
  • 112
2
votes
1 answer

rustdoc link to enum variant

In rust, I want rustdoc text to link to an enum variant. What is the syntax for that? Example Given rust code residing at project file src/common.rs, (this rustdoc code failed to link) /// your result! #[derive(Clone, Copy, Debug, PartialEq)] pub…
JamesThomasMoon
  • 6,169
  • 7
  • 37
  • 63
2
votes
2 answers

Is there a way to embed sequence diagrams in rustdoc?

As they say, one picture is worth 1000 words. I'd like to embed several sequence diagrams in my generated rust documentation. Is there a way to do this? Having an embedded image doesn't really work, it is harder to maintain, it is an asset outside…
Bruce
  • 503
  • 3
  • 13
2
votes
1 answer

Why does Vec::iter_mut not show up in the documentation index of std::vec::Vec?

In https://doc.rust-lang.org/std/vec/struct.Vec.html#method.iter, I can only find iter in the index sidebar to the left of the page. However, iter_mut could not be found. Could anyone explain if it's intentional, or a bug? This is inconvenient…
Helin Wang
  • 4,002
  • 1
  • 30
  • 34