Documenting Rust -- not understanding
⚓ Rust 📅 2025-09-10 👤 surdeus 👁️ 8Well, I thought I understood how to document my code, but apparently not. A friend who is collaborating with me on my Question Bank Creator project sent me some documented code as a suggestion for some changes that would help the project. It looks good on the surface, but I thought it would be easier to read if I ran it through cargo doc –open. So, I did that and didn’t get anything even close to the documentation behind my friend’s ///'s. Consider this snippet:
```
/// This is a test of documentation with cargo doc
///
/// You do know the rhyme, don't you?
/// This little piggy went to market,
/// this little piggy stayed home,
/// this little piggy had roast beef,
/// this little piggy had none,
/// and this little piggy went wee, wee, wee,
/// all the way home.
///
struct Piggy {
toes: u32,
eyes: u32,
name: String,
}
/// The function below is fake
///
pub fn fake_function() {
println!("This little piggy went to market");
}
```
When I run cargo doc –open I don’t get any documentation and in the left panel is a list of seemingly every Rust crate in existence. (BTW there are zero dependencies in the Cargo.toml file for this folder.) So my question is First, why isn’t the documentation showing up and, Second, how do I fix it?
Thanks. :>)
3 posts - 2 participants
🏷️ Rust_feed