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
Sphinx's nit-picky mode, should we use it? #101100
Comments
See also: https://discuss.python.org/t/broken-references-in-sphinx-docs/19463 IMO, we should fix these. Many are actual issues in the documentation. Here's a proof-of-concept GH Action that complains about nitpicks in changed files only: encukou@e97d91f |
Yes, definitely; I've been gradually helping on the docs I've/we've touched anyway, though it is a long term project. I've found a number of things that were undocumented, as well as a number of other real issues through that, e.g. on the
I'd argue neither is exactly innocent:
There's a third, much simpler and better fix. If the link isn't desired, every Sphinx cross-reference role supports prepending
|
I've sent an example PR with the fix for The dev experience was plesant, because on the second run |
As a general note of caution, especially when submitting PRs fixing these sorts of widespread and potentially nitpicky (heh) docs defects, especially when in cases like this there are a number of different possibilities to handle each warning instance, we should take care to avoid the folly of large "omnibus" PRs (as Guido likes to call them) and take care to consider each specific change we're making holistically, and ensure that we're picking the approach that best serves the reader in for each specific context, as opposed to just applying one type of fix mechanically to all instances, or even worse arbitrarily picking one or another each time without careful thought and consideration that might fix the warning but be an overall regression. Otherwise, if we're too focused solely on the narrow objective of getting rid of the warnings by whatever means, as opposed to the broader goal of improving the overall quality of the docs, we risk both doing exactly the opposite of the latter, and consuming the limited time and churn budget of core developers and other reviewers on changes with little or even negative practical benefit. |
That's the reasoning behind teaching the CI to only warn, and only on changed files. |
* pythongh-101100: [Enum] Fix sphinx warnings in (cherry picked from commit 9e025d3) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
To enable this, it would be really useful if Sphinx had more granular config for the warnings/errors, similar to Flake8. For example, we could enable nitpicky only for certain directories and files, and expand as more are cleaned. And possibly in combination with an exclude option. Similarly, we may only want to enable/disable nitpicky for certain classes of warnings/errors. That would allow us to iteratively fix things, and keep them fixed. cc @AA-Turner |
PR to fix 113 warnings in the |
Yeah; you can silence warnings for particular names, but not in particular files, which would IMO be much more useful. Besides just incrementally fixing these issues, it would also be very useful to potentially keep permanently for What's New and Changelog pages (other than those for the current feature version in a particular branch) as those will naturally drift out of date over time. I believe I mentioned this on a Sphinx issue somewhere at some point semi-recently, but if I did I can't seem to find it now. |
Does anybody have an opinion on the docstring-side of matters? In other words, should the docstrings inside the Python source code also comply to Sphinx's nit-picky mode? (see e.g. #100989) |
IMO, it's generally helpful for the docstrings to use the unambiguous, explicit and precise types if feasible, but particularly for the docstrings, avoiding warnings in In the particular case of your PR #100990 , it appears to make substantial clarity and descriptiveness improvements to the docstrings beyond just the above change (which is really secondary in benefit to the latter), so to me it appears to be a pretty clear net win. |
…2695) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Petr Viktorin <encukou@gmail.com>
pythongh-101100: Filter only Doc/ files
Would it be possible for the warning to include a link to possible fixups for the particular warning? I don't remember reading about '~object' or '!CON' and I imaging others are similarly deficient in sphinx-fu. |
That would be a great idea, but its kinda hard to programmatically determine the most appropriate solution for a particular case without considering the specifics and context of the situation, which can be very quick for a human like us with the specific expertise and experience (really, the latter more than the former, since the syntax can be a lot easier to grasp than the semantics) but much harder to write reliable prescriptive rules for. IMO, it would be better for most folks to just not worry about it at all and instead just tag a docs team member (like me) and we can pop over and make a one-click suggestion (or commit) with the best fix if desired. For these kind of issues, I can have a <24 hour, perhaps close to 12-hour SLA.
@ezio-melotti made a nice quick-reference table with all of the common syntax bits, including those, over on the devguide, and the Sphinx docs also has a concise primer covering those as well, but TL;DR these are the main cases:
|
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Petr Viktorin <encukou@gmail.com>
pythongh-101100: Filter only Doc/ files
…103116) Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Follow on from #103116. Expand list of clean docs files from 3 to 181. These files have no Sphinx warnings, and their presence in this list means that any new warnings introduced will fail the build. The list was created by subtracting the list of files with warnings from a list of all files. I tested with all of those, but found that `touch`ing two clean files (https://github.com/python/cpython/blob/main/Doc/includes/wasm-notavail.rst and https://github.com/python/cpython/blob/main/Doc/whatsnew/changelog.rst) caused a cascade effect and resulted in a number of dirty files being rebuilt too, and failing the build. So those two have been omitted. Automerge-Triggered-By: GH:hugovk
…n list (#103191) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…a clean list (python#103191) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Documentation
Running sphinx-build in nit-picky mode, like:
or:
gives tons warnings. ~8k of them at the time of writing.
Most of them are innocent, like using
:const:
while referring to a constant defined in another file, or using:meth:`__init__`
to speak about the concept of an init method.The fall in several cases:
I don't have statistics (yet) on the distribution for the 4 previous cases.
For the innocent usages of rst markers, there's two fixes:
:const:`IGNORECASE`
becomes``IGNORECASE``
. We loose a bit of information in the rst file, I'm not fully convinced.:const:`IGNORECASE`
becomes:const:`re.IGNORECASE`
, or even:const:`~re.IGNORECASE`
to keep the same output. It means more typing, and more links in the HTML output which are not all usefull.My question is: should we try to fix all warnings so we can easily spot typos at build time?
I tried to see if some typo would have been avoided by the nit-picky mode by reading a few pages of WARNINGS and found just one:
read1
instead ofread
inbz2.rst
.Linked PRs
enum
module #101122decimal
module #102125decimal
module (GH-102125) #102237decimal
module (GH-102125) #102238typing
module #102260typing
module docs (GH-102260) #102262typing
module docs (GH-102260) #102263types
module #102274types
module (GH-102274) #102291types
module (GH-102274) #102292turtle
module #102340zipapp
andzipfile
modules #102526zipapp
andzipfile
modules (GH-102526) #102529zipapp
andzipfile
modules (GH-102526) #102530dis
module #102597turtle
module (GH-102340) #102638turtle
module (GH-102340) #102639argparse
module #103289The text was updated successfully, but these errors were encountered: