mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added cargo cmd-doc-gen to auto-generate the table of commands in the new players/commands.md page in the book
This commit is contained in:
parent
ef21c433dc
commit
c00bca7e93
@ -4,6 +4,7 @@ rustflags = [
|
||||
]
|
||||
|
||||
[alias]
|
||||
cmd-doc-gen = "run --features=bin_cmd_doc_gen --bin cmd_doc_gen"
|
||||
csv-export = "run --manifest-path common/Cargo.toml --features=bin_csv --bin csv_export"
|
||||
csv-import = "run --manifest-path common/Cargo.toml --features=bin_csv --bin csv_import"
|
||||
test-server = "run --bin veloren-server-cli --no-default-features"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
|
||||
time cargo clippy --all-targets --locked --features="bin_compression,bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings &&
|
||||
time cargo clippy --all-targets --locked --features="bin_cmd_doc_gen,bin_compression,bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings &&
|
||||
# Ensure that the veloren-voxygen default-publish feature builds as it excludes some default features
|
||||
time cargo clippy -p veloren-voxygen --locked --no-default-features --features="default-publish" -- -D warnings &&
|
||||
time cargo fmt --all -- --check
|
@ -10,6 +10,7 @@ hot-reloading = ["common-assets/hot-reloading"]
|
||||
simd = ["vek/platform_intrinsics"]
|
||||
bin_csv = ["ron", "csv", "structopt"]
|
||||
bin_graphviz = ["petgraph"]
|
||||
bin_cmd_doc_gen = []
|
||||
|
||||
default = ["simd"]
|
||||
|
||||
@ -98,3 +99,7 @@ required-features = ["bin_csv"]
|
||||
[[bin]]
|
||||
name = "recipe_graphviz"
|
||||
required-features = ["bin_graphviz"]
|
||||
|
||||
[[bin]]
|
||||
name = "cmd_doc_gen"
|
||||
required-features = ["bin_cmd_doc_gen"]
|
31
common/src/bin/cmd_doc_gen.rs
Normal file
31
common/src/bin/cmd_doc_gen.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use veloren_common::cmd::ChatCommand;
|
||||
|
||||
/// This binary generates the markdown table used for the `players/commands.md`
|
||||
/// page in the Veloren Book. It can be run with `cargo cmd-doc-gen`.
|
||||
fn main() {
|
||||
println!("|Command|Description|Requires|Arguments|");
|
||||
println!("|-|-|-|-|");
|
||||
for cmd in ChatCommand::iter() {
|
||||
let args = cmd
|
||||
.data()
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| arg.usage_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(" ");
|
||||
|
||||
println!(
|
||||
"|/{}|{}|{}|{}|",
|
||||
cmd.keyword(),
|
||||
cmd.data().description,
|
||||
cmd.data()
|
||||
.needs_role
|
||||
.map_or("".to_string(), |role| format!("{:?}", role)),
|
||||
if !args.is_empty() {
|
||||
format!("`{}`", args)
|
||||
} else {
|
||||
"".to_owned()
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user