Add docstrings

This commit is contained in:
Ohad Livne 2025-06-04 22:45:51 +03:00
parent 9a40551ef5
commit 2f003402d3
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D

View file

@ -151,13 +151,14 @@
(use-package poetry) (use-package poetry)
(defun load-python-env () (defun load-python-env ()
"Set up the Python IDE in the current project" "Set up the Python IDE in the current project."
(interactive) (interactive)
(progn (progn
(poetry-venv-workon) (poetry-venv-workon)
(lsp))) (lsp)))
(defun symbols-at-point () (defun symbols-at-point ()
"Utility function to get the hierarchy of the object at point."
(let* ((lsp--document-symbols-request-async t) (let* ((lsp--document-symbols-request-async t)
(symbols (lsp--get-document-symbols)) (symbols (lsp--get-document-symbols))
(symbols-hierarchy (lsp--symbols->document-symbols-hierarchy symbols))) (symbols-hierarchy (lsp--symbols->document-symbols-hierarchy symbols)))
@ -166,6 +167,7 @@
symbols-hierarchy))) symbols-hierarchy)))
(defun python-test-at-point () (defun python-test-at-point ()
"Use LSP to identify the test at point."
(let ((symbols (symbols-at-point))) (let ((symbols (symbols-at-point)))
(pcase symbols (pcase symbols
(`((,class "Class") (,method "Method") . ,_) (`((,class "Class") (,method "Method") . ,_)
@ -176,11 +178,14 @@
(_ ())))) (_ ()))))
(defun python-test-name-at-point () (defun python-test-name-at-point ()
"Create a unittest-compatible descriptor for the test at point."
(let* ((path (mapcar #'substring-no-properties lsp-headerline--path-up-to-project-segments)) (let* ((path (mapcar #'substring-no-properties lsp-headerline--path-up-to-project-segments))
(filename (f-no-ext (f-filename (buffer-file-name))))) (filename (f-no-ext (f-filename (buffer-file-name)))))
(string-join (append path (list filename) (python-test-at-point)) "."))) (string-join (append path (list filename) (python-test-at-point)) ".")))
(defun python-run-test-at-point (debug) (defun python-run-test-at-point (debug)
"Identify and run the test at point.
When DEBUG is set, run the test in the debugger."
(interactive "P") (interactive "P")
(let ((python (or (executable-find "python3") (let ((python (or (executable-find "python3")
(executable-find "python"))) (executable-find "python")))