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

optionally auto fill paragraphs #16

Merged
merged 5 commits into from
Jul 25, 2023
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
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)

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 14 additions & 4 deletions numpydoc.el
Original file line number Diff line number Diff line change
@@ -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

@@ -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
@@ -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)
@@ -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)
@@ -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)