mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
format args in docstrings as =code=, not /italic/
This commit is contained in:
parent
860858de42
commit
46c378d738
@ -34,12 +34,15 @@
|
|||||||
(flet ((concat-lines (&rest lines)
|
(flet ((concat-lines (&rest lines)
|
||||||
(mapconcat #'identity lines "\n")))
|
(mapconcat #'identity lines "\n")))
|
||||||
(let* ((stars (make-string level ?*))
|
(let* ((stars (make-string level ?*))
|
||||||
|
(args (and (fboundp symbol)
|
||||||
|
(mapcar #'symbol-name (help-function-arglist symbol t))))
|
||||||
(heading (cond ((fboundp symbol)
|
(heading (cond ((fboundp symbol)
|
||||||
(format "%s =%s= (%s)"
|
(format
|
||||||
stars
|
"%s =%s= (%s)" stars symbol
|
||||||
symbol
|
(mapconcat (lambda (a)
|
||||||
(mapconcat #'symbol-name
|
(format (if (string-prefix-p "&" a)
|
||||||
(help-function-arglist symbol t) " ")))
|
"/%s/" "=%s=") a))
|
||||||
|
args " ")))
|
||||||
(t
|
(t
|
||||||
(format "%s =%s=\n" stars symbol))))
|
(format "%s =%s=\n" stars symbol))))
|
||||||
(after-heading
|
(after-heading
|
||||||
@ -57,12 +60,17 @@
|
|||||||
(format "*WARNING*: no symbol named =%s=" symbol)))
|
(format "*WARNING*: no symbol named =%s=" symbol)))
|
||||||
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
||||||
(case-fold-search nil))
|
(case-fold-search nil))
|
||||||
;; do some transformations on the body: FOO becomes /foo/ and
|
;; do some transformations on the body:
|
||||||
|
;; ARG becomes =arg=
|
||||||
|
;; FOO becomes /foo/
|
||||||
;; `bar' becomes [[#bar][=bar=]]
|
;; `bar' becomes [[#bar][=bar=]]
|
||||||
(setq body (replace-regexp-in-string
|
(setq body (replace-regexp-in-string
|
||||||
"[A-Z][A-Z-]+" #'(lambda (match)
|
"[A-Z][A-Z-]+" #'(lambda (match)
|
||||||
(format "/%s/" (downcase match)))
|
(setq match (downcase match))
|
||||||
body)
|
(format (if (member match args)
|
||||||
|
"=%s=" "/%s/")
|
||||||
|
match))
|
||||||
|
body t)
|
||||||
body (replace-regexp-in-string "`\\([a-z-]+\\)'" #'(lambda (match)
|
body (replace-regexp-in-string "`\\([a-z-]+\\)'" #'(lambda (match)
|
||||||
(let* ((name (downcase (match-string 1 match)))
|
(let* ((name (downcase (match-string 1 match)))
|
||||||
(sym (intern name)))
|
(sym (intern name)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user