Skip to content

Commit

Permalink
chore(docs): codegen reference docs for nargo CLI (#4149)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4136 
Resolves AztecProtocol/dev-rel#128
## Summary\*

This PR codegens the reference material for the nargo CLI to avoid us
having to copy documentation from the code over to a markdown file.

The exact format of the codegenned markdown isn't final and we can
iterate on this but it guarantees completeness.

## Additional Context


## Documentation\*

Check one:
- [ ] No documentation needed.
- [x] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench authored Feb 8, 2024
1 parent 682b159 commit 0e07303
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 255 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-gnu
save-if: false

- name: Setup toolchain
uses: dtolnay/[email protected]
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ unknown-git = "deny"
#
# crates.io rejects git dependencies so anything depending on these is unpublishable and you'll ruin my day
# when I find out.
allow-git = ["https://github.com/jfecher/chumsky"]
allow-git = [
"https://github.com/jfecher/chumsky",
"https://github.com/noir-lang/clap-markdown",
]
253 changes: 0 additions & 253 deletions docs/docs/reference/nargo_commands.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"preprocess": "yarn node ./scripts/preprocess/index.js",
"preprocess": "./scripts/codegen_nargo_reference.sh && yarn node ./scripts/preprocess/index.js",
"start": "yarn preprocess && docusaurus start",
"build": "yarn preprocess && yarn version::stables && docusaurus build",
"version::stables": "ts-node ./scripts/setStable.ts",
Expand Down
33 changes: 33 additions & 0 deletions docs/scripts/codegen_nargo_reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eu

cd $(dirname "$0")/..

REFERENCE_DIR="./processed-docs/reference"
NARGO_REFERENCE="$REFERENCE_DIR/nargo_commands.md"
rm -f $NARGO_REFERENCE
mkdir -p $REFERENCE_DIR

echo "---
title: Nargo
description:
Noir CLI Commands for Noir Prover and Verifier to create, execute, prove and verify programs,
generate Solidity verifier smart contract and compile into JSON file containing ACIR
representation and ABI of circuit.
keywords:
[
Nargo,
Noir CLI,
Noir Prover,
Noir Verifier,
generate Solidity verifier,
compile JSON file,
ACIR representation,
ABI of circuit,
TypeScript,
]
sidebar_position: 0
---
" > $NARGO_REFERENCE

cargo run -F codegen-docs -- info >> $NARGO_REFERENCE
4 changes: 4 additions & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ termcolor = "1.1.2"
color-eyre = "0.6.2"
tokio = { version = "1.0", features = ["io-std"] }
dap.workspace = true
clap-markdown = { git = "https://github.com/noir-lang/clap-markdown", rev = "450d759532c88f0dba70891ceecdbc9ff8f25d2b", optional = true }

# Backends
backend-interface = { path = "../backend_interface" }
Expand Down Expand Up @@ -83,3 +84,6 @@ harness = false
[[bench]]
name = "iai"
harness = false

[features]
codegen-docs = ["dep:clap-markdown"]
10 changes: 10 additions & 0 deletions tooling/nargo_cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ enum NargoCommand {
}

pub(crate) fn start_cli() -> eyre::Result<()> {
#[cfg(feature = "codegen-docs")]
return codegen_docs();

let NargoCli { command, mut config } = NargoCli::parse();

// If the provided `program_dir` is relative, make it absolute by joining it to the current directory.
Expand Down Expand Up @@ -126,3 +129,10 @@ pub(crate) fn start_cli() -> eyre::Result<()> {

Ok(())
}

#[cfg(feature = "codegen-docs")]
fn codegen_docs() -> eyre::Result<()> {
let markdown: String = clap_markdown::help_markdown::<NargoCli>();
println!("{markdown}");
Ok(())
}

0 comments on commit 0e07303

Please sign in to comment.