first working version of docs hover

This commit is contained in:
faldor20 2024-03-10 19:41:57 +10:00
parent 87af8bd610
commit cdf218fe7a
No known key found for this signature in database
GPG key ID: F2216079B890CD57
8 changed files with 58748 additions and 31 deletions

View file

@ -177,6 +177,8 @@ fn generate_entry_docs(
let mut acc = Vec::with_capacity(defs.tags.len() + 1);
if let Some(docs) = comments_or_new_lines_to_docs(header_comments) {
println!("<<docs:\n {:#?}\n docs>>", docs);
acc.push(DetachedDoc(docs));
}
@ -197,6 +199,7 @@ fn generate_entry_docs(
let docs = comments_or_new_lines_to_docs(&scratchpad);
println!("<<docs:\n {:#?}\n docs>>", docs);
match either_index.split() {
Err(value_index) => match &defs.value_defs[value_index.index()] {
ValueDef::Annotation(loc_pattern, loc_ann) => {
@ -379,12 +382,14 @@ fn contains_unexposed_type(
Apply(module_name, _ident, loc_args) => {
// If the *ident* was unexposed, we would have gotten a naming error
// during canonicalization, so all we need to check is the module.
let module_id = module_ids.get_id(&(*module_name).into()).unwrap();
!exposed_module_ids.contains(&module_id)
|| loc_args.iter().any(|loc_arg| {
contains_unexposed_type(&loc_arg.value, exposed_module_ids, module_ids)
})
if let Some(module_id) = module_ids.get_id(&(*module_name).into()) {
!exposed_module_ids.contains(&module_id)
|| loc_args.iter().any(|loc_arg| {
contains_unexposed_type(&loc_arg.value, exposed_module_ids, module_ids)
})
} else {
return true;
}
}
Malformed(_) | Inferred | Wildcard | BoundVariable(_) => false,
Function(loc_args, loc_ret) => {

View file

@ -3378,17 +3378,13 @@ fn finish(
roc_checkmate::dump_checkmate!(checkmate);
let mut docs_by_module = Vec::with_capacity(state.exposed_modules.len());
// let mut docs_by_module = Vec::with_capacity(state.exposed_modules.len());
for module_id in state.exposed_modules.iter() {
let docs = documentation.remove(module_id).unwrap_or_else(|| {
panic!("A module was exposed but didn't have an entry in `documentation` somehow: {module_id:?}");
});
docs_by_module.push(docs);
}
debug_assert_eq!(documentation.len(), 0);
// for (module_id, _) in state.module_cache.module_names {
// if let Some(docs) = documentation.remove(&module_id) {
// docs_by_module.push(docs);
// }
// }
LoadedModule {
module_id: state.root_id,
@ -3406,7 +3402,7 @@ fn finish(
resolved_implementations,
sources,
timings: state.timings,
docs_by_module,
docs_by_module: documentation,
abilities_store,
exposed_imports: state.module_cache.exposed_imports,
imports: state.module_cache.imports,
@ -5411,9 +5407,7 @@ fn canonicalize_and_constrain<'a>(
}
HeaderType::Interface { name, .. }
| HeaderType::Builtin { name, .. }
| HeaderType::Hosted { name, .. }
if exposed_module_ids.contains(&parsed.module_id) =>
{
| HeaderType::Hosted { name, .. } => {
let mut scope = module_output.scope.clone();
scope.add_docs_imports();
let docs = crate::docs::generate_module_docs(
@ -5427,12 +5421,11 @@ fn canonicalize_and_constrain<'a>(
parsed.header_comments,
);
println!("adding docs for {:?},", module_path);
println!("docs {:#?},", &docs);
Some(docs)
}
HeaderType::Interface { .. } | HeaderType::Builtin { .. } | HeaderType::Hosted { .. } => {
// This module isn't exposed by the platform, so don't generate docs for it!
None
}
};
// _before has an underscore because it's unused in --release builds

View file

@ -43,7 +43,7 @@ pub struct LoadedModule {
pub resolved_implementations: ResolvedImplementations,
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
pub timings: MutMap<ModuleId, ModuleTiming>,
pub docs_by_module: Vec<(ModuleId, ModuleDocumentation)>,
pub docs_by_module: VecMap<ModuleId, ModuleDocumentation>,
pub abilities_store: AbilitiesStore,
pub typechecked: MutMap<ModuleId, CheckedModule>,