mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-24 13:10:07 +00:00
feat: export package docs to json format and render to html (#1809)
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
It provides a `package-doc.json` and HTML is rendered using a
`package-doc` function.
```typ
#let package-doc(info, path: none) [
#metadata((
// more sub paths
)) <static-paths>
#render-page(info, path) // the content of $path/.html
]
#package-doc(json("package-doc.json"))
```
This commit is contained in:
parent
2c552ce985
commit
bf081ec347
11 changed files with 2544 additions and 133 deletions
|
|
@ -66,6 +66,8 @@ pub fn module_docs(ctx: &mut LocalContext, entry_point: FileId) -> StrResult<Pac
|
|||
/// Information about a definition.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct DefInfo {
|
||||
/// The raw documentation of the definition.
|
||||
pub id: EcoString,
|
||||
/// The name of the definition.
|
||||
pub name: EcoString,
|
||||
/// The kind of the definition.
|
||||
|
|
@ -74,6 +76,10 @@ pub struct DefInfo {
|
|||
pub loc: Option<(usize, usize, usize)>,
|
||||
/// Whether the definition external to the module.
|
||||
pub is_external: bool,
|
||||
/// The module link to the definition
|
||||
pub module_link: Option<String>,
|
||||
/// The symbol link to the definition
|
||||
pub symbol_link: Option<String>,
|
||||
/// The link to the definition if it is external.
|
||||
pub external_link: Option<String>,
|
||||
/// The one-line documentation of the definition.
|
||||
|
|
@ -90,7 +96,7 @@ pub struct DefInfo {
|
|||
#[serde(skip)]
|
||||
pub decl: Option<Interned<Decl>>,
|
||||
/// The children of the definition.
|
||||
pub children: EcoVec<DefInfo>,
|
||||
pub children: Vec<DefInfo>,
|
||||
}
|
||||
|
||||
/// Information about the definitions in a package.
|
||||
|
|
@ -206,6 +212,7 @@ impl ScanDefCtx<'_> {
|
|||
};
|
||||
|
||||
let mut head = DefInfo {
|
||||
id: EcoString::new(),
|
||||
name: key.to_string().into(),
|
||||
kind: decl.kind(),
|
||||
constant: expr.map(|expr| expr.repr()),
|
||||
|
|
@ -215,6 +222,8 @@ impl ScanDefCtx<'_> {
|
|||
children: children.unwrap_or_default(),
|
||||
loc: None,
|
||||
is_external: false,
|
||||
module_link: None,
|
||||
symbol_link: None,
|
||||
external_link: None,
|
||||
oneliner: None,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue