diff --git a/src/dmdoc/main.rs b/src/dmdoc/main.rs index 061a3083..5a3f7193 100644 --- a/src/dmdoc/main.rs +++ b/src/dmdoc/main.rs @@ -463,6 +463,19 @@ fn main2() -> Result<(), Box> { 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, + }, } diff --git a/src/dmdoc/template/dm_module.html b/src/dmdoc/template/dm_module.html index e6ec7b93..417953ea 100644 --- a/src/dmdoc/template/dm_module.html +++ b/src/dmdoc/template/dm_module.html @@ -27,6 +27,9 @@ {%- elif item.global_proc -%} /proc/{{item.global_proc.name}} {{ item.global_proc.teaser | safe }} + {%- elif item.global_var -%} + /var/{{item.global_var.name}} + {{ item.global_var.teaser | safe }} {%- endif %} {%- endfor -%}