1mod pages {
6 pub const ZWF: &str = include_str!("../docs/zwf.md");
7 pub const PATTERNS: &str = include_str!("../docs/patterns.md");
8 pub const VARIABLES: &str = include_str!("../docs/variables.md");
9 pub const CONDITIONS: &str = include_str!("../docs/conditions.md");
10 pub const MEMORY: &str = include_str!("../docs/memory.md");
11 pub const STORAGE: &str = include_str!("../docs/storage.md");
12 pub const DRY_RUN: &str = include_str!("../docs/dry-run.md");
13}
14
15pub const TOPICS: &[(&str, &str)] = &[
17 ("zwf", "The .zwf/.zwfz workflow format"),
18 ("patterns", "Orchestration patterns"),
19 ("variables", "Variable system and data flow"),
20 ("conditions", "Condition expressions"),
21 ("memory", "Memory scratch pad and the `<memory>` block"),
22 (
23 "storage",
24 "Workflow storage — structured writable working data",
25 ),
26 ("dry-run", "Preview a workflow run without invoking zag"),
27];
28
29pub fn get(topic: &str) -> Option<&'static str> {
33 match topic {
34 "zwf" => Some(pages::ZWF),
35 "patterns" => Some(pages::PATTERNS),
36 "variables" => Some(pages::VARIABLES),
37 "conditions" => Some(pages::CONDITIONS),
38 "memory" => Some(pages::MEMORY),
39 "storage" => Some(pages::STORAGE),
40 "dry-run" => Some(pages::DRY_RUN),
41 _ => None,
42 }
43}
44
45pub fn list_topics() -> String {
47 let mut out = String::from("Available docs:\n\n");
48 let max_name_len = TOPICS.iter().map(|(name, _)| name.len()).max().unwrap_or(0);
49 for (name, description) in TOPICS {
50 out.push_str(&format!(
51 " {name:<width$} {description}\n",
52 width = max_name_len
53 ));
54 }
55 out.push_str("\nUsage: zig docs <topic>");
56 out
57}
58
59#[cfg(test)]
60#[path = "docs_tests.rs"]
61mod tests;