diff --git a/ftplugin/javascriptreact/jsdoc.vim b/ftplugin/javascriptreact/jsdoc.vim new file mode 100644 index 0000000..0270bfc --- /dev/null +++ b/ftplugin/javascriptreact/jsdoc.vim @@ -0,0 +1,22 @@ +" File: jsdoc.vim +" Author: NAKAMURA, Hisashi +" Author: Shinya Ohyanagi +" Version: 2.1.4 +" WebPage: http://github.com/heavenshell/vim-jsdoc/ +" Description: Generate JSDoc to your JavaScript, TypeScript file. +" License: BSD, see LICENSE for more details. +let s:save_cpo = &cpo +set cpo&vim + +" version check +if !has('nvim') && (!has('channel') || !has('job')) + echoerr '+channel and +job are required for jsdoc.vim' + finish +endif + +command! -range=0 JsDoc call jsdoc#insert(, , , ) +command! JsDocFormat call jsdoc#format() +nnoremap (jsdoc) :call jsdoc#insert() + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/ftplugin/typescriptreact/jsdoc.vim b/ftplugin/typescriptreact/jsdoc.vim new file mode 100644 index 0000000..0270bfc --- /dev/null +++ b/ftplugin/typescriptreact/jsdoc.vim @@ -0,0 +1,22 @@ +" File: jsdoc.vim +" Author: NAKAMURA, Hisashi +" Author: Shinya Ohyanagi +" Version: 2.1.4 +" WebPage: http://github.com/heavenshell/vim-jsdoc/ +" Description: Generate JSDoc to your JavaScript, TypeScript file. +" License: BSD, see LICENSE for more details. +let s:save_cpo = &cpo +set cpo&vim + +" version check +if !has('nvim') && (!has('channel') || !has('job')) + echoerr '+channel and +job are required for jsdoc.vim' + finish +endif + +command! -range=0 JsDoc call jsdoc#insert(, , , ) +command! JsDocFormat call jsdoc#format() +nnoremap (jsdoc) :call jsdoc#insert() + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/tests/js.vader b/tests/js.vader index cfed3ee..0ac01e0 100644 --- a/tests/js.vader +++ b/tests/js.vader @@ -321,3 +321,16 @@ Expect javascript: console.log('foo') } } + +Given javascriptreact (named function with no arg): + function foo() { } + +Execute: + JsDoc + :sleep 1 + +Expect javascript: + /** + * foo. + */ + function foo() { } diff --git a/tests/ts.vader b/tests/ts.vader index d8f5c9d..97a740c 100644 --- a/tests/ts.vader +++ b/tests/ts.vader @@ -12,7 +12,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: /** * foo. * @@ -33,7 +33,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: /** * foo. * @@ -52,7 +52,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: /** * IFoo. */ @@ -68,7 +68,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: /** * Bar. * @@ -90,7 +90,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: class Bar extends Foo implements IFoo { /** * constructor. @@ -114,7 +114,7 @@ Execute: :JsDoc :sleep 1 -Expect javascript: +Expect typescript: class Bar extends Foo implements IFoo { /** * foo. @@ -126,3 +126,24 @@ Expect javascript: private foo(arg1: string, arg2: number = 0): void { } } + +Given typescript (typescriptreact): + function foo(foo: string = 'foo', bar: number = 1): string { + return 'foo' + } + +Execute: + :JsDoc + :sleep 1 + +Expect typescript: + /** + * foo. + * + * @param {string} foo + * @param {number} bar + * @returns {string} + */ + function foo(foo: string = 'foo', bar: number = 1): string { + return 'foo' + }