skip to Main Content

I have just finished a final project for my Rust class. The project works and runs pretty well. One of the requirements for this project was to include documentation using the /// doc comment that Rust uses. I have coded this entire project through Visual Studio Code 2.

I have made a view documentation comments using that format, but when I save the code and commit it to my GitHub, I cannot find any files on my GitHub that references what I have typed in my main Rust file.

/// The "CarryOn()" function is used for determining if the user wants to add more words to the glossary.
/// The user can input 1 to continue, or any other number to quit.
fn CarryOn()->i8{
    println!("Do you want to continue ending words to the glossary?");
    println!("Press 1 for yes, enter any other number for no.");
    let mut s1 = String::new();
    io::stdin().read_line(&mut s1).expect("Failed");
    let n1:i8 = s1.trim().parse().expect("Not a valid Number");
    return n1;
}

There’s an example of the some of the documentation from my code. Where/how would I find the file, local or on my GitHub, that would show this documentation?

I am new with Rust, and after endlessly searching through YouTube, Google, and my class and teacher’s notes, I could not find anything descriptive that would help me…

2

Answers


  1. You don’t need to push to github to view docs (you can, but it takes some extra setup. It’s easier to read them locally).

    To generate and view documentation from your project, open up a terminal and set your current working directory to the project folder. Next run cargo doc --open. After a short while, your web browser should open up pointing to the documentation for your project.

    If on the documentation page you don’t see the doc comments you are looking for try entering your function name into the search bar.

    If that still doesn’t work try running cargo doc --open --document-private-items instead.

    Login or Signup to reply.
  2. If you need your documentation to be hosted online, not just available on your local machine, then you can create a GitHub Pages repository. You can then run cargo doc on your code to generate the ./target/doc directory and copy the contents of that into your GitHub pages repository.

    That’s what I’ve done here: hosted documentation, pages repository, original code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search