Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make parameter type descriptions optional #5

Merged
merged 3 commits into from
May 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@ numpydoc.el NEWS -- history of user visible changes
* Unreleased

** Changes
TBD

*** Added new defcustom: numpydoc-insert-paramter-types
New variable controls whether the type hint is added to each argument
in the parameters block (default is t).

* 0.2.0 (Mar 5, 2021)

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -89,12 +89,19 @@ See inside Emacs with <kbd>M-x customize-group RET numpydoc</kbd>
</dd>
<dt>numpydoc-insert-examples-block</dt>
<dd>
If <code>t</code> an Examples block will be added to the docstring.
If <code>t</code> (the default) an Examples block will be added to
the docstring.
</dd>
<dt>numpydoc-insert-parameter-types</dt>
<dd>
If <code>t</code> (the default) type hints from the function
signature will be used to add a type to each argument in the
Parameters blocks of the docstring.
</dd>
<dt>numpydoc-insert-raises-block</dt>
<dd>
If <code>t</code> a Raises bock will be added to the docstring if
exceptions are detected in the function body.
If <code>t</code> (the default) a Raises bock will be added to the
docstring if exceptions are detected in the function body.
</dd>
<dt>numpydoc-template-short</dt>
<dd>
20 changes: 14 additions & 6 deletions numpydoc.el
Original file line number Diff line number Diff line change
@@ -84,6 +84,11 @@ When nil, template text will be inserted."
:group 'numpydoc
:type 'boolean)

(defcustom numpydoc-insert-parameter-types t
"Flag to control if Parameter types are inserted based on type hints."
:group 'numpydoc
:type 'boolean)

(defcustom numpydoc-insert-raises-block t
"Flag to control if the Raises section is inserted.
This section will only be inserted if the flag is on and the function
@@ -367,12 +372,15 @@ This function assumes the cursor to be in the function body."
(let ((tp type)
(tmpt (cond ((numpydoc--yas-p) numpydoc--yas-replace-pat)
(t numpydoc-template-type-desc))))
(unless tp
(setq tp (if (numpydoc--prompt-p)
(read-string (format "Type of %s: "
name))
tmpt)))
(numpydoc--insert indent (format "%s : %s\n" name tp))))
(if numpydoc-insert-parameter-types
(progn
(unless tp
(setq tp (if (numpydoc--prompt-p)
(read-string (format "Type of %s: "
name))
tmpt)))
(numpydoc--insert indent (format "%s : %s\n" name tp)))
(numpydoc--insert-item indent name))))

(defun numpydoc--insert-item-desc (indent element)
"Insert ELEMENT parameter description at level INDENT."