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

feat(markdown docs): add aliases to options and subcommands #1771

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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/add_visible_aliases" }
33 changes: 33 additions & 0 deletions cmd/soroban-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,36 @@ 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()
}
}
Loading