Fix docs generation of types

This commit is contained in:
Richard Feldman 2022-11-30 21:32:35 -05:00
parent f0b3c3eb08
commit ab45d6c632
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 26 additions and 21 deletions

View file

@ -654,6 +654,13 @@ impl LoadedModule {
.map(|symbol| symbol.as_str(&self.interns))
.collect()
}
pub fn exposed_aliases_str(&self) -> Vec<&str> {
self.exposed_aliases
.keys()
.map(|symbol| symbol.as_str(&self.interns))
.collect()
}
}
#[derive(Debug)]

View file

@ -9,7 +9,6 @@ use roc_can::scope::Scope;
use roc_code_markup::markup::nodes::MarkupNode;
use roc_code_markup::slow_pool::SlowPool;
use roc_highlight::highlight_parser::{highlight_defs, highlight_expr};
use roc_load::docs::DocEntry::DocDef;
use roc_load::docs::{DocEntry, TypeAnnotation};
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
@ -210,18 +209,17 @@ fn render_module_documentation(
);
let exposed_values = loaded_module.exposed_values_str();
let exposed_aliases = loaded_module.exposed_aliases_str();
for entry in &module.entries {
let mut should_render_entry = true;
if let DocDef(def) = entry {
// We dont want to render entries that arent exposed
should_render_entry = exposed_values.contains(&def.name.as_str());
}
if should_render_entry {
match entry {
DocEntry::DocDef(doc_def) => {
let name_str = doc_def.name.as_str();
// We dont want to render entries that arent exposed
let should_render_entry =
exposed_values.contains(&name_str) || exposed_aliases.contains(&name_str);
if should_render_entry {
buf.push_str("<section>");
let mut href = String::new();
@ -275,6 +273,7 @@ fn render_module_documentation(
buf.push_str("</section>");
}
}
DocEntry::DetachedDoc(docs) => {
let markdown = markdown_to_html(
&exposed_values,
@ -286,7 +285,6 @@ fn render_module_documentation(
}
};
}
}
buf
}