mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
feat(doc): handle detail output for enum (#6078)
This commit is contained in:
parent
fcae2fec87
commit
9bd5c08d5a
2 changed files with 16 additions and 0 deletions
|
@ -41,6 +41,7 @@ pub fn format_details(node: doc::DocNode) -> String {
|
|||
|
||||
let maybe_extra = match node.kind {
|
||||
DocNodeKind::Class => Some(format_class_details(node)),
|
||||
DocNodeKind::Enum => Some(format_enum_details(node)),
|
||||
DocNodeKind::Namespace => Some(format_namespace_details(node)),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -412,6 +413,17 @@ fn format_class_details(node: doc::DocNode) -> String {
|
|||
details
|
||||
}
|
||||
|
||||
fn format_enum_details(node: doc::DocNode) -> String {
|
||||
let mut details = String::new();
|
||||
let enum_def = node.enum_def.unwrap();
|
||||
for member in enum_def.members {
|
||||
details
|
||||
.push_str(&add_indent(format!("{}\n", colors::bold(member.name)), 1));
|
||||
}
|
||||
details.push_str("\n");
|
||||
details
|
||||
}
|
||||
|
||||
fn format_namespace_details(node: doc::DocNode) -> String {
|
||||
let mut ns = String::new();
|
||||
|
||||
|
|
|
@ -884,6 +884,10 @@ export enum Hello {
|
|||
let actual = serde_json::to_value(entry).unwrap();
|
||||
assert_eq!(actual, expected_json);
|
||||
|
||||
assert!(colors::strip_ansi_codes(
|
||||
super::printer::format_details(entry.clone()).as_str()
|
||||
)
|
||||
.contains("World"));
|
||||
assert!(colors::strip_ansi_codes(
|
||||
super::printer::format(entries.clone()).as_str()
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue