From 3374c73fba3a96df22d0c04e6c17078ca8cce45b Mon Sep 17 00:00:00 2001 From: Valentin Anger Date: Sun, 12 Jul 2020 14:16:33 +0200 Subject: 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 --- cli/doc/function.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli/doc/function.rs') 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) } -- cgit v1.2.3