mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
Fix docs generation of types
This commit is contained in:
parent
f0b3c3eb08
commit
ab45d6c632
2 changed files with 26 additions and 21 deletions
|
@ -654,6 +654,13 @@ impl LoadedModule {
|
||||||
.map(|symbol| symbol.as_str(&self.interns))
|
.map(|symbol| symbol.as_str(&self.interns))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn exposed_aliases_str(&self) -> Vec<&str> {
|
||||||
|
self.exposed_aliases
|
||||||
|
.keys()
|
||||||
|
.map(|symbol| symbol.as_str(&self.interns))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -9,7 +9,6 @@ use roc_can::scope::Scope;
|
||||||
use roc_code_markup::markup::nodes::MarkupNode;
|
use roc_code_markup::markup::nodes::MarkupNode;
|
||||||
use roc_code_markup::slow_pool::SlowPool;
|
use roc_code_markup::slow_pool::SlowPool;
|
||||||
use roc_highlight::highlight_parser::{highlight_defs, highlight_expr};
|
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::{DocEntry, TypeAnnotation};
|
||||||
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
|
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
|
||||||
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
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_values = loaded_module.exposed_values_str();
|
||||||
|
let exposed_aliases = loaded_module.exposed_aliases_str();
|
||||||
|
|
||||||
for entry in &module.entries {
|
for entry in &module.entries {
|
||||||
let mut should_render_entry = true;
|
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 let DocDef(def) = entry {
|
if should_render_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) => {
|
|
||||||
buf.push_str("<section>");
|
buf.push_str("<section>");
|
||||||
|
|
||||||
let mut href = String::new();
|
let mut href = String::new();
|
||||||
|
@ -275,17 +273,17 @@ fn render_module_documentation(
|
||||||
|
|
||||||
buf.push_str("</section>");
|
buf.push_str("</section>");
|
||||||
}
|
}
|
||||||
DocEntry::DetachedDoc(docs) => {
|
}
|
||||||
let markdown = markdown_to_html(
|
DocEntry::DetachedDoc(docs) => {
|
||||||
&exposed_values,
|
let markdown = markdown_to_html(
|
||||||
&module.scope,
|
&exposed_values,
|
||||||
docs.to_string(),
|
&module.scope,
|
||||||
loaded_module,
|
docs.to_string(),
|
||||||
);
|
loaded_module,
|
||||||
buf.push_str(markdown.as_str());
|
);
|
||||||
}
|
buf.push_str(markdown.as_str());
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
buf
|
buf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue