What is it?
sphinx-doc is an emacs minor mode for inserting docstring skeleton
for Python functions and methods. The structure of the docstring is as
per the requirement of the
Sphinx documentation generator.
This package can be installed from
MELPA. To do so, run
M-x package-list-packages, then search for "sphinx-doc". Mark it with
and finally press
x to install.
To install manually, download and copy the
somewhere in the load path.
Add the following line to your
.emacs (or the equivalent config
(add-hook 'python-mode-hook (lambda () (require 'sphinx-doc) (sphinx-doc-mode t)))
This will enable the
sphinx-doc-mode and bind the interactive
Inside a Python file, move the cursor to some function/method
definition and hit
C-c M-d (see gif demo below).
- When calling the function interactively, if the cursor is not on the
head of a function definition (ie. the keyword
def, function name or the parenthesized list of the formal parameters) it either shows a "search failed" message in the minibuffer or inserts documentation for a valid function definition closer to the current line! Although both behaviours are quite harmless, it's annoying and definitely needs to be fixed. Patches welcome!
The autodoc extension needs to be enabled for the sphinx instance in order to generate documentation from the docstrings.