-
Notifications
You must be signed in to change notification settings - Fork 8
Adds defcustom numpydoc-newline-after-opening-quotes #20
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
base: main
Are you sure you want to change the base?
Conversation
Adds `numpydoc-newline-after-opening-quotes` as a custom boolean variable with a default of `t` to the `numpydoc` group. This is then used in `numpydoc--insert-short-and-long-desc` to conditionally insert a new line as per [validation rule GL01](https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks).
|
Wondering if I need to update/modify any tests on this for it to be merged? |
douglasdavis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is behavior changing for the package I'd prefer to keep the new defcustom as nil by default.
| (numpydoc--insert indent | ||
| (concat (make-string 3 numpydoc-quote-char) | ||
| (if numpydoc-newline-after-opening-quotes | ||
| "\n ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does numpydoc--insert with indent not take care of the extra spaces? (I haven't tested the code so I'm asking here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean indenting to align with the docstring indent i.e. there may be no need for the spaces after the carriage return?
| "\n ") | |
| "\n") |
Not sure, I'll check it out and report back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked this, if the spaces aren't there then the text isn't indented to align with the start of the """ so I think they are required, but appreciate there is likely a smarter way of doing this.
Looking at the code (not being very conversant in Emacs Lisp) it looks like its numpydoc--insert that is required.
I tried adding
| "\n ") | |
| "\n" | |
| (numpydoc--insert indent ld)) |
..without any success, insert Short Description was at the start of the line. Then I realised there is numpydoc--insert-short-and-long-desc defined right after numpydoc--insert which only takes indent as an argument so tried...
| "\n ") | |
| "\n" | |
| (numpydoc--insert-short-and-long-desc indent)) |
Next I tried placing it outside if the surrounding (if numpydoc-newline-afer-opening-quote-char "\n")
| "\n ") | |
| "\n") | |
| (numpydoc--insert-short-and-long-desc indent) |
...which didn't work either, it resulted in exceeding the nesting max-lisp-eval-depth, I think because that causes the function to be called recursively without any break-out clause!
Looking further down I see that the "Long description" I think the following...
(if (numpydoc--prompt-p)
(progn
(setq ld (read-string (concat "Long description "
"(or press return to skip): ")
nil nil "" nil)) ;; This captures the text to be inserted
(unless (string-empty-p ld)
(insert "\n")
(numpydoc--insert indent ld) ;; This inserts the value of ld
(when numpydoc-auto-fill-paragraphs ;; auto-fill/wrap paragraphs
(numpydoc--fill-last-insertion))
(insert "\n")))
(insert "\n")
(numpydoc--insert indent tmpl)
(insert "\n"))))So I tried using that as a template....
(numpydoc--insert indent
(concat (make-string 3 numpydoc-quote-char)
(if numpydoc-newline-after-opening-quotes
"\n")
(if (numpydoc--prompt-p)
(progn
(setq ld (read-string (format "Short description: ")
tmps))
(unless (string-empty-p ld)
(insert "\n")
(numpydoc--insert indent ld)
(when numpydoc-auto-fill-paragraphs
(numpydoc--fill-last-insertion))
(insert "\n")))
(insert "\n")
(make-string 3 numpydoc-quote-char))No dice, feel like I'm out of my depth here but keen to learn what it is I'm missing/not understanding.
Co-authored-by: Doug Davis <[email protected]>
Closes #19
Finally remembered to finish this off, sorry its taken so long.
Adds the suggested
numpydoc-newline-after-opening-quotesas a custom boolean variable with a default oft(as suggested) to thenumpydocgroup.This is then used in
numpydoc--insert-short-and-long-descto conditionally insert a new line as per validation rule GL01.