Add global vars to the module tree

This commit is contained in:
Tad Hardesty 2020-11-30 20:39:05 -08:00
parent 7c37211691
commit 1dc27b789a
2 changed files with 21 additions and 0 deletions

View file

@ -463,6 +463,19 @@ fn main2() -> Result<(), Box<dyn std::error::Error>> {
error_entity_put(format!("{}/var/{}", ty.path, name));
let block = DocBlock::parse(&var.value.docs.text(), Some(broken_link_callback));
// if the var is global, add it to the module tree
if ty.is_root() {
let module = module_entry(&mut modules1, &context.file_path(var.value.location.file));
module.items_wip.push((
var.value.location.line,
ModuleItem::GlobalVar {
name,
teaser: block.teaser().to_owned(),
}
));
}
// `type` is pulled from the parent if necessary
let type_ = ty.get_var_declaration(name).map(|decl| VarType {
is_static: decl.var_type.flags.is_static(),
@ -1253,4 +1266,9 @@ enum ModuleItem<'a> {
name: &'a str,
teaser: String,
},
#[serde(rename="global_var")]
GlobalVar {
name: &'a str,
teaser: String,
},
}

View file

@ -27,6 +27,9 @@
{%- elif item.global_proc -%}
<tr><th>/proc/<a href="global.html#proc/{{item.global_proc.name}}">{{item.global_proc.name}}</a></th>
<td>{{ item.global_proc.teaser | safe }}</td></tr>
{%- elif item.global_var -%}
<tr><th>/var/<a href="global.html#var/{{item.global_var.name}}">{{item.global_var.name}}</a></th>
<td>{{ item.global_var.teaser | safe }}</td></tr>
{%- endif %}
{%- endfor -%}
</table>