New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add hoverxref & codeautolink support. Various fixes #2968
base: master
Are you sure you want to change the base?
docs: add hoverxref & codeautolink support. Various fixes #2968
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2968 +/- ##
==========================================
- Coverage 99.63% 99.61% -0.02%
==========================================
Files 117 117
Lines 17593 17593
Branches 3173 3173
==========================================
- Hits 17528 17525 -3
- Misses 46 47 +1
- Partials 19 21 +2 |
Related issue: |
|
The hoverxref seems to be working excellently, but objects in examples don't seem to be clickable (i.e. the codeautolink part)? https://trio--2968.org.readthedocs.build/en/2968/reference-testing.html |
Thank you, @jakkdl, for adding the missing dependencies in the requirements file. I will review and confirm with you why the objects do not appear clickable. |
It appears that codeautolink requires explicitly marking code blocks as python code blocks, so this does not work: trio/docs/source/reference-core.rst Lines 252 to 258 in 96a5524
But this does (after adding In the simplest case, you can apply a timeout to a block of code:
.. code:: python
with trio.move_on_after(30):
result = await do_http_get("https://...")
print("result is", result)
print("with block finished") Skimming configuration and examples I don't find a way to configure the former to work, so will have to replace the syntax of all code blocks - but shouldn't be too bad with a regex search&replace. This does also add syntax highlighting in my editor, and in viewing the source on github. |
…mentation to use .. code::, and make the majority explicit what language (python, pycon, sh) they are in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vast majority of the diff is near identical, so I pointed out most points where anything is different.
docs/source/design.rst
Outdated
def call_the_thing(fn, *args, kwonly1, kwonly2, ...):: | ||
def call_the_thing(fn, *args, kwonly1, kwonly2, ...): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random typo I noticed when searching for ::$
docs/source/design.rst
Outdated
def call_the_thing(fn, *args):: | ||
.. code:: python | ||
|
||
def call_the_thing(fn, *args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and a second instance of invalid python syntax
docs/source/tutorial.rst
Outdated
function call that returns this weird "coroutine" object:: | ||
function call that returns this weird "coroutine" object: | ||
|
||
.. code:: pycon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pycon
is "python console"
docs/source/releasing.rst
Outdated
* push to PyPI:: | ||
* push to PyPI: | ||
|
||
.. code:: | ||
|
||
git clean -xdf # maybe run 'git clean -xdn' first to see what it will delete | ||
python3 -m build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any language highlighting that's relevant here, so made it a generic code block.
docs/source/reference-io.rst
Outdated
subshell, multiple layers of escaping can be needed: | ||
|
||
.. code:: sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shell
docs/source/reference-io.rst
Outdated
because CMD.EXE handles them differently from the MSVC runtime rules; in:: | ||
because CMD.EXE handles them differently from the MSVC runtime rules; in: | ||
|
||
.. code:: sh | ||
|
||
prog.exe "foo \"bar\" baz" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there might be some windows console identifier, but I just made it sh
/shrug
docs/source/conf.py
Outdated
codeautolink_global_preface = """ | ||
import trio | ||
from trio import * | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the code uses trio.xxxx
, maybe even all of it, but not much reason not to keep from trio import *
. Although it's plausible we should also import testing
/lowlevel
/etc, have not scoured the docs that thoroughly yet.
import asyncio, trio | ||
import asyncio | ||
import trio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know why this raised errors, or by what, but it gave
/home/h/Git/trio/docs/source/reference-lowlevel.rst: WARNING: Could not match transformation of `asyncio` on source lines 1-1
I noticed one file using .. code-block:: python3
if bool(int('5')):
print("hello world") Turns out github (or my editor) don't recognize python3 as a language directive for highlighting the rst source code .. code-block:: python
if bool(int('5')):
print("hello world") (No clue why, it works in normal code blocks, and is a valid identifier both according to linguist (used for GH code blocks) and pygments (used by RST)) After an unreasonable amount of digging I've finally figured out the difference between A trailing |
Fixes #1522