Added numpy function docstring template
This commit is contained in:
parent
c6304aa86e
commit
10db44b841
|
@ -21,5 +21,19 @@
|
|||
(unless (string= formatted-args "")
|
||||
(mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent))))
|
||||
|
||||
(defun python-args-to-docstring-numpy ()
|
||||
"return docstring format for the python arguments in yas-text"
|
||||
(let* ((args (python-split-args yas-text))
|
||||
(format-arg (lambda(arg)
|
||||
(concat (nth 0 arg) " : " (if (nth 1 arg) ", optional") "\n")))
|
||||
(formatted-params (mapconcat format-arg args "\n"))
|
||||
(formatted-ret (mapconcat format-arg (list (list "out")) "\n")))
|
||||
(unless (string= formatted-params "")
|
||||
(mapconcat 'identity
|
||||
(list "\nParameters\n----------" formatted-params
|
||||
"\nReturns\n-------" formatted-ret)
|
||||
"\n"))))
|
||||
|
||||
|
||||
(add-hook 'python-mode-hook
|
||||
'(lambda () (set (make-local-variable 'yas-indent-line) 'fixed)))
|
||||
|
|
11
python-mode/function_docstring_numpy
Normal file
11
python-mode/function_docstring_numpy
Normal file
|
@ -0,0 +1,11 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: Egor Panfilov <egor.v.panfilov[at]gmail[dot]com>
|
||||
# name: function_docstring_numpy
|
||||
# key: fdn
|
||||
# group: definitions
|
||||
# --
|
||||
def ${1:name}($2):
|
||||
\"\"\"$3
|
||||
${2:$(python-args-to-docstring-numpy)}
|
||||
\"\"\"
|
||||
$0
|
Loading…
Reference in a new issue