Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get Python documentation in Texinfo Info format?

Since Python 2.6, it seems the documentation is in the new reStructuredText format, and it doesn't seem very easy to build a Texinfo Info file out of the box anymore.

I'm an Emacs addict and prefer my documentation installed in Info.

Does anyone have Python 2.6 or later docs in Texinfo format? How did you convert them? Or, is there a maintained build somewhere out there?

I know I can use w3m or haddoc to view the html docs - I really want them in Info.

I've played with Pandoc but after a few small experiments it doesn't seem to deal well with links between documents, and my larger experiment - running it across all docs cat'ed together to see what happens - is still chugging along two days since I started it!

Two good answers

Highlighting two answers below, because SO won't allow me to accept both answers:

  • @wilfred-hughes: Installing from MELPA is the quickest way to get pre-build info into Emacs
  • @alioth: Building it yourself looks like it's a lot easier than when I asked this question in 2009
like image 931
Matt Curtis Avatar asked Jun 28 '09 13:06

Matt Curtis


People also ask

How do I get documentation in Python?

You can use help() function to display the documentation. or you can choose method. __doc__ descriptor. Eg: help(input) will give the documentation on input() method.

Which is the best documentation for Python?

Sphinx. Sphinx is far and away the most popular Python documentation tool. Use it. It converts reStructuredText markup language into a range of output formats including HTML, LaTeX (for printable PDF versions), manual pages, and plain text.

Does Python have documentation?

The Python language has a substantial body of documentation, much of it contributed by various authors. The markup used for the Python documentation is reStructuredText, developed by the docutils project, amended by custom directives and using a toolset named Sphinx to post-process the HTML output.


7 Answers

Jon Waltman http://bitbucket.org/jonwaltman/sphinx-info has forked sphinx and written a texinfo builder, it can build the python documentation (I've yet done it). It seems that it will be merged soon into sphinx.

Here's the quick links for the downloads (temporary):

  • http://dl.dropbox.com/u/1276730/python.info
  • http://dl.dropbox.com/u/1276730/python.texi

Steps to generate python doc in texinfo format:

Download the python source code

Download and install the sphinx-info package (in a virtualenv)

Enter in the Python/Doc directory from the python sources

Edit the Makefile, to the build target replace $(PYTHON) tools/sphinx-build.py with sphinx-build, then add this target to the makefile, pay attention, the space before echo is a TAB:

texinfo: BUILDER = texinfo
texinfo: build
    @echo
    @echo "Build finished. The Texinfo files are in _build/texinfo."
    @echo "Run \`make' in that directory to run these through makeinfo" \
          "(use \`make info' here to do that automatically)."

Edit the Python/Doc/conf.py adding:

texinfo_documents = [
    ('contents', 'python', 'Python Documentation', 'Georg Brandl',
     'Python', 'The Python Programming Language', 'Documentation tools',
     1),
]

Then run make texinfo and it should produce the texifile in the build/texinfo directory. To generate the info file run makeinfo python.texi

like image 149
pygabriel Avatar answered Oct 07 '22 17:10

pygabriel


I've packaged up the Python docs as a texinfo file.

If you're using Emacs with MELPA, you can simply install this with M-x package-install python-info.

like image 32
Wilfred Hughes Avatar answered Oct 07 '22 17:10

Wilfred Hughes


With no doubt it would be cool and challenging to generate the Python documentation on your particular Python version by yourself. Just follow EmacsWiki, or feel free to compile it locally (at Debian Jessy for Python3.4.2):

sudo apt-get install python3-sphinx
cd ~/Desktop
wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2rc1.tar.xz
tar -xf Python-3.4.2rc1.tar.xz
cd Python-3.4.2rc1/Doc/
sphinx-build -b texinfo -d build/doctrees . build/texinfo
# extra time to build
cd build/texinfo/
makeinfo python.texi
# extra time for convertation

I got this tree:

.                                                                                                                              
├── logging_flow.png                                                                                                           
├── Makefile                                                                                                                   
├── pathlib-inheritance.png                                                                                                    
├── python.info                                                                                                                
├── python.info-1                                                                                                              
├── python.info-10                                                                                                             
├── python.info-11                                                                                                             
├── python.info-12                                                                                                             
├── python.info-13                                                                                                             
├── python.info-14                                                                                                             
├── python.info-15                                                                                                             
├── python.info-16                                                                                                             
├── python.info-17                                                                                                             
├── python.info-18                                                                                                             
├── python.info-19                                                                                                             
├── python.info-2                                                                                                              
├── python.info-20                                                                                                             
├── python.info-21                                                                                                             
├── python.info-22                                                                                                             
├── python.info-23                                                                                                             
├── python.info-24                                                                                                             
├── python.info-25                                                                                                             
├── python.info-26                                                                                                             
├── python.info-27                                                                                                             
├── python.info-28                                                                                                             
├── python.info-29                                                                                                             
├── python.info-3                                                                                                              
├── python.info-30                                                                                                             
├── python.info-31                                                                                                             
├── python.info-32                                                                                                             
├── python.info-33                                                                                                             
├── python.info-34                                                                                                             
├── python.info-4                                                                                                              
├── python.info-5                                                                                                              
├── python.info-6                                                                                                              
├── python.info-7                                                                                                              
├── python.info-8                                                                                                              
├── python.info-9                                                                                                              
├── python.texi                                                                                                                
├── python-video-icon.png                                                                                                      
├── tulip_coro.png                                                                                                             
└── turtle-star.png

And now it is possible to review python documentation natively in Emacs by

C-u C-h i python-info RET

python-info is a filename (fourth in the tree above), and even to bookmark some arbitrary nodes for habitual and regular reviewing convenience.

like image 36
Alioth Avatar answered Oct 07 '22 17:10

Alioth


For those following this question in the hope of an answer, I found another rst2texinfo implementation which you might like to try:

http://bitbucket.org/jonwaltman/rst2texinfo/src

like image 25
Matt Curtis Avatar answered Oct 07 '22 18:10

Matt Curtis


Another "workaround" is to execute pydoc as suggested by Nikokrock directly in Emacs:

(defun pydoc (&optional arg)
  (interactive)
  (when (not (stringp arg))
    (setq arg (thing-at-point 'word)))

  (setq cmd (concat "pydoc " arg))
  (ad-activate-regexp "auto-compile-yes-or-no-p-always-yes")
  (shell-command cmd)
  (setq pydoc-buf (get-buffer "*Shell Command Output*"))
  (switch-to-buffer-other-window pydoc-buf)
  (python-mode)
  (ad-deactivate-regexp "auto-compile-yes-or-no-p-always-yes")
)
like image 44
wr. Avatar answered Oct 07 '22 17:10

wr.


Michael Ernst used to maintain Info formats of Python docs:

http://www.cs.washington.edu/homes/mernst/software/#python-info

You can try using his makefile and html2texi script to generate an updated version. Both are linked at the above URL. I'm not sure how well it works now (the last version was around 2001), but his script is well commented (grep for "python").

like image 25
ars Avatar answered Oct 07 '22 16:10

ars


Python docs are now generated using Sphynx framework. This framework does not have texinfo output format. Currently it has:

  1. HTML
  2. latex
  3. plain text

Maybe you can get what you want using the Latex output. With the text output you will lost the cross ref.

Personnaly I prefer using pydoc when I want textual output. With Vim I have a shorcut to call pydoc and open a window with the doc for the entity under my cursor...

like image 44
Nikokrock Avatar answered Oct 07 '22 18:10

Nikokrock