Skip to content

Commit

Permalink
feat: Add tests for omit_redundant_param_types option for javascript,…
Browse files Browse the repository at this point in the history
… add option description to readme.
  • Loading branch information
vantreeseba committed Feb 1, 2021
1 parent 17b6147 commit 3049d64
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,16 @@ being aliased, see [`g:doge_filetype_aliases`](#gdoge_filetype_aliases).
```vim
let g:doge_javascript_settings = {
\ 'destructuring_props': 1,
\ 'omit_redundant_param_types': 0,
\}
```

- `destructuring_props`: Whether or not to generate `@param` tags for the
destructured properties in a function expression.

- `omit_redundant_param_types`: Whether or not to omit the `{Type}` part of
parameters, when the type is known (i.e. typescript).

### PHP

```vim
Expand Down
40 changes: 40 additions & 0 deletions test/filetypes/javascript/functions.vader
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,46 @@ Expect javascript (generated comments with a description, @param and @return tag
*/
function foo({ a, b: str, c = 3, d: int = 5 }) {}

# ==============================================================================
# Test the 'omit_redundant_param_types' option
# ==============================================================================
Given javascript (functions with type information):
function foo(a, b: str, c = 3, d: int = 5):int {}

function foo(a, b: str, c = 3, d: int = 5):int {}


Do (trigger doge):
:let g:doge_javascript_settings = {'omit_redundant_param_types': 1}\<CR>
:1\<CR>
\<C-d>
:let g:doge_javascript_settings = {'omit_redundant_param_types': 0}\<CR>
:13\<CR>
\<C-d>
:let g:doge_javascript_settings = {'omit_redundant_param_types': 1}\<CR>

Expect javascript (generated comments with a description, @param and @return tags):
/**
* [TODO:description]
*
* @param {[TODO:type]} a - [TODO:description]
* @param {str} b - [TODO:description]
* @param {[TODO:type]} [c] - [TODO:description]
* @param {int} [d] - [TODO:description]
* @return {int} [TODO:description]
*/
function foo(a, b: str, c = 3, d: int = 5):int {}

/**
* [TODO:description]
*
* @param {[TODO:type]} a - [TODO:description]
* @param b - [TODO:description]
* @param {[TODO:type]} [c] - [TODO:description]
* @param [d] - [TODO:description]
*/
function foo(a, b: str, c = 3, d: int = 5):int {}

# ==============================================================================
# Function calls that should not generate documentation
# ==============================================================================
Expand Down

0 comments on commit 3049d64

Please sign in to comment.