Subject: bug#6224: 23.1; last-command docstring "multiple displays" info node link

From: Kevin Ryde <[email-masked]>
Date: Thu, 20 May 2010 10:32:45 +1000

Juri Linkov <[email-masked]> writes:
>
> BTW, do you have a command that automatically checks for broken links
> in docstrings?

:-)  I threw down a couple of lines the other day

(defun my-emacs-info-xref-docstrings (filename-list)
  (require 'info-xref)
  (require 'lisp-mnt)
  (require 'help-mode)
  (dolist (filename filename-list)
    (lm-with-file filename
      (goto-char (point-min))
      (while (re-search-forward help-xref-info-regexp nil t)
        (let ((match (match-string 0))
              (node  (match-string 2)))
          (save-match-data ;; for the while loop
            (unless (string-match "\\`(" node)
              (setq node (concat "(emacs)" node)))
            (setq match (replace-regexp-in-string "\n" " " match))
            (setq node (replace-regexp-in-string "\n" " " node))
            (unless (or (string-match "%" node)
                        (info-xref-goto-node-p node))
              (lwarn 'emacs-info-xref-docstrings 'warning
                     "\n  %s:\n  no such node: %S"
                     filename match))))))))

to be used as say

(my-emacs-info-xref-docstrings (file-expand-wildcards "/down/emacs/src/*.c"))

or on your whole load-path

(progn
  (kill-buffer (get-buffer-create "*Warnings*"))
  (require 'cl)
  (dolist (dir load-path)
    (let ((lst (file-expand-wildcards (concat dir "/*.elc"))))
      (dolist (el (file-expand-wildcards (concat dir "/*.el")))
        (setq lst (remove (concat el "c") lst))
        (push el lst))
      (my-emacs-info-xref-docstrings lst))))

It picked up a typo in one of my own files.  I'm thinking of working it
up into a presentable form and adding to my info-xref.el (which is in
emacs).

I started with mapatoms and getting each `documentation', but a grep
through the .el doesn't load up lots of strings and can be applied to
packages without loading them.