mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'coffee-compiler/update_cmd_doc_gen' into 'master'
Update cmd_doc_gen to print client command table as well See merge request veloren/veloren!4553
This commit is contained in:
commit
68b74000f7
@ -11,7 +11,6 @@ simd = ["vek/platform_intrinsics"]
|
||||
bin_csv = ["ron", "csv", "clap"]
|
||||
bin_graphviz = ["petgraph", "clap"]
|
||||
bin_recipe_gen = ["ron"]
|
||||
bin_cmd_doc_gen = []
|
||||
bin_asset_migrate = ["ron"]
|
||||
rrt_pathfinding = ["kiddo"]
|
||||
calendar_events = []
|
||||
@ -118,7 +117,3 @@ required-features = ["bin_graphviz"]
|
||||
[[bin]]
|
||||
name = "skill_graphviz"
|
||||
required-features = ["bin_graphviz"]
|
||||
|
||||
[[bin]]
|
||||
name = "cmd_doc_gen"
|
||||
required-features = ["bin_cmd_doc_gen"]
|
||||
|
@ -1,31 +0,0 @@
|
||||
use veloren_common::cmd::ServerChatCommand;
|
||||
|
||||
/// 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 ServerChatCommand::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()
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@ egui-ui = ["voxygen-egui", "egui", "egui_wgpu_backend", "egui_winit_platform"]
|
||||
shaderc-from-source = ["shaderc/build-from-source"]
|
||||
discord = ["discord-sdk"]
|
||||
bin_img_export = ["common-assets"]
|
||||
bin_cmd_doc_gen = []
|
||||
|
||||
# We don't ship egui with published release builds so a separate feature is required that excludes it.
|
||||
default-publish = [
|
||||
@ -174,3 +175,7 @@ name = "meshing_benchmark"
|
||||
[[bin]]
|
||||
name = "img_export"
|
||||
required-features = ["bin_img_export"]
|
||||
|
||||
[[bin]]
|
||||
name = "cmd_doc_gen"
|
||||
required-features = ["bin_cmd_doc_gen"]
|
47
voxygen/src/bin/cmd_doc_gen.rs
Normal file
47
voxygen/src/bin/cmd_doc_gen.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use common::cmd::{ChatCommandData, ServerChatCommand};
|
||||
use veloren_voxygen::cmd::ClientChatCommand;
|
||||
|
||||
/// This binary generates the markdown tables used for the `players/commands.md`
|
||||
/// page in the Veloren Book. It can be run with `cargo cmd-doc-gen`.
|
||||
fn main() {
|
||||
let table_header = "|Command|Description|Requires|Arguments|";
|
||||
let table_seperator = "|-|-|-|-|";
|
||||
|
||||
println!("{table_header}");
|
||||
println!("{table_seperator}");
|
||||
|
||||
for cmd in ServerChatCommand::iter() {
|
||||
println!("{}", format_row(cmd.keyword(), &cmd.data()))
|
||||
}
|
||||
|
||||
println!();
|
||||
|
||||
println!("{table_header}");
|
||||
println!("{table_seperator}");
|
||||
|
||||
for cmd in ClientChatCommand::iter() {
|
||||
println!("{}", format_row(cmd.keyword(), &cmd.data()))
|
||||
}
|
||||
}
|
||||
|
||||
fn format_row(keyword: &str, data: &ChatCommandData) -> String {
|
||||
let args = data
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| arg.usage_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(" ");
|
||||
|
||||
format!(
|
||||
"|/{}|{}|{}|{}|",
|
||||
keyword,
|
||||
data.description,
|
||||
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