diff options
author | Alberto Luaces <aluaces@udc.es> | 2016-12-01 14:02:56 +0100 |
---|---|---|
committer | Alberto Luaces <aluaces@udc.es> | 2016-12-01 14:02:56 +0100 |
commit | 83355faf3e530fb36fcb32750ebedda19e1927ef (patch) | |
tree | ff9f7eb3cfb4842c41173e67b3a6614332343b24 /python-mode/.yas-setup.el | |
parent | 632df2ede2712994b12ee499abfc948e6dc3f9ae (diff) | |
parent | 12b385f3badb51bd3689a1a0986cc9410ea416c5 (diff) |
Merge latest upstream.
Diffstat (limited to 'python-mode/.yas-setup.el')
-rw-r--r-- | python-mode/.yas-setup.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/python-mode/.yas-setup.el b/python-mode/.yas-setup.el index 6635232..1af8703 100644 --- a/python-mode/.yas-setup.el +++ b/python-mode/.yas-setup.el @@ -1,3 +1,6 @@ +(require 'yasnippet) +(defvar yas-text) + (defun python-split-args (arg-string) "Split a python argument string into ((name, default)..) tuples" (mapcar (lambda (x) @@ -18,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))) |