Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): codegen reference docs for nargo CLI #4149

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(())
}
Loading