summaryrefslogtreecommitdiff
path: root/lisp/python-custom.el
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew.kosarek@vention.cc>2023-03-26 08:26:45 -0400
committerMatthew Kosarek <matthew.kosarek@vention.cc>2023-03-26 08:26:45 -0400
commit8a9b9d83d17ccd59bbefe2da3cd2e79c0d363025 (patch)
tree4b24cf552a27808ee51786062563188b76ebd9cd /lisp/python-custom.el
parent371b1723f317f56dcc010f47e5f456315fbd236f (diff)
Improvements to org-mode and performance
Diffstat (limited to 'lisp/python-custom.el')
-rw-r--r--lisp/python-custom.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/python-custom.el b/lisp/python-custom.el
index 432ad48..10c4cfc 100644
--- a/lisp/python-custom.el
+++ b/lisp/python-custom.el
@@ -9,5 +9,30 @@
:hook
((python-mode . eglot-ensure)))
+(defun python-args-to-google-docstring (text &optional make-fields)
+ "Return a reST docstring format for the python arguments in yas-text."
+ (let* ((indent (concat "\n" (make-string (current-column) 32)))
+ (args (python-split-args text))
+ (nr 0)
+ (formatted-args
+ (mapconcat
+ (lambda (x)
+ (concat " " (nth 0 x)
+ (if make-fields (format " ${%d:arg%d}" (cl-incf nr) nr))
+ (if (nth 1 x) (concat " \(default " (nth 1 x) "\)"))))
+ args
+ indent)))
+ (unless (string= formatted-args "")
+ (concat
+ (mapconcat 'identity
+ (list "" "Args:" formatted-args)
+ indent)
+ "\n"))))
+
+(use-package yasnippet
+ :ensure t
+ :config
+ (yas-global-mode 1))
+
(provide 'python-custom)
;;; python-custom.el ends here