Skip to content
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 sphinx-lint session to noxfile #1800

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rffontenelle
Copy link
Contributor

@rffontenelle rffontenelle commented Feb 4, 2025

See #1166

This runs sphinx-lint in the docs together with HTML build and linkcheck. It accepts one or more path as positional argument, so e.g. one may specify the path of a translation file instead of using the source reST files from "source" directory.

I was going to add sphinx-lint package to requirements.txt and pip-install from that file, but this unnecessarily added dependencies and increased install time.

Running without posargs:

$ python -m nox -s sphinx_lint
nox > Running session sphinx_lint
nox > Creating virtual environment (virtualenv) using python in .nox/sphinx_lint
nox > python -m pip install sphinx-lint
nox > sphinx-lint source
source/glossary.rst:294: OMG TABS!!!1 (horipython -m nox -s sphinx_lintzontal-tab)
source/guides/creating-command-line-tools.rst:105: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:106: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:107: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:126: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:127: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:148: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:149: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:150: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:151: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:152: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:153: OMG TABS!!!1 (horizontal-tab)
source/guides/creating-command-line-tools.rst:163: OMG TABS!!!1 (horizontal-tab)
nox > Command sphinx-lint source failed with exit code 1
nox > Session sphinx_lint failed.

Running with a posargs as the filepath "messages.po", the Brazilian Portuguese translation obtained from translation/source branch:

$ python -m nox -s sphinx_lint -- messages.po 
nox > Running session sphinx_lint
nox > Creating virtual environment (virtualenv) using python in .nox/sphinx_lint
nox > python -m pip install sphinx-lint==1.0.0
nox > sphinx-lint messages.po
No problems found.
nox > Session sphinx_lint was successful.

📚 Documentation preview 📚: https://python-packaging-user-guide--1800.org.readthedocs.build/en/1800/

@chrysle
Copy link
Contributor

chrysle commented Mar 1, 2025

Thanks for your contribution! But probably it will be sufficient to add sphinx-lint to CI (#1786)?

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

accepting another path as positional argument.
"""
session.install("sphinx-lint==1.0.0")
target = session.posargs if len(session.posargs) >= 1 else ["source"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this would probably be more elegant

Suggested change
target = session.posargs if len(session.posargs) >= 1 else ["source"]
target = session.posargs or ["source"]

@webknjaz
Copy link
Member

webknjaz commented Mar 2, 2025

Thanks for your contribution! But probably it will be sufficient to add sphinx-lint to CI (#1786)?

I like both solutions. The important bit is the ability to invoke it locally.

@rffontenelle WDYT? Should we go for the other PR?

@rffontenelle
Copy link
Contributor Author

I'm fine with it.

Although I wonder if it uses problem-matcher annotations and if not if it would feasible. Personally I find annotations very handy on GitHub Actions run log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants