-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Add initial Sphinx docs #747
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #747 +/- ##
===========================================
- Coverage 87.85% 87.84% -0.01%
===========================================
Files 124 124
Lines 5393 5390 -3
Branches 430 430
===========================================
- Hits 4738 4735 -3
Misses 569 569
Partials 86 86
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
Sure, I just didn't have time to do it. |
@abhinavsingh looks like you didn't fully integrate RTD into this repo — I don't see checks reported in this PR. |
# This file is autogenerated by pip-compile with python 3.10 | ||
# To update, run: | ||
# | ||
# pip-compile --allow-unsafe --generate-hashes --output-file=docs/requirements.txt --strip-extras docs/requirements.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.
@abhinavsingh note that this file is auto-generated and is checked in for reproducibility purposes.
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.
Thank you, I'll spend sometime to try this out. I haven't used this option before, but I see where it's coming from. I have now about a dozen TODOs on my list, thanks to you :D
d2a1097
to
e3580b6
Compare
No worries, happy to help. |
Missed this comment
I see following, but may be because it's trying |
Also enabled |
b7962b3
to
c74c389
Compare
Yes, mkdocs is not Sphinx.
I think you could also add it to the branch protection settings. |
Especially taking into account that build is successful on RTD (https://readthedocs.org/projects/proxypy/builds/15307154/) and the preview is here https://proxypy--747.org.readthedocs.build/en/747/. |
This is awesome. I am tempted to take a pass at end-to-end doc string once again :) I am thinking of 2 edits to make the site more accessible:
Essentially, this is what user sees by default (expanded menu):
|
+1. I noticed the same, redundant header on every page. Will make a pass at it and push a fix. |
@abhinavsingh you don't need to customize the auto-generated private API pages. It's best to add more human-readable at separate pages (starting with splitting the README into several pages). On the second note, I recommend checking out the https://diataxis.fr framework — it is a set of principles for structuring the docs sections and other aspects of the content. And I recommend joining https://www.writethedocs.org/slack/ — it's a community of mostly tech writers but there are channels for Sphinx and Diataxis where you can ask questions and get insights about improving the docs. As for expanding or putting the Private API on top — don't. It's there mostly for convenience. Many sites hide it or don't create at all. You need to focus on adding more documents, once this is merged. The idea is that you'll add new document names to one of the ToC sections or create additional one at the top and that will show up above all other menu items. |
@@ -4,6 +4,8 @@ | |||
⚡ Fast • 🪶 Lightweight • 0️⃣ Dependency • 🔌 Pluggable • 😈 TLS interception • 🔒 DNS-over-HTTPS • 🔥 Poor Man's VPN • ⏪ Reverse & ⏩ Forward • 👮🏿 "Proxy Server" framework • 🌐 "Web Server" framework • ➵ ➶ ➷ ➠ "PubSub" framework • 👷 "Work" acceptor & executor framework | |||
</p> | |||
|
|||
[//]: # (DO-NOT-REMOVE-docs-badges-START) |
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.
@abhinavsingh these markers are referenced from docs/index.md
. They are used to include parts of the README on the front page, excluding the badges. It's enough for a demo now but you can make more and include things on other (sub)pages later.
@@ -969,7 +973,7 @@ response from the server. Start `proxy.py` as: | |||
--ca-signing-key-file ca-signing-key.pem | |||
``` | |||
|
|||
[![NOTE](https://img.shields.io/static/v1?label=MacOS&message=note&color=yellow)](https://github.com/abhinavsingh/proxy.py#flags) Also provide explicit CA bundle path needed for validation of peer certificates. See `--ca-file` flag. | |||
[![NOTE](https://img.shields.io/static/v1?label=MacOS&message=note&color=yellow)](https://github.com/abhinavsingh/proxy.py#user-content-flags) Also provide explicit CA bundle path needed for validation of peer certificates. See `--ca-file` flag. |
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.
This one is tricky. The #flags
anchor doesn't exist in HTML, it's navigated to via JS so the linkcheck builder cannot verify that the link is valid. All of the real anchors are prefixed, this is why this patch was needed.
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.
Thank you, I did notice this change and didn't understand the context. Makes sense coz sphinx kind of steals away ToC from the readme.
a client connection as work payload and hooks into the threadless | ||
event loop to handle the client connection. | ||
Example, :class:`~proxy.core.base.tcp_server.BaseTcpServerHandler` | ||
implements :class:`~proxy.core.acceptor.work.Work` protocol. It |
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.
@abhinavsingh the leading tilde means that only the last chunk Work
will be visible in HTML.
# The reST default role (used for this markup: `text`) to use for all | ||
# documents. | ||
# Ref: python-attrs/attrs#571 | ||
default_role = 'any' |
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.
@abhinavsingh this instructs Sphinx to link any text in single backticks to any role that has an object with that name. Practically, it allows you to identify forgotten syntax (Markdown mixup in RST). In RST, it's best to set roles explicitly.
|
||
# -- Options for intersphinx extension --------------------------------------- | ||
|
||
intersphinx_mapping = { |
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.
@abhinavsingh intersphinx allows you to reference objects defined on other Sphinx sites for as long as you list them here. Sphinx will download their objects.inv
files with lists of everything exposed.
The built-in way of exploring those objects is:
$ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv
But it's not very user-friendly, so I have a small project displaying this information for several sites I sometimes interact with. It's here: https://webknjaz.github.io/intersphinx-untangled/.
When linking objects from a foreign site, you can type them in as per usual, with their correct role and name. But since objects with the same name may exist on this and other sites, I prefer explicitly predending the references with <site-alias>:
. The dict keys below are those aliases you can use to point at objects at a specific site.
'pr': (f'{github_repo_url}/pull/%s', 'PR #'), # noqa: WPS323 | ||
'commit': (f'{github_repo_url}/commit/%s', ''), # noqa: WPS323 | ||
'gh': (f'{github_url}/%s', 'GitHub: '), # noqa: WPS323 | ||
'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 |
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.
@abhinavsingh these are simple roles for making external references. For example, you can use user
(in RST) in as follows:
:user:`webknjaz`
And that will link to my sponsors page (for users w/o sponsors enabled, GH will automatically redirect to their profiles).
This is useful to credit contributions to people in the changelog, for example.
_any_role = 'any' | ||
_py_class_role = 'py:class' | ||
nitpick_ignore = [ | ||
(_any_role, '<proxy.HttpProxyBasePlugin>'), |
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.
@abhinavsingh these are weird things mostly in single backticks found across the codebase. They all should be fixed one way or another, this is why they are ignored for now. But the action items are the same as for those linting violations for flake8.
@@ -0,0 +1,25 @@ | |||
(_proxy_py_glossary)= | |||
# {{ project }} Glossary |
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.
@abhinavsingh I declared this variable substitution so you can use it as {{ project }}
in Markdown documents and as |project|
in RST.
``` | ||
|
||
```{glossary} | ||
DNS |
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.
@abhinavsingh these are declared mostly so that they could be used via a term
directive instead of adding them to spelling exclusions. It's also useful for interlinking the same concept from various places. The lists may contain a few aliases as demonstrated for DoH. RST usage example:
:term:`DNS`
:term:`a custom DNS mention anchor <DNS>`
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.
All of this is awesomeness. I did notice the glossary section :)
```{toctree} | ||
:hidden: | ||
|
||
Glossary <glossary> |
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.
This syntax allows choosing a custom name for the menu item. In most cases, you'd just type in the document name and its title would be used here.
:start-after: (DO-NOT-REMOVE-docs-badges-END) | ||
``` | ||
|
||
```{toctree} |
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.
@abhinavsingh you can have as many ToC trees as you want. Each may have a caption if needed. :hidden:
is needed to exclude from the document render because this is also included in the sidebar and is unnecessary in the doc bottom.
author = f'{project} project contributors' | ||
copyright = author # pylint: disable=redefined-builtin |
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 chose this style without a date or the names because of the recommendations from the Linux Foundation.
TL;DR it's easier to maintain and doesn't have direct legal implications anyway.
https://linuxfoundation.org/blog/copyright-notices-in-open-source-software-projects/
@@ -0,0 +1,7 @@ | |||
IPv |
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.
@abhinavsingh this could probably be moved to the glossary and linked as a term once it's out of the README.
basepython = python3 | ||
commands_pre = | ||
# Paramiko: | ||
{envpython} -m pip install -r{toxinidir}/requirements-tunnel.txt |
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.
This is not in the deps because the docs requirements use a constraints file with hashes and when pip sees at least one hash, it requires all of the packages to be listed with hashes. The one on this line doesn't have hashes and will fail if listed in the same command. It's a hack but it is what it is. If the env deps infra is properly converted to pip-tools managed constraints files, it would be possible to move this to a better place.
usedevelop = false | ||
|
||
|
||
[testenv:doctest-docs] |
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.
@abhinavsingh with this, you can start adding doctests as part of the docs snippets per https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html. It's important to know that those snippets aren't out-of-date and still work.
@abhinavsingh you can now use the short link https://proxypy.rtfd.io on the repository front page, I think. Also, I have a comment about the pictures. The image in the README is not transparent and is not very well combined with the Dark Mode. It is visible both on the docs site and on GitHub (if you switch to dark mode). I recommend remaking that picture to:
As a side note, think about creating an SVG favicon too — try to avoid committing binary blobs like pictures into Git repos, it's harmful to them. But since SVG is just text/XML, it's fine + it's great for viewing with the 200% zoom that some people have in their browsers. |
PR preview: https://proxypy--747.org.readthedocs.build/en/747/
Notes