175 |
(defun help-add-fundoc-usage (doc arglist) |
(defun help-add-fundoc-usage (doc arglist) |
176 |
"Add the usage info to the docstring DOC. |
"Add the usage info to the docstring DOC. |
177 |
If DOC already has a usage info, then just return DOC unchanged. |
If DOC already has a usage info, then just return DOC unchanged. |
178 |
The usage info is built from ARGLIST. DOC can be nil." |
The usage info is built from ARGLIST. DOC can be nil. |
179 |
|
ARGLIST can also be nil or a string of the form \"(fun ARG1 ARG2 ...)\"." |
180 |
(unless (stringp doc) (setq doc "Not documented")) |
(unless (stringp doc) (setq doc "Not documented")) |
181 |
(if (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) |
(if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) (not arglist)) |
182 |
doc |
doc |
183 |
(format "%s%s%s" doc |
(format "%s%s%s" doc |
184 |
(if (string-match "\n?\n\\'" doc) |
(if (string-match "\n?\n\\'" doc) |
185 |
(if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "") |
(if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "") |
186 |
"\n\n") |
"\n\n") |
187 |
(help-make-usage 'fn arglist)))) |
(if (and (stringp arglist) |
188 |
|
(string-match "\\`([^ ]+\\(.*\\))\\'" arglist)) |
189 |
|
(concat "(fn" (match-string 1 arglist) ")") |
190 |
|
(help-make-usage 'fn arglist))))) |
191 |
|
|
192 |
(defun help-function-arglist (def) |
(defun help-function-arglist (def) |
193 |
;; Handle symbols aliased to other symbols. |
;; Handle symbols aliased to other symbols. |