Skip to content

Commit

Permalink
docs: Adds parent to classes & structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Sep 6, 2024
1 parent 18548af commit da1462a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Tools/DocumentationCLI/src/reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,23 @@ impl<'a> ReflectionContext<'a> {
Ok(())
}

fn write_file_base(&self, file: &mut File, base: &ReflectionBase) -> Result<()> {
fn write_file_base(&self, file: &mut File, base: &ReflectionBase, parent: Option<String>) -> Result<()> {
let title = base.display_name();
let description = &base.description;

writeln!(file, "= {title}")?;
writeln!(file, ":table-caption!:")?;
writeln!(file)?;

if let Some(parent) = parent {
writeln!(file, r#"[cols="1,5a",separator="!"]"#)?;
writeln!(file, "!===")?;
writeln!(file, "! Parent")?;
writeln!(file, "! {parent}")?;
writeln!(file, "!===")?;
writeln!(file)?;
}

writeln!(file, "{description}")?;
writeln!(file)?;

Expand All @@ -407,7 +417,9 @@ impl<'a> ReflectionContext<'a> {
file: &mut File,
ref_struct: &ReflectionStruct,
) -> Result<()> {
self.write_file_base(file, &ref_struct.base)?;
let parent = ref_struct.parent.as_ref().map(|p| escape_for_adoc_table(&self.ctx.xref_struct(&Some(p.as_str()))));

self.write_file_base(file, &ref_struct.base, parent)?;

if !ref_struct.properties.is_empty() {
let mut properties: Vec<_> = ref_struct.properties.iter().collect();
Expand Down Expand Up @@ -478,7 +490,9 @@ impl<'a> ReflectionContext<'a> {
}

pub(crate) fn write_class(&self, file: &mut File, ref_class: &ReflectionClass) -> Result<()> {
self.write_file_base(file, &ref_class.reflection_struct.base)?;
let parent = ref_class.reflection_struct.parent.as_ref().map(|p| escape_for_adoc_table(&self.ctx.xref_class(&Some(p.as_str()))));

self.write_file_base(file, &ref_class.reflection_struct.base, parent)?;

writeln!(file, "// tag::interface[]")?;
writeln!(file)?;
Expand Down

0 comments on commit da1462a

Please sign in to comment.