You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fdoc2md.el 832B

123456789101112131415161718192021
  1. ;;; -*- lexical-binding: t -*-
  2. ;;; fdoc2md.el -- Convert function documentation to markdown
  3. (defvar fdoc-replacements
  4. '(("`\\([^']+\\)'" . "`\\1`"))
  5. "A list of alists where the car is the search regular
  6. expression and the cdr is the replacement string.")
  7. (defun fdoc2md (func file)
  8. "Extract the documentation from FUNC and try to convert it to
  9. markdown then append it to FILE."
  10. (let ((doc (documentation func)))
  11. (mapc (lambda (re)
  12. (let ((start nil))
  13. (while (setq start (string-match (car re) doc
  14. (if start (match-end 0))))
  15. (setq doc (replace-match (cdr re) nil nil doc nil)))))
  16. fdoc-replacements)
  17. (with-temp-buffer
  18. (insert doc)
  19. (insert "\n")
  20. (append-to-file (point-min) (point-max) file))))