Skip to content

Commit

Permalink
optionally auto fill paragraphs (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis authored Jul 25, 2023
1 parent 935e6cb commit 5cb26db
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# numpydoc.el NEWS -- history of user visible changes

## Unreleased
## 0.9 (July 24, 2023)

...
### Changes

- Add new `defcustom`: `numpydoc-auto-fill-paragraphs`, which when set
to `t` (the default) will enable automatic paragraph filling for
(somewhat) long descriptions.
([#16](https://github.com/douglasdavis/numpydoc.el/pull/16)).

## 0.8 (March 20, 2023)

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ RET numpydoc</kbd>
All function parameters with names listed here will be ignored
when generating a docstring.
</dd>
<dt>numpydoc-auto-fill-paragraphs</dt>
<dd>
If <code>t</code> text that is inserted in a prompt will be
automatically paragraph-filled.
</dd>
</dl>

## Examples
Expand Down
18 changes: 14 additions & 4 deletions numpydoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; Maintainer: Doug Davis <[email protected]>
;; URL: https://github.com/douglasdavis/numpydoc.el
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Version: 0.8
;; Version: 0.9
;; Package-Requires: ((emacs "25.1") (s "1.12.0") (dash "2.18.0"))
;; Keywords: convenience

Expand Down Expand Up @@ -133,6 +133,13 @@ when generating a docstring."
:group 'numpydoc
:type '(repeat string))

(defcustom numpydoc-auto-fill-paragraphs t
"Flag to control automatic paragraph filling.
If set to t text that is inserted in a prompt will be automatically
paragraph-filled."
:group 'numpydoc
:type 'boolean)

;;; package implementation code.

(cl-defstruct numpydoc--def
Expand Down Expand Up @@ -391,7 +398,8 @@ This function assumes the cursor to be in the function body."
(unless (string-empty-p ld)
(insert "\n")
(numpydoc--insert indent ld)
(numpydoc--fill-last-insertion)
(when numpydoc-auto-fill-paragraphs
(numpydoc--fill-last-insertion))
(insert "\n")))
(insert "\n")
(numpydoc--insert indent tmpl)
Expand Down Expand Up @@ -429,7 +437,8 @@ This function assumes the cursor to be in the function body."
element))
tmpd))))
(numpydoc--insert indent desc)
(numpydoc--fill-last-insertion)
(when numpydoc-auto-fill-paragraphs
(numpydoc--fill-last-insertion))
(insert "\n")))

(defun numpydoc--insert-parameters (indent fnargs)
Expand Down Expand Up @@ -466,7 +475,8 @@ This function assumes the cursor to be in the function body."
(if (numpydoc--prompt-p)
(read-string "Description for return: ")
tmpr)))
(numpydoc--fill-last-insertion)
(when numpydoc-auto-fill-paragraphs
(numpydoc--fill-last-insertion))
(insert "\n"))))

(defun numpydoc--insert-exceptions (indent fnexcepts)
Expand Down

0 comments on commit 5cb26db

Please sign in to comment.