Title: Short hyperlinks to Python docs
Intended duration: 5 minutes
Abstract:
If we have a local copy of the Python docs installed then it is
easy to define the three hyperlink functions in the Python program
below,
# (find-pydoc "tutorial/classes")
# (find-pydocw "tutorial/classes")
# (find-pydocr "tutorial/classes")
class MyVector:
def __init__(v, x, y):
v.x = x
v.y = y
|
such that each one expands its argument in the right way, and the
first one opens the local URL file:///usr/share/doc/python3.9-doc/html/tutorial/classes.html in the
browser, the second one opens https://docs.python.org/3/tutorial/classes.html, and the third one
opens the RST source of those HTML pages in Emacs: the file /<rstsourcedir>/tutorial/classes.rst.txt.
The docs for Python are designed to be navigated in a browser.
Suppose that we start on the page classes.html above,
follow a couple of hyperlinks, and then we find this other page that,
ahem, is very interesting and important and we need to have
hyperlinks to:
https://docs.python.org/3/reference/datamodel.html#object.__init__
The most obvious way to create elisp hyperlinks to that page is to
copy its URL to Emacs, edit it by hand to produce a (find-pydoc
...)
hyperlink, duplicate that hyperlink twice, and add a "w
"
and a "r
" into the right places... but this is not very
practical.
In this presentation I will show a practical way to handle that. It
is a new module of eev -- eev-rstdoc.el --
that performs both the expansions needed by find-pydoc{,w,r}
and
the "shrinkings" that convert URLs and filenames to short hyperlinks.
Eev-rstdoc.el comes with three "families" of hyperlinks, expansions,
and shrinkings: one for Python docs, one for SymPy, and one for
MatPlotLib. It is easy to add new families, and the parameters for
expansion and shrinking in each family are easy to configure.
For more info see the comments in eev-rstdoc.el. For a
translation of the Python tutorial to a format that has only
executable examples and elisp hyperlinks, see this.
Note that youtube always converts my videos to a format that is
blurry at some points. You can download a local copy of the original
video, with subtitles, with the two "wget"s below: