Skip to content

docs: add Rustdoc comments and CI support for documentation generation - #151

Closed
hyperfinitism wants to merge 2 commits into
virtee:mainfrom
hyperfinitism:docs/rustdoc
Closed

hyperfinitism wants to merge 2 commits into
virtee:mainfrom
hyperfinitism:docs/rustdoc

Conversation

@hyperfinitism

Copy link
Copy Markdown
Contributor

This PR replaces #139.

  • Add comprehensive module-level (//!) and item-level (///) Rustdoc comments across all source files, so cargo doc produces a complete API reference and the crate-level documentation can drive a cargo rdme-generated README.md.
  • Regenerate README.md from src/main.rs's crate-level doc via cargo rdme. The handwritten sections (overview, basic usage, subcommand table, build/install instructions, reporting bugs) now live as the crate-level doc, keeping cargo doc output and the rendered README in sync.
  • Add a Rustdoc CI workflow (.github/workflows/docs.yml) that runs on push and pull request:
    • cargo rdme --check: fails if README.md differs from the crate-level doc.
    • cargo doc --no-deps --all-features: fails on broken intra-doc links or other doc-build errors.

Build

# cargo install cargo-rdme
cargo rdme
cargo doc --all-features --no-deps

Note

I have left the Asciidoc files as they were. The changes to the adoc files from the preceding PR are not included in this PR.

@ghost
ghost requested review from DGonzalezVillal and larrydewey April 21, 2026 12:52
@hyperfinitism
hyperfinitism force-pushed the docs/rustdoc branch 3 times, most recently from 8d724ac to 8b3f29e Compare April 21, 2026 13:13
Add module-level documentation (//!) and doc comments (///) to all
source files to support `cargo doc` and prepare for `cargo rdme`
README generation.

Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
@DGonzalezVillal

Copy link
Copy Markdown
Member

@hyperfinitism is the pr still in draft?

@hyperfinitism

Copy link
Copy Markdown
Contributor Author

Yes. As mentioned in #152, I recognized that this method also has some flaws. In that issue, I proposed several possible approaches.

Comment thread src/main.rs
Comment on lines +40 to +161
//! ## [Extended Attestation Workflow](#extended-attestation-flowchart)
//!
//! ![Extended attestation diagram](https://github.com/virtee/snpguest/blob/main/docs/extended.PNG?raw=true)
//!
//! **Step 1.** Request the attestation report by providing the two mandatory
//! parameters - `$ATT_REPORT_PATH` which is the path pointing to where the
//! user wishes to store the attestation report and `$REQUEST_FILE` which is
//! the path pointing to where the request file used to request the attestation
//! report is stored. The optional parameter `-v, --vmpl` specifies the vmpl
//! level for the attestation report and is set to 1 by default. The flag
//! `-r, --random` generates random data to be used as request data for the
//! attestation report. Lastly, the flag `-p, --platform` obtains both the
//! attestation report and the request data from the platform (only available
//! for a Microsoft Azure CVM where Hyper-V guest is enabled).
//!
//! ```bash
//! snpguest report $ATT_REPORT_PATH $REQUEST_FILE [-v, --vmpl] $VMPL [-r, --random] [-p, --platform]
//! ```
//!
//! **Step 2.** Request certificates from the extended memory by providing the
//! two mandatory parameters - `$ENCODING` which specifies whether to use PEM
//! or DER encoding to store the certificates and $CERTS_DIR which specifies
//! the path in the user's directory where the certificates will be saved.
//!
//! ```bash
//! snpguest certificates $ENCODING $CERTS_DIR
//! ```
//!
//! In some environments, only the VCEK/VLEK certificate can be obtained. In
//! this case, you must follow the procedure described in
//! [Regular Attestation Workflow](#regular-attestation-workflow) to obtain an
//! AMD CA certificates.
//!
//! **Step 3.** Verify the certificates obtained from the extended memory by
//! providing `$CERTS_DIR` which specifies the path in the user's directory
//! where the certificates were saved from Step 2.
//!
//! ```bash
//! snpguest verify certs $CERTS_DIR
//! ```
//!
//! **Step 4.** Verify the attestation by providing the two mandatory
//! parameters - `$CERTS_DIR` which specifies the path in the user's directory
//! where the certificates were saved from Step 2 and `$ATT_REPORT_PATH` which
//! is the path pointing to the stored attestation report which the user
//! wishes to verify. The optional parameters `-t, --tcb` is used to verify
//! just the Reported TCB contents of the attestaion report and
//! `-s, --signature` is used to verify just the signature of the attestaion
//! report.
//!
//! ```bash
//! snpguest verify attestation $CERTS_DIR $ATT_REPORT_PATH [-t, --tcb] [-s, --signature]
//! ```
//!
//! ## [Regular Attestation Workflow](#regular-attestation-flowchart)
//!
//! ![Regular attestation diagram](https://github.com/virtee/snpguest/blob/main/docs/regular.PNG?raw=true)
//!
//! **Step 1.** Request the attestation report by providing the two mandatory
//! parameters - `$ATT_REPORT_PATH` which is the path pointing to where the
//! user wishes to store the attestation report and `$REQUEST_FILE` which is
//! the path pointing to where the request file used to request the attestation
//! report is stored. The optional parameter `-v, --vmpl` specifies the vmpl
//! level for the attestation report and is set to 1 by default. The flag
//! `-r, --random` generates random data to be used as request data for the
//! attestation report. Lastly, the flag `-p, --platform` obtains both the
//! attestation report and the request data from the platform (only available
//! for a Microsoft Azure CVM where Hyper-V guest is enabled).
//!
//! ```bash
//! snpguest report $ATT_REPORT_PATH $REQUEST_FILE [-v, --vmpl] $VMPL [-r, --random] [-p, --platform]
//! ```
//!
//! **Step 2.** Request AMD Root Key (ARK) and AMD SEV Key (ASK) (or AMD
//! SEV-VLEK Key (ASVK) for VLEK) from the AMD Key Distribution Service (KDS)
//! by providing the three mandatory parameters - `$ENCODING` which specifies
//! whether to use PEM or DER encoding to store the certificates, `$CERTS_DIR`
//! which specifies the path in the user's directory where the certificates
//! will be saved, and `$PROCESSOR_MODEL` - which specifies the AMD Processor
//! model for which the certificates are to be fetched. The optional
//! `-e, --endorser` argument specifies the type of attestation signing key
//! (defaults to VCEK).
//!
//! ```bash
//! snpguest fetch ca $ENCODING $CERTS_DIR $PROCESSOR_MODEL [-e, --endorser] $ENDORSER
//! ```
//!
//! **Step 3.** Request the Versioned Chip Endorsement Key (VCEK) from the AMD
//! Key Distribution Service (KDS) by providing the three mandatory
//! parameters - `$ENCODING` which specifies whether to use PEM or DER
//! encoding to store the certificates, `$CERTS_DIR` which specifies the path
//! in the user's directory where the certificates will be saved, and
//! `$ATT_REPORT_PATH` which is the path pointing to the stored attestation
//! report for detecting Chip ID and Reported TCB Version. The optional
//! `-p, --processor-model` argument specifies the AMD Processor model for
//! which the certificates are to be fetched.
//!
//! ```bash
//! snpguest fetch vcek $ENCODING $CERTS_DIR $ATT_REPORT_PATH [-p, --processor-model] $PROCESSOR_MODEL
//! ```
//!
//! **Step 4.** Verify the certificates obtained by providing `$CERTS_DIR`
//! which specifies the path in the user's directory where the certificates
//! were saved from Step 2.
//!
//! ```bash
//! snpguest verify certs $CERTS_DIR
//! ```
//!
//! **Step 5.** Verify the attestation by providing the two mandatory
//! parameters - `$CERTS_DIR` which specifies the path in the user's directory
//! where the certificates were saved from Step 2 and `$ATT_REPORT_PATH` which
//! is the path pointing to the stored attestation report which the user
//! wishes to verify. The optional parameters `-t, --tcb` is used to verify
//! just the Reported TCB contents of the attestaion report and
//! `-s, --signature` is used to verify just the signature of the attestaion
//! report.
//!
//! ```bash
//! snpguest verify attestation $CERTS_DIR $ATT_REPORT_PATH [-t, --tcb] [-s, --signature]
//! ```
//!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these workflow guides can be a separate document in the docs as you suggested in the issue.

@DGonzalezVillal

Copy link
Copy Markdown
Member

Hey @hyperfinitism I have a quick question related to this approach. So in you suggestion, we will no longer have a documentation similar to that of the .adoc that shows how the cli commands are supposed to be used? Or when you run cargo doc then that guide would be generated for you?

I'm thinking maybe I would like a document similar to the adoc as reference for users, but I maybe I'm confused as to what would replace it here on this pr. Or it's not being replaced?

@hyperfinitism

Copy link
Copy Markdown
Contributor Author

With this approach, the adoc file will be replaced by Rustdoc pages corresponding to each module (which describe how to use the CLI). However, as I mentioned in the issue cited above, I currently do not consider this approach to be a clean solution.

@DGonzalezVillal

Copy link
Copy Markdown
Member

So this is the equivalent to option B in your issue?

@tylerfanelli

Copy link
Copy Markdown
Member

I'm really not a huge fan of polluting the source code with documentation. I think these should be separate.

@hyperfinitism

Copy link
Copy Markdown
Contributor Author

@DGonzalezVillal
Yes, this PR follows Option B.

@tylerfanelli
Agree. I now believe that Option C is a better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants