1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

feat(doc): handle detail output for enum (#6078)

This commit is contained in:
uki00a 2020-06-04 04:40:50 +09:00 committed by GitHub
parent fcae2fec87
commit 9bd5c08d5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -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();

View file

@ -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()
)