Jon Waltman avatar Jon Waltman committed 8e124d6

Update regexps due to changes in how Sphinx formats indexes

Comments (0)

Files changed (2)

 
 If you want to build the Python documentation yourself, follow these steps:
 
-#. Download and install the latest version of Sphinx (virtualenv may be useful)::
+#. Download and install the development version of Sphinx (virtualenv
+   may be useful)::
 
-      hg clone https://bitbucket.org/birkenfeld/sphinx
-      cd sphinx
+      hg clone https://bitbucket.org/jonwaltman/sphinx-info
+      cd sphinx-info
       sudo python setup.py install
 
 #. Install some libraries::
 #. Modify the configuration file ``conf.py``::
 
       cd Python-2.7.1/Doc
-      cat >> conf.py <<'EOF'
+      cat >> conf.py
 
       texinfo_documents = [
           ('contents', 'python', 'Python Documentation', _stdauthor,
-           "Python", "The Python Documentation", "Software Development"),
+           'Python', 'The Python Documentation', 'Software Development'),
       ]
-      EOF
+
 
 #. Generate the Texinfo::
 
  :mode 'python-mode
  :parse-rule 'pydoc-info-python-symbol-at-point
  :doc-spec
- '(("(python)Index" pydoc-info-lookup-transform-entry)))
+ '(("(python)Python Module Index" pydoc-info-lookup-transform-entry)
+   ("(python)Index" pydoc-info-lookup-transform-entry)))
 
 (defun pydoc-info-python-symbol-at-point ()
   (with-syntax-table python-dotty-syntax-table
 
 (defun pydoc-info-lookup-transform-entry (item)
   "Transform a Python index entry to a help item."
-  (cond
-   ;; keyword; foo --> foo
-   ;; statement; foo --> foo
-   ((string-match "\\`\\(keyword\\|statement\\);? \\([[:alnum:]_]+\\)" item)
-    (replace-regexp-in-string " " "." (match-string 2 item)))
+  (let* ((py-re "\\([[:alnum:]_.]+\\)(?)?"))
+    (cond
+     ;; keyword; foo --> foo
+     ;; statement; foo --> foo
+     ((string-match (concat "\\`\\(keyword\\|statement\\);? " py-re) item)
+      (replace-regexp-in-string " " "." (match-string 2 item)))
 
-   ;; foo [built-in ...] --> foo
-   ((string-match "\\`\\([[:alnum:]_ ]+\\) \\[built-in .+\\]" item)
-    (replace-regexp-in-string " " "." (match-string 1 item)))
+     ;; foo (built-in ...) --> foo
+     ((string-match (concat "\\`" py-re " (built-in .+)") item)
+      (replace-regexp-in-string " " "." (match-string 1 item)))
 
-   ;; foo bar [module] --> foo.bar
-   ((string-match "\\`\\([[:alnum:]_ ]+\\) \\[module\\]" item)
-    (replace-regexp-in-string " " "." (match-string 1 item)))
+     ;; foo.bar (module) --> foo.bar
+     ((string-match (concat "\\`" py-re " (module)") item)
+      (replace-regexp-in-string " " "." (match-string 1 item)))
 
-   ;; baz [in module foo bar] --> foo.bar.baz
-   ((string-match "\\`\\([[:alnum:]_ ]+\\) \\[in module \\(.+\\)\\]" item)
-    (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
-                                              (match-string 1 item))))
-   ;; Bar [class in foo bar] --> foo.bar.Bar
-   ((string-match "\\`\\([[:alnum:]_ ]+\\) \\[class in \\(.+\\)\\]" item)
-    (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
-                                              (match-string 1 item))))
-   ;; bar [foo Foo method] --> foo.Foo.bar
-   ((string-match
-     "\\`\\([[:alnum:]_ ]+\\) \\[\\(.+\\) \\(method\\|attribute\\)\\]" item)
-    (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
-                                              (match-string 1 item))))
-   (t
-    item)))
+     ;; baz (in module foo.bar) --> foo.bar.baz
+     ((string-match (concat "\\`" py-re " (in module \\(.+\\))") item)
+      (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
+                                                (match-string 1 item))))
+     ;; Bar (class in foo.bar) --> foo.bar.Bar
+     ((string-match (concat "\\`" py-re " (class in \\(.+\\))") item)
+      (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
+                                                (match-string 1 item))))
+     ;; bar (foo.Foo method) --> foo.Foo.bar
+     ((string-match
+       (concat "\\`" py-re " (\\(.+\\) \\(method\\|attribute\\))") item)
+      (replace-regexp-in-string " " "." (concat (match-string 2 item) " "
+                                                (match-string 1 item))))
+     (t
+      item))))
 
 (provide 'pydoc-info)
 ;;; pydoc-info.el ends here
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.