Skip to content

Commit

Permalink
feat(markdown docs): add aliases to options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
willemneal authored and gitbutler-client committed Dec 2, 2024
1 parent 68a8b46 commit b804476
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -e
echo '+cargo fmt --check'
cargo fmt --check || (cargo fmt && exit 1)

echo '+cargo run --bin doc-gen --features clap-markdown'
cargo run --bin doc-gen --features clap-markdown
echo '+cargo md-gen'
cargo md-gen
4 changes: 2 additions & 2 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ echo '+cargo test --all'
cargo build
cargo test --all || (echo "might need to rebuild make build-snapshot" && exit 1)

echo '+cargo run --bin doc-gen --features clap-markdown'
cargo run --bin doc-gen --features clap-markdown
echo '+cargo md-gen'
cargo md-gen
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[alias] # command aliases
f = "fmt"
md-gen = "run --bin doc-gen --features clap-markdown"
md-gen = "test --package soroban-cli --lib -- test::md_gen --exact --ignored"
s = "run --quiet --"
# b = "build"
# c = "check"
Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

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

36 changes: 18 additions & 18 deletions FULL_HELP_DOCS.md

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ path = "src/bin/soroban.rs"
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ version }-{ target }{ archive-suffix }"
bin-dir = "{ bin }{ binary-ext }"

[[bin]]
name = "doc-gen"
path = "src/bin/doc-gen.rs"
required-features = ["clap-markdown"]

[lib]
name = "soroban_cli"
path = "src/lib.rs"
Expand Down Expand Up @@ -91,7 +86,6 @@ itertools = "0.10.5"
shlex = "1.1.0"
sep5 = { workspace = true }
ethnum = { workspace = true }
clap-markdown = { version = "0.1.4", optional = true }
which = { workspace = true, features = ["regex"] }
strsim = "0.11.1"
heck = "0.5.0"
Expand Down Expand Up @@ -137,3 +131,4 @@ assert_fs = "1.0.7"
predicates = { workspace = true }
walkdir = "2.5.0"
mockito = "1.5.0"
clap-markdown = {version = "0.1.4", git = "https://github.com/ahalabs/clap-markdown", branch = "feat/visible_aliases"}
37 changes: 37 additions & 0 deletions cmd/soroban-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,40 @@ where
pub trait Pwd {
fn set_pwd(&mut self, pwd: &Path);
}

#[cfg(test)]
mod test {
use std::path::{Path, PathBuf};



#[test]
#[ignore]
fn md_gen() {
doc_gen().unwrap();
}

fn doc_gen() -> std::io::Result<()> {
let out_dir = project_root();
let options = clap_markdown::MarkdownOptions::new()
.show_footer(false)
.show_table_of_contents(false)
.title("Stellar CLI Manual".to_string());

let content = clap_markdown::help_markdown_custom::<super::Root>(&options);

std::fs::write(out_dir.join("FULL_HELP_DOCS.md"), content)?;

Ok(())
}

fn project_root() -> PathBuf {
Path::new(&env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(2)
.unwrap()
.to_path_buf()
}


}

0 comments on commit b804476

Please sign in to comment.