]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/rstdoc.el
emacs: use lexical-bindings in all libraries
[notmuch] / emacs / rstdoc.el
index 2225aefc023a2a1776f31c53332551965952a91e..c7c130154a582841b084343f38787431e0bbe77a 100644 (file)
@@ -1,4 +1,4 @@
-;;; rstdoc.el --- help generate documentation from docstrings -*-lexical-binding: t-*-
+;;; rstdoc.el --- help generate documentation from docstrings  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2018 David Bremner
 
@@ -24,7 +24,6 @@
 ;;
 
 ;;; Commentary:
-;;
 
 ;; Rstdoc provides a facility to extract all of the docstrings defined in
 ;; an elisp source file. Usage:
 
 ;;; Code:
 
-(provide 'rstdoc)
-
 (defun rstdoc-batch-extract ()
-  "Extract docstrings to and from the files on the command line"
+  "Extract docstrings to and from the files on the command line."
   (apply #'rstdoc-extract command-line-args-left))
 
 (defun rstdoc-extract (in-file out-file)
-  "Write docstrings from IN-FILE to OUT-FILE"
+  "Write docstrings from IN-FILE to OUT-FILE."
   (load-file in-file)
   (let* ((definitions (cdr (assoc (expand-file-name in-file) load-history)))
+        (text-quoting-style 'grave)
         (doc-hash (make-hash-table :test 'eq)))
     (mapc
      (lambda (elt)
 
 (defun rstdoc--insert-docstring (symbol docstring)
   (insert (format "\n.. |docstring::%s| replace::\n" symbol))
-  (insert (replace-regexp-in-string "^" "    " (rstdoc--rst-quote-string docstring)))
+  (insert (replace-regexp-in-string "^" "    "
+                                   (rstdoc--rst-quote-string docstring)))
   (insert "\n"))
 
 (defvar rst--escape-alist
-  '( ("\\\\='" . "\\\\'")
-     ("\\([^\\]\\)'" . "\\1`")
-     ("^[[:space:]\t]*$" . "|br|")
-     ("^[[:space:]\t]" . "|indent| "))
+  '( ("\\\\='" . "\001")
+     ("`\\([^\n`']*\\)[`']" . "\002\\1\002") ;; good enough for now...
+     ("`" . "\\\\`")
+     ("\001" . "'")
+     ("\002" . "`")
+     ("^[[:space:]]*$" . "|br|")
+     ("^[[:space:]]" . "|indent| "))
     "list of (regex . replacement) pairs")
 
 (defun rstdoc--rst-quote-string (str)
@@ -82,4 +84,6 @@
        (replace-match (cdr pair))))
     (buffer-substring (point-min) (point-max))))
 
+(provide 'rstdoc)
+
 ;;; rstdoc.el ends here