Skip to content

Commit

Permalink
[documentation] Refactor CommonMark formatting [#95]
Browse files Browse the repository at this point in the history
  • Loading branch information
cipriancraciun committed Jun 27, 2018
1 parent eb5d7da commit f448789
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions sources/tools_documentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,26 +527,30 @@ pub fn dump_cmark (libraries : Libraries, stream : &mut dyn io::Write) -> (Outco
}
}

if category.has_definitions () {
try_writeln! (stream);
try_writeln! (stream, "Complete list of definitions:");
for definition in category.definitions () {
let definition_anchor = try! (generate_anchor (Some ("definition"), Some (library.identifier ()), Some (definition.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", definition.identifier (), definition_anchor);
}
}
try! (write_description (category.description (), stream));
try! (write_links (category.links (), stream));

if category.has_value_kinds () {
try_writeln! (stream);
try_writeln! (stream, "Complete list of types:");
try_writeln! (stream);
try_writeln! (stream, "#### Types");
try_writeln! (stream);
for value_kind in category.value_kinds () {
let value_kind_anchor = try! (generate_anchor (Some ("value_kind"), Some (library.identifier ()), Some (value_kind.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", value_kind.identifier (), value_kind_anchor);
}
}

try! (write_description (category.description (), stream));
try! (write_links (category.links (), stream));
if category.has_definitions () {
try_writeln! (stream);
try_writeln! (stream);
try_writeln! (stream, "#### Definitions");
try_writeln! (stream);
for definition in category.definitions () {
let definition_anchor = try! (generate_anchor (Some ("definition"), Some (library.identifier ()), Some (definition.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", definition.identifier (), definition_anchor);
}
}

try_writeln! (stream);
try_writeln! (stream, "Goto: [library](#{}), [categories](#{}), [types](#{}), [definitions](#{}).", &library_anchor, &categories_anchor, &value_kinds_anchor, &definitions_anchor);
Expand Down Expand Up @@ -646,18 +650,20 @@ pub fn dump_cmark (libraries : Libraries, stream : &mut dyn io::Write) -> (Outco
}
}

try! (write_description (value_kind.description (), stream));
try! (write_links (value_kind.links (), stream));

if value_kind.has_definitions () {
try_writeln! (stream);
try_writeln! (stream, "Referenced by the following definitions:");
try_writeln! (stream);
try_writeln! (stream, "#### Referent definitions");
try_writeln! (stream);
for definition in value_kind.definitions () {
let definition_anchor = try! (generate_anchor (Some ("definition"), Some (library.identifier ()), Some (definition.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", definition.identifier (), definition_anchor);
}
}

try! (write_description (value_kind.description (), stream));
try! (write_links (value_kind.links (), stream));

try_writeln! (stream);
try_writeln! (stream, "Goto: [library](#{}), [categories](#{}), [types](#{}), [definitions](#{}).", &library_anchor, &categories_anchor, &value_kinds_anchor, &definitions_anchor);
try_writeln! (stream);
Expand Down Expand Up @@ -721,15 +727,6 @@ pub fn dump_cmark (libraries : Libraries, stream : &mut dyn io::Write) -> (Outco
}
}

if definition.has_referenced_value_kinds () {
try_writeln! (stream);
try_writeln! (stream, "References the following types:");
for value_kind in definition.referenced_value_kinds () {
let value_kind_anchor = try! (generate_anchor (Some ("value_kind"), Some (library.identifier ()), Some (value_kind.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", value_kind.identifier (), value_kind_anchor);
}
}

try! (write_description (definition.description (), stream));
try! (write_links (definition.links (), stream));

Expand Down Expand Up @@ -817,6 +814,17 @@ pub fn dump_cmark (libraries : Libraries, stream : &mut dyn io::Write) -> (Outco
}
}

if definition.has_referenced_value_kinds () {
try_writeln! (stream);
try_writeln! (stream);
try_writeln! (stream, "#### Referenced types");
try_writeln! (stream);
for value_kind in definition.referenced_value_kinds () {
let value_kind_anchor = try! (generate_anchor (Some ("value_kind"), Some (library.identifier ()), Some (value_kind.identifier ())));
try_writeln! (stream, " * [`{}`](#{});", value_kind.identifier (), value_kind_anchor);
}
}

try_writeln! (stream);
try_writeln! (stream, "Goto: [library](#{}), [categories](#{}), [types](#{}), [definitions](#{}).", &library_anchor, &categories_anchor, &value_kinds_anchor, &definitions_anchor);
try_writeln! (stream);
Expand Down

0 comments on commit f448789

Please sign in to comment.