Stationpedia docs
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
)
|
||||
),*
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +236,13 @@ impl Documentation for SysCall {
|
||||
Self::Math(m) => m.docs(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_all_documentation() -> Vec<(&'static str, String)> {
|
||||
let mut all_docs = System::get_all_documentation();
|
||||
all_docs.extend(Math::get_all_documentation());
|
||||
|
||||
all_docs
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SysCall {
|
||||
|
||||
@@ -95,6 +95,10 @@ impl Documentation for TokenType {
|
||||
_ => "".into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_all_documentation() -> Vec<(&'static str, String)> {
|
||||
Keyword::get_all_documentation()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TokenType> for u32 {
|
||||
|
||||
Reference in New Issue
Block a user