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
Migrate docs to Sphinx + MyST #285
Conversation
3db3087
to
b851862
Compare
* Add [source] links Fix broken admonition in contributing.md Use ::: for reST items Document proxies Update build and publish scripts Simplify conf.py
462b103
to
721fa36
Compare
For some reason I'm not able to get the Edit: I found where that comes from. We're forcing That means I was able to make the |
This is ready for review, I'm quite happy about this. @tomchristie Any thoughts on this? I know the "consistency of tooling across Encode" argument will certainly pop in your mind. :-) Do you feel like playing with this based on the hints I gave, see how it all works in the day-to-day development process? There's not much really different from MkDocs as far as the writing experience goes, except that |
I like this 😄. The output looks really good and you've written a really clear explanation of everything that's going on here. To me the most controversial thing is that the markup language is kind of a weird mix. The main docs are markdown still, but then the Sphinx-specific stuff looks more like RST, and docstrings become a lot more like RST. You've explained why this is, I'm not sure much can be done about it, and I think it's probably worth the trade-offs. |
Okay, so the docs do looks pretty great. I've not downloaded and tried it out locally yet, that's something I want to do but don't have the time today.
I think we really do want the improved API Docs this gives us, so either we ought to be considering this, or else weighing up what work we'd need to put in to get MkDocs up to an equivalent in that area. |
:::{eval-rst} | ||
.. autoclass:: httpcore.PlainByteStream | ||
:show-inheritance: | ||
:noindex: |
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.
Curious - what is :noindex:
here, and why on this class in particular?
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.
We show this class two times, once for the sync API, once for the async API. I figured it's fine, except showing them twice would make Sphinx index them twice, which raised a warning hinting to add :noindex:
.
The maximum number of connections to allow before closing keep-alive | ||
connections. | ||
http2: | ||
Enable HTTP/2 support. |
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.
Have to say, I do prefer the style here after this change.
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.
Same!
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.
@florimondmanca I think I'm probably happy to leave this one up to you.
It's a pretty difficult set of tradeoffs, but looking at the URLLib3 docs I really like how it can look with a little bit of nice branding etc thrown it.
The API documentation is clearer, for sure. That's a massive win.
Areas that'd be interesting to think about...
- What would we need to do to get versioned docs?
- What would we need to do to get internationalised docs, and how does that work with the Furo theme?
- What (if anything) would we gain by hosting on ReadTheDocs?
- I'm not necessarily against switching to RST for the documentation. Not that big of a deal perhaps.
I'll chime in for two points you raised: versioned docs would go hand in hand with hosting on RTD very easily. They allow for building based on Git tags. Commonly that means using two versions: |
I imagine you meant Furo. Everything (except RTL) is purely handled by Sphinx's build pipeline, and doesn't need any additional support on the theme. I don't know of any Sphinx theme that supports RTL out-of-the-box but I do plan to add this in Furo and set stuff up in sphinx-basic-ng, so that future themes that derive from it; won't have this problem. :) https://jareddillard.com/blog/documentation-internationalization-using-sphinx-and-zanata is something I got linked to recently on this topic.
ReadTheDocs. Host it there, and they'll give you the overlay for versioning your docs.
Answered above. :) |
Oops - typo 🤪 |
Short. Yup I'm okay with this, if and when @florimondmanca is. The improvement in the API docs and the interlinking is motivation enough. |
Happy with how this is turning out! I'll update the PR and ready to merge afterwards. :-) |
be4804f
to
7f9637d
Compare
Merged, and just deployed docs via:
See: b0fb17d 👍 |
Took some time to speak with Eric Holscher of ReadTheDocs about getting us hosted there, in particular wrt. managing sponsorships etc. Example of hosting it up on RTD, along with a sidebar ad demo'ing that we'd be able to manage our sponsorship placements... |
Ah, a custom publisher! Neat! |
Latest docs deployments have been failing. https://github.com/encode/httpcore/actions/workflows/publish.yml Not looked into it yet. |
Seems to be a git-related issue. |
Refs encode/httpx#1220
There are pending discussions on "MkDocs vs Sphinx" for HTTPX.
This PR goes ahead and experiments with migrating to modern Sphinx for HTTPCore.
This is a fully functional PR. I find the result so much better from a reader experience perspective that I went ahead and deployed, see https://www.encode.io/httpcore/.
Preview
Pieces
sphinx-autobuild
: "watch" behavior for thescripts/docs serve
script.sphinx.ext.autodoc
: API autodocdescription
mode so type hints show in param descriptions (similarly to our ad-hoc style) rather than in signatures (which I find unreadable).sphinx.ext.viewcode
: automatic[source]
links in API reference and source pagesghp-import
: GitHub Pages deployment (used by MkDocs too)Some resources I used to help me set things up:
autodoc
and cross-references.Highlights
We now get the following:
What changed in the development workflow:
''code''
(double backticks), rather than'code'
(single backtick), and code fences should be written as indented code preceded by a line ending with::
(seeExample::
in_bytestreams.py
).mkautodoc
blocks such as::: mkautodoc
, we now have to use MyST-Parser special:::{directive}
style combined with Sphinx directive contents inside it. It's a bit odd at first, but it makes sense. MyST supports reStructuredText things like refs in MD-friendly forms, eg class references can be done via[SomeClass](httpcore.SomeClass)
(regular links).What DID NOT change:
scripts/docs serve
andscripts/docs gh-deploy
work the same way they did when usingmkdocs
. To deploy to GH Pages, we invoke ghp-import directly (MkDocs'gh-deploy
is a wrapper around that) in the shell script. The resulting script remains pretty lightweight. :-)