<|>
var connect = function(port, methods, host) {
/**
* <|>
* @param {} port -
* @param {[]} methods -
* @param {} host -
* @return
*/
var connect = function(port, methods, host) {
引数名がsで終わってたら、勝手に配列だと解釈する.
# -*- mode: snippet -*- | |
# name: jsdoc comment | |
# key: doc | |
# -- | |
/** | |
* $0 | |
`(save-excursion | |
(let* ((pos-fun (re-search-forward "\\<function\\s-*(\\([^)]*\\))")) | |
(argstr (and pos-fun (match-string 1))) | |
(args (and pos-fun (split-string argstr ",\\s-*")))) | |
(loop with params = nil | |
for arg in args | |
for nump = (string-match "s$" arg) | |
for param = (if nump (format " * @param {[]} %s - " arg) | |
(format " * @param {} %s - " arg)) | |
do | |
(if (< 0 (length arg)) | |
(push param params)) | |
finally return | |
(mapconcat 'identity (reverse (cons " * @return " params)) "\n"))))` | |
*/ |
regex should be more like this:
\\<function\\s-*\.*(\\([^)]*\\))
so it can match strings like
function foo(a, b, c)
otherwise it throws an error:
[yas] elisp error: Search failed: "\\<function\\s-*(\\([^)]*\\))"