Stationpedia docs

This commit is contained in:
2025-12-02 17:59:40 -07:00
parent bf1daf12cc
commit 75f1c5c44a
11 changed files with 211 additions and 24 deletions

View File

@@ -5,6 +5,8 @@ mod macros;
pub trait Documentation {
/// Retreive documentation for this specific item.
fn docs(&self) -> String;
fn get_all_documentation() -> Vec<(&'static str, String)>;
}
pub mod prelude {

View File

@@ -55,7 +55,7 @@ macro_rules! documented {
)*
}
// 2. Implement the Trait
// 2. Implement the Documentation Trait
impl Documentation for $name {
fn docs(&self) -> String {
match self {
@@ -79,6 +79,33 @@ macro_rules! documented {
)*
}
}
// 3. Implement Static Documentation Provider
#[allow(dead_code)]
fn get_all_documentation() -> Vec<(&'static str, String)> {
vec![
$(
(
stringify!($variant),
{
// Re-use the same extraction logic
let doc_lines: &[Option<&str>] = &[
$(
documented!(@doc_filter #[ $($variant_attr)* ])
),*
];
doc_lines.iter()
.filter_map(|&d| d)
.collect::<Vec<_>>()
.join("\n")
.trim()
.to_string()
}
)
),*
]
}
}
};
}