diff options
Diffstat (limited to '2022/talks/python.md')
-rw-r--r-- | 2022/talks/python.md | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/2022/talks/python.md b/2022/talks/python.md new file mode 100644 index 00000000..410b1368 --- /dev/null +++ b/2022/talks/python.md @@ -0,0 +1,69 @@ +[[!meta title="Short hyperlinks to Python docs"]] +[[!meta copyright="Copyright © 2022 Eduardo Ochs"]] +[[!inline pages="internal(2022/info/python-nav)" raw="yes"]] + +<!-- Initially generated with emacsconf-generate-talk-page and then left alone for manual editing --> +<!-- You can manually edit this file to update the abstract, add links, etc. ---> + + +# Short hyperlinks to Python docs +Eduardo Ochs + +[[!inline pages="internal(2022/info/python-before)" raw="yes"]] + +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](https://docs.python.org/3/tutorial/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](http://angg.twu.net/eev-current/eev-rstdoc.el.html) +– 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 [this +page](http://angg.twu.net/emacsconf2022-py.html). For a translation of the Python tutorial +to a format that has only executable examples and elisp hyperlinks, +see [this](http://angg.twu.net/e/python.e.html#tut-numbers). + + + +[[!inline pages="internal(2022/info/python-after)" raw="yes"]] + +[[!inline pages="internal(2022/info/python-nav)" raw="yes"]] + +[[!taglink CategoryPython]] |