Skip to content

Commit fcbdeca

Browse files
committedMar 5, 2021
Enforce documentation of argument types; adds another defcustom.
1 parent e0dff37 commit fcbdeca

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
 

‎README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# numpydoc.el
22

33
[![MELPA](https://melpa.org/packages/numpydoc-badge.svg)](https://melpa.org/#/numpydoc)
4-
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
54
[![CI](https://github.com/douglasdavis/numpydoc.el/actions/workflows/ci.yml/badge.svg)](https://github.com/douglasdavis/numpydoc.el/actions/workflows/ci.yml)
65
[![builds.sr.ht status](https://builds.sr.ht/~ddavis/numpydoc.el/commits/.build.yml.svg)](https://builds.sr.ht/~ddavis/numpydoc.el/commits/.build.yml?)
76

@@ -108,6 +107,12 @@ See inside Emacs with <kbd>M-x customize-group RET numpydoc</kbd>
108107
description if <code>numpydoc-prompt-for-input</code> is
109108
<code>nil</code>.
110109
</dd>
110+
<dt>numpydoc-template-type-desc</dt>
111+
<dd>
112+
Template text that will be used for each function argument type
113+
description if <code>numpydoc-prompt-for-input</code> is
114+
<code>nil</code>.
115+
</dd>
111116
</dl>
112117

113118
## Examples

‎numpydoc.el

+18-3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ text, and below the Examples section."
9393
:group 'numpydoc
9494
:type 'string)
9595

96+
(defcustom numpydoc-template-type-desc "FIXME: Add type."
97+
"Template text for individual component type descriptions."
98+
:group 'numpydoc
99+
:type 'string)
100+
96101
;;; package implementation code.
97102

98103
(cl-defstruct numpydoc--def
@@ -329,6 +334,16 @@ This function assumes the cursor to be in the function body."
329334
(format "%s : %s\n" name type)
330335
(format "%s\n" name))))
331336

337+
(defun numpydoc--insert-item-and-type (indent name type)
338+
"Insert parameter with NAME and TYPE at level INDENT."
339+
(let ((tp type))
340+
(unless tp
341+
(setq tp (if numpydoc-prompt-for-input
342+
(read-string (format "Type of %s: "
343+
name))
344+
numpydoc-template-type-desc)))
345+
(numpydoc--insert indent (format "%s : %s\n" name tp))))
346+
332347
(defun numpydoc--insert-item-desc (indent element)
333348
"Insert ELEMENT parameter description at level INDENT."
334349
(let ((desc (concat (make-string 4 ?\s)
@@ -348,9 +363,9 @@ This function assumes the cursor to be in the function body."
348363
"Parameters\n"
349364
"----------\n")
350365
(dolist (element fnargs)
351-
(numpydoc--insert-item indent
352-
(numpydoc--arg-name element)
353-
(numpydoc--arg-type element))
366+
(numpydoc--insert-item-and-type indent
367+
(numpydoc--arg-name element)
368+
(numpydoc--arg-type element))
354369
(numpydoc--insert-item-desc indent
355370
(numpydoc--arg-name element)))))
356371

0 commit comments

Comments
 (0)
Please sign in to comment.