Skip to content

Commit 8508cce

Browse files
Group CLI options into sections in help docs (#2272)
### What Move the doc-gen binary code into its own crate, separate from the soroban-cli crate, and have it be dependent on the unmerged pull request to clap-markdown that adds support for grouping cli options: - ConnorGray/clap-markdown#48 ### Why The grouped options experience is a massive improvement. It makes the help documentation easier to scan and understand. It's the way the options are organised on the command line and the help markdown documentation should follow suite. While the pull request adds the feature upstream, the pull request hasn't been accepted yet. The clap-markdown dependency isn't needed for the stellar-cli other than doc-gen, so it is in any case good to get the dependency outside of the soroban-cli crate, so that it isn't downloaded by cargo everytime someone installs the stellar-cli. Moving doc-gen into its own crate is trivial because the soroban-cli is designed to be embedded, and achieves that. Additionally because the doc-gen crate does not need to be published it can reference the unreleased pull request without issue.
1 parent 5b13f4c commit 8508cce

10 files changed

Lines changed: 1184 additions & 660 deletions

File tree

.github/workflows/dependency-check.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

Cargo.lock

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"cmd/stellar-cli",
55
"cmd/soroban-cli",
6+
"cmd/doc-gen",
67
"cmd/crates/*",
78
"cmd/crates/soroban-test/tests/fixtures/test-wasms/*",
89
"cmd/crates/soroban-test/tests/fixtures/hello",

FULL_HELP_DOCS.md

Lines changed: 1131 additions & 629 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ build-test-wasms:
4444
build-test: build-test-wasms install
4545

4646
docs:
47-
cargo run --bin doc-gen
47+
cargo run --package doc-gen
4848
./node_modules/.bin/prettier --write --log-level warn FULL_HELP_DOCS.md
4949

5050
test: build-test

cmd/doc-gen/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "doc-gen"
3+
description = "Stellar CLI generator of markdown help documentation"
4+
homepage = "https://github.com/stellar/stellar-cli"
5+
repository = "https://github.com/stellar/stellar-cli"
6+
authors = ["Stellar Development Foundation <info@stellar.org>"]
7+
license = "Apache-2.0"
8+
readme = "README.md"
9+
version.workspace = true
10+
edition = "2021"
11+
rust-version.workspace = true
12+
publish = false
13+
14+
[dependencies]
15+
soroban-cli = { workspace = true }
16+
# clap-markdown from https://github.com/ConnorGray/clap-markdown/pull/48
17+
clap-markdown = { version = "0.1.5", git = "https://github.com/ConnorGray/clap-markdown", rev = "42956b342cef3325d9060fc43995d595e7c8aa66" }

cmd/doc-gen/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Stellar CLI Documentation Generator
2+
3+
A generator for the help documentation using clap-markdown.
4+
5+
## Usage
6+
7+
Run the following command from the workspace root.
8+
9+
```
10+
cargo run --package doc-gen
11+
```
12+
13+
The command will update the file `FULL_HELP_DOCS.md` located in the root of the workspace.
14+
15+
Typically this command is not run directly, but in the root `Makefile` the `docs` target will run this command in conjunction with formatting the markdown.
16+
17+
So typically run this command via make:
18+
19+
```
20+
make docs
21+
```

cmd/soroban-cli/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ path = "src/bin/soroban.rs"
2424
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ version }-{ target }{ archive-suffix }"
2525
bin-dir = "{ bin }{ binary-ext }"
2626

27-
[[bin]]
28-
name = "doc-gen"
29-
path = "src/bin/doc-gen.rs"
30-
3127
[lib]
3228
name = "soroban_cli"
3329
path = "src/lib.rs"
@@ -133,7 +129,6 @@ whoami = "1.5.2"
133129
serde_with = "3.11.0"
134130
rustc_version = "0.4.1"
135131
prettytable = "0.10.0"
136-
clap-markdown = "0.1.5"
137132

138133
[build-dependencies]
139134
crate-git-revision = "0.0.6"

deny.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ unknown-git = "deny"
258258
# if not specified. If it is specified but empty, no registries are allowed.
259259
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
260260
# List of URLs for allowed Git repositories
261-
allow-git = []
261+
allow-git = [
262+
# Only used by the unpublished doc-gen crate, temporarily until PR is merged: https://github.com/ConnorGray/clap-markdown/pull/48
263+
"https://github.com/ConnorGray/clap-markdown?rev=42956b342cef3325d9060fc43995d595e7c8aa66",
264+
]
262265

263266
[sources.allow-org]
264267
# 1 or more github.com organizations to allow git sources for

0 commit comments

Comments
 (0)