feat(doc): Improve terminal printer (#6594)

- Add more support for generics
- Add the --private flag - displays documentation for
  not exported and private nodes
- Display more attributes like abstract, static and readonly
- Display type aliases
- Refactor module to use the Display trait
- Use a bit more color
This commit is contained in:
Valentin Anger 2020-07-12 14:16:33 +02:00 committed by GitHub
parent 871f9255e3
commit 3374c73fba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 2888 additions and 1743 deletions

View file

@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use super::params::pat_to_param_def;
use super::parser::DocParser;
use super::ts_type::ts_type_ann_to_def;
use super::ts_type::TsTypeDef;
use super::ts_type_param::maybe_type_param_decl_to_type_param_defs;
@ -20,12 +21,14 @@ pub struct FunctionDef {
}
pub fn function_to_function_def(
doc_parser: &DocParser,
function: &swc_ecma_ast::Function,
) -> FunctionDef {
let mut params = vec![];
for param in &function.params {
let param_def = pat_to_param_def(&param.pat);
let param_def =
pat_to_param_def(&param.pat, Some(&doc_parser.ast_parser.source_map));
params.push(param_def);
}
@ -47,9 +50,10 @@ pub fn function_to_function_def(
}
pub fn get_doc_for_fn_decl(
doc_parser: &DocParser,
fn_decl: &swc_ecma_ast::FnDecl,
) -> (String, FunctionDef) {
let name = fn_decl.ident.sym.to_string();
let fn_def = function_to_function_def(&fn_decl.function);
let fn_def = function_to_function_def(&doc_parser, &fn_decl.function);
(name, fn_def)
}