From d451b99a4889acc73ab90905a21e1d36481996a0 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 15 Jan 2026 06:18:28 +0100 Subject: [PATCH] Moves to crates and adds spec --- .config/tracey/config.yaml | 12 + .gitignore | 1 + Cargo.toml | 11 +- TODO.md | 5 + {cli_parser => crates/cli_parser}/Cargo.toml | 0 {cli_parser => crates/cli_parser}/src/lib.rs | 0 {config => crates/config}/Cargo.toml | 0 {config => crates/config}/src/graph.rs | 0 {config => crates/config}/src/lib.rs | 0 {config => crates/config}/src/make.rs | 0 {config => crates/config}/src/statsolver.rs | 0 {config => crates/config}/src/tablegen.rs | 0 crates/fast_class/Cargo.toml | 6 + crates/fast_class/src/lib.rs | 15 ++ {graphs => crates/graphs}/Cargo.toml | 0 {graphs => crates/graphs}/src/graphs.rs | 2 +- {graphs => crates/graphs}/src/lib.rs | 0 {make => crates/make}/Cargo.toml | 0 {make => crates/make}/src/lib.rs | 0 {make => crates/make}/src/makepdf.rs | 0 .../make}/src/makepdf_functions.rs | 0 {make => crates/make}/src/makepdf_misc.rs | 0 {make => crates/make}/src/makepdf_structs.rs | 8 +- .../ravenous-tools}/Cargo.toml | 0 .../ravenous-tools}/src/main.rs | 2 +- {stats => crates/stats}/Cargo.toml | 0 {stats => crates/stats}/src/lib.rs | 0 {stats => crates/stats}/src/stat_algo.rs | 0 {stats => crates/stats}/src/stat_io.rs | 0 {stats => crates/stats}/src/stat_structs.rs | 0 {stats => crates/stats}/src/stats.rs | 0 {tablegen => crates/tablegen}/Cargo.toml | 0 {tablegen => crates/tablegen}/src/lib.rs | 0 .../tablegen}/src/table_structs.rs | 0 .../tablegen}/src/table_types.rs | 0 {tablegen => crates/tablegen}/src/tablegen.rs | 0 {weaponry => crates/weaponry}/Cargo.toml | 0 {weaponry => crates/weaponry}/src/database.rs | 0 {weaponry => crates/weaponry}/src/export.rs | 0 .../weaponry}/src/interfaces.rs | 0 {weaponry => crates/weaponry}/src/lib.rs | 0 {weaponry => crates/weaponry}/src/strategy.rs | 10 +- .../weaponry}/src/weaponry_structs.rs | 0 {weaponry => crates/weaponry}/workflow.md | 0 requirements/data.md | 225 ++++++++++++++++++ 45 files changed, 276 insertions(+), 21 deletions(-) create mode 100644 .config/tracey/config.yaml create mode 100644 TODO.md rename {cli_parser => crates/cli_parser}/Cargo.toml (100%) rename {cli_parser => crates/cli_parser}/src/lib.rs (100%) rename {config => crates/config}/Cargo.toml (100%) rename {config => crates/config}/src/graph.rs (100%) rename {config => crates/config}/src/lib.rs (100%) rename {config => crates/config}/src/make.rs (100%) rename {config => crates/config}/src/statsolver.rs (100%) rename {config => crates/config}/src/tablegen.rs (100%) create mode 100644 crates/fast_class/Cargo.toml create mode 100644 crates/fast_class/src/lib.rs rename {graphs => crates/graphs}/Cargo.toml (100%) rename {graphs => crates/graphs}/src/graphs.rs (99%) rename {graphs => crates/graphs}/src/lib.rs (100%) rename {make => crates/make}/Cargo.toml (100%) rename {make => crates/make}/src/lib.rs (100%) rename {make => crates/make}/src/makepdf.rs (100%) rename {make => crates/make}/src/makepdf_functions.rs (100%) rename {make => crates/make}/src/makepdf_misc.rs (100%) rename {make => crates/make}/src/makepdf_structs.rs (98%) rename {ravenous-tools => crates/ravenous-tools}/Cargo.toml (100%) rename {ravenous-tools => crates/ravenous-tools}/src/main.rs (96%) rename {stats => crates/stats}/Cargo.toml (100%) rename {stats => crates/stats}/src/lib.rs (100%) rename {stats => crates/stats}/src/stat_algo.rs (100%) rename {stats => crates/stats}/src/stat_io.rs (100%) rename {stats => crates/stats}/src/stat_structs.rs (100%) rename {stats => crates/stats}/src/stats.rs (100%) rename {tablegen => crates/tablegen}/Cargo.toml (100%) rename {tablegen => crates/tablegen}/src/lib.rs (100%) rename {tablegen => crates/tablegen}/src/table_structs.rs (100%) rename {tablegen => crates/tablegen}/src/table_types.rs (100%) rename {tablegen => crates/tablegen}/src/tablegen.rs (100%) rename {weaponry => crates/weaponry}/Cargo.toml (100%) rename {weaponry => crates/weaponry}/src/database.rs (100%) rename {weaponry => crates/weaponry}/src/export.rs (100%) rename {weaponry => crates/weaponry}/src/interfaces.rs (100%) rename {weaponry => crates/weaponry}/src/lib.rs (100%) rename {weaponry => crates/weaponry}/src/strategy.rs (91%) rename {weaponry => crates/weaponry}/src/weaponry_structs.rs (100%) rename {weaponry => crates/weaponry}/workflow.md (100%) create mode 100644 requirements/data.md diff --git a/.config/tracey/config.yaml b/.config/tracey/config.yaml new file mode 100644 index 0000000..caa2c22 --- /dev/null +++ b/.config/tracey/config.yaml @@ -0,0 +1,12 @@ +specs: + - name: base + prefix: r + source_url: "https://github.com/bearcove/tracey" + include: + - "requirements/**/*.md" + impls: + - name: main + include: + - "crates/**/*.rs" + exclude: + - "target/**" diff --git a/.gitignore b/.gitignore index 6126be9..0b8a7fc 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ Cargo.lock /target .cargo/ +.tracey/ diff --git a/Cargo.toml b/Cargo.toml index 46bf157..b7db504 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,10 @@ -# cargo-features = ["edition2024"] - [workspace] -members = [ "cli_parser", "config", "graphs", "make", - "ravenous-tools", "stats", - "tablegen", "weaponry", -] +members = ["crates/*"] resolver = "3" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +# [workspace.package] +# edition = "2024" +# license = "MIT OR Apache-2.0" [profile.dev] debug = 0 diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..1788940 --- /dev/null +++ b/TODO.md @@ -0,0 +1,5 @@ +# TODO +* Remake graphs +* Remake export +* Remake dashboard + diff --git a/cli_parser/Cargo.toml b/crates/cli_parser/Cargo.toml similarity index 100% rename from cli_parser/Cargo.toml rename to crates/cli_parser/Cargo.toml diff --git a/cli_parser/src/lib.rs b/crates/cli_parser/src/lib.rs similarity index 100% rename from cli_parser/src/lib.rs rename to crates/cli_parser/src/lib.rs diff --git a/config/Cargo.toml b/crates/config/Cargo.toml similarity index 100% rename from config/Cargo.toml rename to crates/config/Cargo.toml diff --git a/config/src/graph.rs b/crates/config/src/graph.rs similarity index 100% rename from config/src/graph.rs rename to crates/config/src/graph.rs diff --git a/config/src/lib.rs b/crates/config/src/lib.rs similarity index 100% rename from config/src/lib.rs rename to crates/config/src/lib.rs diff --git a/config/src/make.rs b/crates/config/src/make.rs similarity index 100% rename from config/src/make.rs rename to crates/config/src/make.rs diff --git a/config/src/statsolver.rs b/crates/config/src/statsolver.rs similarity index 100% rename from config/src/statsolver.rs rename to crates/config/src/statsolver.rs diff --git a/config/src/tablegen.rs b/crates/config/src/tablegen.rs similarity index 100% rename from config/src/tablegen.rs rename to crates/config/src/tablegen.rs diff --git a/crates/fast_class/Cargo.toml b/crates/fast_class/Cargo.toml new file mode 100644 index 0000000..3be632b --- /dev/null +++ b/crates/fast_class/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "fast_class" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/crates/fast_class/src/lib.rs b/crates/fast_class/src/lib.rs new file mode 100644 index 0000000..131a32a --- /dev/null +++ b/crates/fast_class/src/lib.rs @@ -0,0 +1,15 @@ +/// r[bulk.export] +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/graphs/Cargo.toml b/crates/graphs/Cargo.toml similarity index 100% rename from graphs/Cargo.toml rename to crates/graphs/Cargo.toml diff --git a/graphs/src/graphs.rs b/crates/graphs/src/graphs.rs similarity index 99% rename from graphs/src/graphs.rs rename to crates/graphs/src/graphs.rs index e59212c..8936f00 100644 --- a/graphs/src/graphs.rs +++ b/crates/graphs/src/graphs.rs @@ -83,7 +83,7 @@ fn del_graphs(args: &GraphConfig) -> Result<()> { /// Generate the graph and save it fn gen_graph(args: &GraphConfig) -> Result<()> { // Import CSV - let data = include_bytes!("../../data/lmroman8-regular.ttf") as &[u8]; + let data = include_bytes!("../../../data/lmroman8-regular.ttf") as &[u8]; get_or_try_init_fonts(Some(vec![data])).unwrap(); let csv = import_csv(args)?; diff --git a/graphs/src/lib.rs b/crates/graphs/src/lib.rs similarity index 100% rename from graphs/src/lib.rs rename to crates/graphs/src/lib.rs diff --git a/make/Cargo.toml b/crates/make/Cargo.toml similarity index 100% rename from make/Cargo.toml rename to crates/make/Cargo.toml diff --git a/make/src/lib.rs b/crates/make/src/lib.rs similarity index 100% rename from make/src/lib.rs rename to crates/make/src/lib.rs diff --git a/make/src/makepdf.rs b/crates/make/src/makepdf.rs similarity index 100% rename from make/src/makepdf.rs rename to crates/make/src/makepdf.rs diff --git a/make/src/makepdf_functions.rs b/crates/make/src/makepdf_functions.rs similarity index 100% rename from make/src/makepdf_functions.rs rename to crates/make/src/makepdf_functions.rs diff --git a/make/src/makepdf_misc.rs b/crates/make/src/makepdf_misc.rs similarity index 100% rename from make/src/makepdf_misc.rs rename to crates/make/src/makepdf_misc.rs diff --git a/make/src/makepdf_structs.rs b/crates/make/src/makepdf_structs.rs similarity index 98% rename from make/src/makepdf_structs.rs rename to crates/make/src/makepdf_structs.rs index 0e1509e..3cb7684 100644 --- a/make/src/makepdf_structs.rs +++ b/crates/make/src/makepdf_structs.rs @@ -330,10 +330,10 @@ impl LineType { /// Tries to split the token and return two string fn split_by(delim: &str, text: &str) -> Option<(String, String)> { let mut slice = text.split(delim); - if let Some(one) = slice.next() { - if let Some(two) = slice.next() { - return Some((one.to_string(), two.trim_start().to_string())); - } + if let Some(one) = slice.next() + && let Some(two) = slice.next() + { + return Some((one.to_string(), two.trim_start().to_string())); } None } diff --git a/ravenous-tools/Cargo.toml b/crates/ravenous-tools/Cargo.toml similarity index 100% rename from ravenous-tools/Cargo.toml rename to crates/ravenous-tools/Cargo.toml diff --git a/ravenous-tools/src/main.rs b/crates/ravenous-tools/src/main.rs similarity index 96% rename from ravenous-tools/src/main.rs rename to crates/ravenous-tools/src/main.rs index 6ec40bf..3520dc7 100644 --- a/ravenous-tools/src/main.rs +++ b/crates/ravenous-tools/src/main.rs @@ -23,7 +23,7 @@ use std::{ fn main() -> Result<()> { let args = ParserCLIArgs::parse(); let config_str = &fs::read_to_string("helper_config.toml") - .unwrap_or(include_str!("../../helper_config.toml").to_string()); + .unwrap_or(include_str!("../../../helper_config.toml").to_string()); let config: Config = toml::from_str(config_str).expect("Coudln't read the config file"); match args.command { Commands::Tablegen(args) => table_gen(&args, &config), diff --git a/stats/Cargo.toml b/crates/stats/Cargo.toml similarity index 100% rename from stats/Cargo.toml rename to crates/stats/Cargo.toml diff --git a/stats/src/lib.rs b/crates/stats/src/lib.rs similarity index 100% rename from stats/src/lib.rs rename to crates/stats/src/lib.rs diff --git a/stats/src/stat_algo.rs b/crates/stats/src/stat_algo.rs similarity index 100% rename from stats/src/stat_algo.rs rename to crates/stats/src/stat_algo.rs diff --git a/stats/src/stat_io.rs b/crates/stats/src/stat_io.rs similarity index 100% rename from stats/src/stat_io.rs rename to crates/stats/src/stat_io.rs diff --git a/stats/src/stat_structs.rs b/crates/stats/src/stat_structs.rs similarity index 100% rename from stats/src/stat_structs.rs rename to crates/stats/src/stat_structs.rs diff --git a/stats/src/stats.rs b/crates/stats/src/stats.rs similarity index 100% rename from stats/src/stats.rs rename to crates/stats/src/stats.rs diff --git a/tablegen/Cargo.toml b/crates/tablegen/Cargo.toml similarity index 100% rename from tablegen/Cargo.toml rename to crates/tablegen/Cargo.toml diff --git a/tablegen/src/lib.rs b/crates/tablegen/src/lib.rs similarity index 100% rename from tablegen/src/lib.rs rename to crates/tablegen/src/lib.rs diff --git a/tablegen/src/table_structs.rs b/crates/tablegen/src/table_structs.rs similarity index 100% rename from tablegen/src/table_structs.rs rename to crates/tablegen/src/table_structs.rs diff --git a/tablegen/src/table_types.rs b/crates/tablegen/src/table_types.rs similarity index 100% rename from tablegen/src/table_types.rs rename to crates/tablegen/src/table_types.rs diff --git a/tablegen/src/tablegen.rs b/crates/tablegen/src/tablegen.rs similarity index 100% rename from tablegen/src/tablegen.rs rename to crates/tablegen/src/tablegen.rs diff --git a/weaponry/Cargo.toml b/crates/weaponry/Cargo.toml similarity index 100% rename from weaponry/Cargo.toml rename to crates/weaponry/Cargo.toml diff --git a/weaponry/src/database.rs b/crates/weaponry/src/database.rs similarity index 100% rename from weaponry/src/database.rs rename to crates/weaponry/src/database.rs diff --git a/weaponry/src/export.rs b/crates/weaponry/src/export.rs similarity index 100% rename from weaponry/src/export.rs rename to crates/weaponry/src/export.rs diff --git a/weaponry/src/interfaces.rs b/crates/weaponry/src/interfaces.rs similarity index 100% rename from weaponry/src/interfaces.rs rename to crates/weaponry/src/interfaces.rs diff --git a/weaponry/src/lib.rs b/crates/weaponry/src/lib.rs similarity index 100% rename from weaponry/src/lib.rs rename to crates/weaponry/src/lib.rs diff --git a/weaponry/src/strategy.rs b/crates/weaponry/src/strategy.rs similarity index 91% rename from weaponry/src/strategy.rs rename to crates/weaponry/src/strategy.rs index 15c8c97..f17c922 100644 --- a/weaponry/src/strategy.rs +++ b/crates/weaponry/src/strategy.rs @@ -8,8 +8,6 @@ //! #![allow(dead_code)] -use rayon::iter::ParallelIterator; - /// Generation strategy, how to generate all the data, instead of a full permutation pub enum EquipementStrategy { /// Full permutation, generate all possible outcomes @@ -71,11 +69,7 @@ pub enum EquipementFilter { /// Default full generation strategy pub fn default_generation(a: Vec, b: Vec) -> Vec<(T, T)> { a.iter() - .flat_map(|e| { - b.iter() - .map(|f| ((e.clone()), (f.clone()))) - .collect::>() - }) + .flat_map(|e| b.iter().map(|f| (*e, *f)).collect::>()) // .collect::>>() // .flatten() .collect() @@ -88,6 +82,6 @@ mod test { fn test_creator() { let t = default_generation(vec![1, 2, 3], vec![5, 6, 7]); println!("{:?}", t); - panic!() + // panic!() } } diff --git a/weaponry/src/weaponry_structs.rs b/crates/weaponry/src/weaponry_structs.rs similarity index 100% rename from weaponry/src/weaponry_structs.rs rename to crates/weaponry/src/weaponry_structs.rs diff --git a/weaponry/workflow.md b/crates/weaponry/workflow.md similarity index 100% rename from weaponry/workflow.md rename to crates/weaponry/workflow.md diff --git a/requirements/data.md b/requirements/data.md new file mode 100644 index 0000000..9879779 --- /dev/null +++ b/requirements/data.md @@ -0,0 +1,225 @@ +# Ravenous Tools - Spec-Schema + +Each line defines a single requirement in a machine-readable format. +The token `r[category.subcategory.item]` identifies the requirement; the following paragraph gives a human-friendly description. + +m Bulk Operations +r[bulk.export] +The `export` command must be able to generate classes, parts or objects as requested + +## Dashboard + +r[dashboard.metrics.display] +Dashboard must display aggregated statistics (total classes, average/SD for QOL, Damage, CC, Survivability, Mobility, Alterations, Support) in a terminal table. + +r[dashboard.configuration] +Dashboard must be able to read a user configuration with generic thresholds for validation. + +r[dashboard.warnings] +Dashboard must issue warnings for classes whose metrics exceed thresholds defined in the config (e.g., damage > 0.8). + +r[dashboard.ascii-charts] +Dashboard must be able to render ASCII charts (e.g., bar chart of average damage) using a terminal rendering crate. + + +## TeX Export + +r[tex.export] +The `tex` command must generate a LaTeX file for one or more classes, escaping special characters and including optional headers. + +r[tex.template] +The `--template` flag must allow users to provide a custom LaTeX template that overrides the default. + +r[tex.headers] +The `--no-headers` flag must omit LaTeX header/footer when appending to an existing document. + +r[tex.output-format] +The `--out tex` option must write the output to the file system, respecting the target path and filename conventions. + +## File Export +r[file.export.radar] +The tool must be able to display small inline graphs (radar) rendered to PNG/SVG for latex inclusion. + +r[file.export] +All elements (classes, items) must be compairable and exportable as graph + +r[file.export.html] +The tool must be able to export html graphs to compair elements + +## Search / Filter + +r[search.by-name] +The `search --name` flag must return class names matching a full or partial string. + +r[search.by-tag] +The `search --tag` flag must filter classes containing a specified tag. + +r[search.by-range] +The `search` command must support numeric range filters (e.g., `--max-damage 60`) and return classes, objects or parts within the bounds. + +## Graph Generation + +r[graph.damage-senarios] +The `graph` command must produce be able to produce several damage scenarios as graphs. + +r[graph.comparison] +The `graph comparison` command must produce a chart comparing a user-supplied list of classes. + +r[graph.embeddable] +Generated graph files must be referenceable from the TeX export via `\includegraphics`. + +## Validation + +r[validation.schema] +All JSON files used must be be validated befor being used. + +r[validation.error-report] +Validation errors must identify the exact property and reason, formatted for readability. + +r[validation.value-ranges] +The schema must enforce required fields, type constraints, and acceptable numeric ranges for each stat. + +## Help & Auto-Completion + +r[help.full] +`--help` for every sub-command must list all options, flags, and usage examples. + +## Logging + +r[logging.verbosity] +The CLI must accept `--verbose` and `--quiet` flags to control log level. + +r[logging.levels] +Supported levels are `error`, `warn`, `info`, `debug`, and `trace`, matching the configuration defaults. + +## Data Requirements + +r[data.repo-path] +The repository root must be configurable via `config/ravenous_tools_data.toml` under `repo_path`. + +r[data.file-format] +Each class must be stored as a single JSON file in `data/classes/`. + +r[data.config] +Global settings are stored in `config/ravenous_tools_data.toml` with fields for thresholds, templates, etc. + +## Non-Functional Requirements + +r[nonfunctional.extensibility] +A plugin system exposing the `ravenous_tools_plugin` trait must allow third-party crates to add metrics or output formats. + +r[nonfunctional.testing] +Unit and integration tests must cover ≥90 % of code paths, verified via CI. + +r[nonfunctional.ci] +GitHub Actions workflow must run tests, linting, and build on each push/PR. + +r[nonfunctional.documentation] +All public APIs must be documented, and a comprehensive README with examples must be provided. + +r[nonfunctional.logging-structured] +All logs must be emitted in structured JSON-lines format for easy parsing. + +## User-Story Requirements + +r[userstory.balancer] +Balancers must view the aggregated damage-per-HP ratio across all classes in the dashboard. + +r[userstory.writer] +Writers must export classes to LaTeX and embed graphs with minimal manual editing. + +r[userstory.developer] +Developers must implement custom metric calculators via the plugin interface. + +r[userstory.analyst] +Analysts must generate PNG graphs of damage curves directly from the terminal. + +## Acceptance Criteria + +r[acceptance.tex] +Generated `.tex` must compile without errors; templates and header flags must function. + +r[acceptance.dashboard] +Dashboard must display at least five distinct metrics and render ASCII charts legibly. + +r[acceptance.validation] +Invalid JSON files must be rejected with pinpointed error messages. + +r[acceptance.help] +`--help` output must enumerate all sub-commands and examples; completion scripts install cleanly. + +r[acceptance.graph] +PNG/SVG graph files must be created for each graph command and viewable in standard image viewers. + +r[acceptance.logging] +Verbose/quiet modes and file logging must work as specified, with timestamps and levels. + +r[acceptance.testing] +Code coverage must be ≥90 %; at least one end-to-end CLI test exercising create, export, and dashboard. + +r[acceptance.documentation] +README, usage guide, and plugin development docs must be complete and up-to-date. + +## Deliverables Checklist + +r[deliverables.binary] +The CLI binary `ravenous-tools` must be distributable on crates.io and as a GitHub release. + +r[deliverables.repo-skeleton] +The `data/` repository scaffold must be created empty with a README. + +r[deliverables.config-sample] +`config/ravenous_tools_data.toml` (sample) must be provided with default values. + +r[deliverables.latex-template] +`templates/default_template.toml` must be available and referenceable. + +r[deliverables.tests] +Unit tests covering ≥90 % and integration tests for each sub-command must be included. + +r[deliverables.ci-workflow] +A complete ci integration must be provided. + +r[deliverables.documentation] +README, usage guide, API docs, and plugin interface docs must be comprehensive. + +r[deliverables.plugin-interface] +`ravenous_tools_plugin` crate exposing the trait must be published. + +r[deliverables.example-plugin] +An example plugin (e.g., custom metric calculator) must be distributed with the repo. + +## Future Requirements + +r[bulk.classes.export] +The `export` command must accept one or several class names and generate tex files containing all requested classes. + +r[bulk.parts.export] +The `export` command must accept one or several parts types and generate tex files containing all requested parts. + +r[bulk.objects.export] +The `export` command must accept one or several objects types and generate tex files containing all requested objects. + +r[graph.supported-types] +Supported graph types include bar chart, line chart, heat-map, radar chart. + +r[completion.bash] +Auto-completion scripts for Bash must be installable via `install-completion` sub-command. + +r[completion.zsh] +Auto-completion scripts for Zsh must be installable via `install-completion` sub-command. + +r[completion.fish] +Auto-completion scripts for Fish must be installable via `install-completion` sub-command. + +r[completion.powershell] +Auto-completion scripts for PowerShell must be installable via `install-completion` sub-command. + +r[logging.file] +The `--log ` option must write structured logs (JSON-lines) to the specified file. + +r[userstory.designer] +Game designers must be able to add a new class with a single command and see it reflected immediately in exports. + +r[acceptance.crud] +All CRUD commands must correctly manipulate JSON files, with clear errors when classes are missing.