Allow hidden modules, not generating any documentation.
This is useful when splitting module for dependencies, yet without the desire to expose internal constructors and types. This merely skips the documentation generation; but doesn't prevent the hidden module from being accessible.
This commit is contained in:
parent
7eee3ce63c
commit
44e42d608d
|
@ -127,6 +127,10 @@ pub fn generate_all(root: &Path, config: &Config, modules: Vec<&CheckedModule>)
|
||||||
let mut search_indexes: Vec<SearchIndex> = vec![];
|
let mut search_indexes: Vec<SearchIndex> = vec![];
|
||||||
|
|
||||||
for module in &modules {
|
for module in &modules {
|
||||||
|
if module.skip_doc_generation() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let (indexes, file) = generate_module(config, module, &modules_links, &source, ×tamp);
|
let (indexes, file) = generate_module(config, module, &modules_links, &source, ×tamp);
|
||||||
if !indexes.is_empty() {
|
if !indexes.is_empty() {
|
||||||
search_indexes.extend(indexes);
|
search_indexes.extend(indexes);
|
||||||
|
@ -356,15 +360,16 @@ fn generate_modules_links(modules: &[&CheckedModule]) -> Vec<DocLink> {
|
||||||
let non_empty_modules = modules
|
let non_empty_modules = modules
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|module| {
|
.filter(|module| {
|
||||||
module.ast.definitions.iter().any(|def| {
|
!module.skip_doc_generation()
|
||||||
matches!(
|
&& module.ast.definitions.iter().any(|def| {
|
||||||
def,
|
matches!(
|
||||||
Definition::Fn(Function { public: true, .. })
|
def,
|
||||||
| Definition::DataType(DataType { public: true, .. })
|
Definition::Fn(Function { public: true, .. })
|
||||||
| Definition::TypeAlias(TypeAlias { public: true, .. })
|
| Definition::DataType(DataType { public: true, .. })
|
||||||
| Definition::ModuleConstant(ModuleConstant { public: true, .. })
|
| Definition::TypeAlias(TypeAlias { public: true, .. })
|
||||||
)
|
| Definition::ModuleConstant(ModuleConstant { public: true, .. })
|
||||||
})
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.sorted_by(|a, b| a.name.cmp(&b.name))
|
.sorted_by(|a, b| a.name.cmp(&b.name))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
|
@ -291,6 +291,15 @@ pub struct CheckedModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedModule {
|
impl CheckedModule {
|
||||||
|
pub fn skip_doc_generation(&self) -> bool {
|
||||||
|
self.ast
|
||||||
|
.docs
|
||||||
|
.first()
|
||||||
|
.map(|s| s.as_str().trim())
|
||||||
|
.unwrap_or_default()
|
||||||
|
== "@hidden"
|
||||||
|
}
|
||||||
|
|
||||||
pub fn to_cbor(&self) -> Vec<u8> {
|
pub fn to_cbor(&self) -> Vec<u8> {
|
||||||
let mut module_bytes = vec![];
|
let mut module_bytes = vec![];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue