Skip to content

Commit

Permalink
chore(docs): codegen reference docs for nargo CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jan 29, 2024
1 parent 2914310 commit 42b4456
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 254 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.

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
31 changes: 31 additions & 0 deletions docs/scripts/codegen_nargo_reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -eu

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

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

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 42b4456

Please sign in to comment.