Skip to content

Commit

Permalink
implement variable & type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Oct 25, 2023
1 parent 3eba944 commit 0b4b0dc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ fn doc_block(doc_nodes: &[crate::DocNode], name: &str) -> String {
match doc_node.kind {
DocNodeKind::ModuleDoc => {}
DocNodeKind::Function => functions.push(doc_node),
DocNodeKind::Variable => {}
DocNodeKind::Variable => {
content.push_str(&variable::render_variable(doc_node))
}
DocNodeKind::Class => {}
DocNodeKind::Enum => content.push_str(&r#enum::render_enum(doc_node)),
DocNodeKind::Interface => {}
DocNodeKind::TypeAlias => {}
DocNodeKind::TypeAlias => {
content.push_str(&type_alias::render_type_alias(doc_node))
}
DocNodeKind::Namespace => {}
DocNodeKind::Import => {}
};
Expand Down
23 changes: 23 additions & 0 deletions src/html/type_alias.rs
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
use crate::html::r#type::render_type_def;
use crate::html::util::*;

pub fn render_type_alias(doc_node: &crate::DocNode) -> String {
let type_alias_def = doc_node.type_alias_def.as_ref().unwrap();

let id = name_to_id("typeAlias", &doc_node.name);

// TODO: tags, examples, TypeParamsDoc

format!(
r#"<div class="docBlockItems">{}</div>"#,
section(
"type",
&doc_entry(
&id,
"definition",
&format!(": {}", render_type_def(&type_alias_def.ts_type)),
)
)
)
}

// TODO: classes: docBlockItems
27 changes: 27 additions & 0 deletions src/html/variable.rs
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
use crate::html::r#type::render_type_def;
use crate::html::util::*;

pub fn render_variable(doc_node: &crate::DocNode) -> String {
let variable_def = doc_node.variable_def.as_ref().unwrap();

if variable_def.ts_type.is_none() {
return String::new();
}

let id = name_to_id("variable", &doc_node.name);

// TODO: examples

format!(
r#"<div class="docBlockItems">{}</div>"#,
section(
"type",
&doc_entry(
&id,
"",
&render_type_def(variable_def.ts_type.as_ref().unwrap())
)
)
)
}

// TODO: classes: docBlockItems

0 comments on commit 0b4b0dc

Please sign in to comment.