Compile all rustdoc comments in project folder into single markdown file

302 views Asked by At

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 comments from all main.rs files. In this case, that'd be MY_EXAMPLES/Example_1/src/main.rs and MY_EXAMPLES/Example_2/src/main.rs. Note that I would like this solution to scale, so I could automatically compile the comments if I had 10 or 20 Example_X folders.

MY_EXAMPLES/Example_1/src/main.rs

/// My notes on Example 1 that I'd like to add to my README.md
fn main(){
//..
}

MY_EXAMPLES/Example_2/src/main.rs

/// My notes on Example 2 that I'd like to add to my README.md
fn main(){
//..
}

Running:

C:\Users\Primary User\Desktop\MY_EXAMPLES> cargo doc

should create a README.md file that looks like:


Example_1

My notes on Example 1 that I'd like to add to my README.md

Example_2

My notes on Example 2 that I'd like to add to my README.md


So our general template for the README.md content is something like:

### Project Rootdir
rustdoc comments

Does rustdoc have any kind of templating system, similar to that of JSDoc, etc? I've also seen this similar question, which is currently without an answer.

0

There are 0 answers