diff options
author | Valentin Anger <syrupthinker@gryphno.de> | 2020-07-12 14:16:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 14:16:33 +0200 |
commit | 3374c73fba3a96df22d0c04e6c17078ca8cce45b (patch) | |
tree | 91d996554a2e276724a86ecb3bff19ea5411238b /cli/doc/function.rs | |
parent | 871f9255e37b4d2e63439c84da8e9bed6b388034 (diff) |
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
Diffstat (limited to 'cli/doc/function.rs')
-rw-r--r-- | cli/doc/function.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cli/doc/function.rs b/cli/doc/function.rs index e8abf56f9..ede8bdbbd 100644 --- a/cli/doc/function.rs +++ b/cli/doc/function.rs @@ -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(¶m.pat); + let param_def = + pat_to_param_def(¶m.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) } |