File tree 4 files changed +47
-0
lines changed
4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ (defun python-split-args (arg-string )
2
+ " Split a python argument string into ((name, default)..) tuples"
3
+ (mapcar '(lambda (x)
4
+ (split-string x " [[:blank:]]*=[[:blank:]]*" t ))
5
+ (split-string arg-string " [[:blank:]]*,[[:blank:]]*" t )))
6
+
7
+ (defun python-args-to-docstring ()
8
+ " return docstring format for the python arguments in yas-text"
9
+ (let* ((indent (concat " \n " (make-string (current-column ) 32 )))
10
+ (args (mapconcat
11
+ '(lambda (x)
12
+ (concat (nth 0 x) " -- "
13
+ (if (nth 1 x) (concat " \( default " (nth 1 x) " \) " ))))
14
+ (python-split-args yas-text)
15
+ indent)))
16
+ (unless (string= args " " )
17
+ (mapconcat 'identity (list " Keyword Arguments:" args) indent))))
Original file line number Diff line number Diff line change
1
+ # -*- mode : snippet -*-
2
+ # name : function_docstring
3
+ # key : fd
4
+ # group : definitions
5
+ # --
6
+ def ${ 1 :name } ($2 ):
7
+ \"\"\" $3
8
+ ${ 2 :$ (python-args-to-docstring) }
9
+ \"\"\"
10
+ $0
Original file line number Diff line number Diff line change
1
+ # -*- mode : snippet -*-
2
+ # name : init_docstring
3
+ # key : id
4
+ # group : definitions
5
+ # --
6
+ def __init__(self$1 ):
7
+ \"\"\" $2
8
+ ${ 1 :$ (python-args-to-docstring) }
9
+ \"\"\"
10
+ $0
Original file line number Diff line number Diff line change
1
+ # -*- mode : snippet -*-
2
+ # name : method_docstring
3
+ # key : md
4
+ # group : object oriented
5
+ # --
6
+ def ${ 1 :name } (self$2 ):
7
+ \"\"\" $3
8
+ ${ 2 :$ (python-args-to-docstring) }
9
+ \"\"\"
10
+ $0
You can’t perform that action at this time.
0 commit comments