Skip to content

Commit 21b4bf1

Browse files
committed
feat(markdown docs): add aliases to options
Move `cargo md-gen` to an ignored test. This allows moving clap-markdown to dev-dependency allowing the use of a fork and removing an unneeded dependency since the markdown generation is pre-release.
1 parent c940386 commit 21b4bf1

File tree

7 files changed

+58
-31
lines changed

7 files changed

+58
-31
lines changed

.cargo-husky/hooks/pre-commit

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ set -e
55
echo '+cargo fmt --check'
66
cargo fmt --check || (cargo fmt && exit 1)
77

8-
echo '+cargo run --bin doc-gen --features clap-markdown'
9-
cargo run --bin doc-gen --features clap-markdown
8+
echo '+cargo md-gen'
9+
cargo md-gen

.cargo-husky/hooks/pre-push

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ echo '+cargo test --all'
1616
cargo build
1717
cargo test --all || (echo "might need to rebuild make build-snapshot" && exit 1)
1818

19-
echo '+cargo run --bin doc-gen --features clap-markdown'
20-
cargo run --bin doc-gen --features clap-markdown
19+
echo '+cargo md-gen'
20+
cargo md-gen

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[alias] # command aliases
44
f = "fmt"
5-
md-gen = "run --bin doc-gen --features clap-markdown"
5+
md-gen = "test --package soroban-cli --lib -- test::md_gen --exact --ignored"
66
s = "run --quiet --"
77
# b = "build"
88
# c = "check"

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FULL_HELP_DOCS.md

+18-18
Large diffs are not rendered by default.

cmd/soroban-cli/Cargo.toml

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +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-
required-features = ["clap-markdown"]
31-
3227
[lib]
3328
name = "soroban_cli"
3429
path = "src/lib.rs"
@@ -91,7 +86,6 @@ itertools = "0.10.5"
9186
shlex = "1.1.0"
9287
sep5 = { workspace = true }
9388
ethnum = { workspace = true }
94-
clap-markdown = { version = "0.1.4", optional = true }
9589
which = { workspace = true, features = ["regex"] }
9690
strsim = "0.11.1"
9791
heck = "0.5.0"
@@ -137,3 +131,4 @@ assert_fs = "1.0.7"
137131
predicates = { workspace = true }
138132
walkdir = "2.5.0"
139133
mockito = "1.5.0"
134+
clap-markdown = { version = "0.1.4", git = "https://github.com/ahalabs/clap-markdown", branch = "feat/add_visible_aliases" }

cmd/soroban-cli/src/lib.rs

+33
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,36 @@ where
6363
pub trait Pwd {
6464
fn set_pwd(&mut self, pwd: &Path);
6565
}
66+
67+
#[cfg(test)]
68+
mod test {
69+
use std::path::{Path, PathBuf};
70+
71+
#[test]
72+
#[ignore]
73+
fn md_gen() {
74+
doc_gen().unwrap();
75+
}
76+
77+
fn doc_gen() -> std::io::Result<()> {
78+
let out_dir = project_root();
79+
let options = clap_markdown::MarkdownOptions::new()
80+
.show_footer(false)
81+
.show_table_of_contents(false)
82+
.title("Stellar CLI Manual".to_string());
83+
84+
let content = clap_markdown::help_markdown_custom::<super::Root>(&options);
85+
86+
std::fs::write(out_dir.join("FULL_HELP_DOCS.md"), content)?;
87+
88+
Ok(())
89+
}
90+
91+
fn project_root() -> PathBuf {
92+
Path::new(&env!("CARGO_MANIFEST_DIR"))
93+
.ancestors()
94+
.nth(2)
95+
.unwrap()
96+
.to_path_buf()
97+
}
98+
}

0 commit comments

Comments
 (0)