Capture global module docs in JSON.
This commit is contained in:
parent
fcc363af60
commit
eb5b15e954
@ -247,6 +247,7 @@ fn setup_editor() -> Editor<()> {
|
|||||||
rl
|
rl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Module containing sample functions.
|
||||||
#[export_module]
|
#[export_module]
|
||||||
mod sample_functions {
|
mod sample_functions {
|
||||||
/// This is a sample function.
|
/// This is a sample function.
|
||||||
|
@ -168,6 +168,8 @@ pub fn gen_metadata_to_json(
|
|||||||
include_standard_packages: bool,
|
include_standard_packages: bool,
|
||||||
) -> serde_json::Result<String> {
|
) -> serde_json::Result<String> {
|
||||||
let _ast = ast;
|
let _ast = ast;
|
||||||
|
#[cfg(feature = "metadata")]
|
||||||
|
let mut global_doc = String::new();
|
||||||
let mut global = ModuleMetadata::new();
|
let mut global = ModuleMetadata::new();
|
||||||
|
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
@ -185,7 +187,16 @@ pub fn gen_metadata_to_json(
|
|||||||
.global_modules
|
.global_modules
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|m| !m.flags.contains(exclude_flags))
|
.filter(|m| !m.flags.contains(exclude_flags))
|
||||||
.flat_map(|m| m.iter_fn())
|
.flat_map(|m| {
|
||||||
|
#[cfg(feature = "metadata")]
|
||||||
|
if !m.doc().is_empty() {
|
||||||
|
if !global_doc.is_empty() {
|
||||||
|
global_doc.push('\n');
|
||||||
|
}
|
||||||
|
global_doc.push_str(m.doc());
|
||||||
|
}
|
||||||
|
m.iter_fn()
|
||||||
|
})
|
||||||
.for_each(|f| {
|
.for_each(|f| {
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut meta: FnMetadata = f.into();
|
let mut meta: FnMetadata = f.into();
|
||||||
@ -213,7 +224,17 @@ pub fn gen_metadata_to_json(
|
|||||||
|
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
if let Some(ast) = _ast {
|
if let Some(ast) = _ast {
|
||||||
global.doc = ast.doc();
|
if !ast.doc().is_empty() {
|
||||||
|
if !global_doc.is_empty() {
|
||||||
|
global_doc.push('\n');
|
||||||
|
}
|
||||||
|
global_doc.push_str(ast.doc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "metadata")]
|
||||||
|
{
|
||||||
|
global.doc = &global_doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
serde_json::to_string_pretty(&global)
|
serde_json::to_string_pretty(&global)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user