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 to pre-commit configuration #16180

Open
namurphy opened this issue Mar 8, 2024 · 3 comments
Open

Add sphinx-lint to pre-commit configuration #16180

namurphy opened this issue Mar 8, 2024 · 3 comments

Comments

@namurphy
Copy link
Contributor

namurphy commented Mar 8, 2024

In one of my recent ventures into a Sphinx rabbit dragon hole, I learned about sphinx-lint. sphinx-lint checks for "stylistic and formal issues in .rst and .py files included in the documentation". A key benefit is that it can find reStructuredText errors a lot more quickly than Astropy's Read the Docs build (and consequently partially addresses the issue I brought up in #16161).

It turns out that sphinx-lint has a pre-commit hook which could be added to .pre-commit-config.yaml.

I applied sphinx-lint to PlasmaPy in PlasmaPy/PlasmaPy#2561, and it was able to find a few reStructuredText errors that hadn't previously been caught by sphinx-build. I applied sphinx-lint to Astropy and it found the following ∼50 issues, which would need to be fixed or intentionally ignored if this hook is added. [I'd suggest ignoring the licenses directory in this hook (since for PlasmaPy, it reported text like ``AS IS'' as having a reStructuredText error).]

astropy/extern/README.rst:5: Line ends with dangling hyphen (dangling-hyphen)
docs/convolution/index.rst:266: Line ends with dangling hyphen (dangling-hyphen)
docs/coordinates/index.rst:452: Line ends with dangling hyphen (dangling-hyphen)
docs/development/docguide.rst:66: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
docs/development/docguide.rst:66: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
docs/coordinates/representations.rst:693: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:707: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:708: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:709: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:710: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:711: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:712: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:715: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:716: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:717: OMG TABS!!!1 (horizontal-tab)
docs/coordinates/representations.rst:718: OMG TABS!!!1 (horizontal-tab)
docs/development/releasing.rst:501: Line ends with dangling hyphen (dangling-hyphen)
docs/io/fits/appendix/header_transition.rst:51: Line ends with dangling hyphen (dangling-hyphen)
docs/modeling/example-fitting-model-sets.rst:83: OMG TABS!!!1 (horizontal-tab)
docs/modeling/parameters.rst:92: OMG TABS!!!1 (horizontal-tab)
docs/modeling/physical_models.rst:158: OMG TABS!!!1 (horizontal-tab)
docs/modeling/physical_models.rst:159: OMG TABS!!!1 (horizontal-tab)
docs/modeling/physical_models.rst:192: OMG TABS!!!1 (horizontal-tab)
docs/modeling/physical_models.rst:213: OMG TABS!!!1 (horizontal-tab)
docs/io/votable/index.rst:532: missing space before default role: ' to`~astropy.io.votable.parse`'. (missing-space-before-default-role)
docs/table/construct_table.rst:667: Line ends with dangling hyphen (dangling-hyphen)
docs/units/logarithmic_units.rst:286: OMG TABS!!!1 (horizontal-tab)
docs/units/logarithmic_units.rst:290: OMG TABS!!!1 (horizontal-tab)
docs/timeseries/lombscarglemb.rst:445: OMG TABS!!!1 (horizontal-tab)
docs/visualization/rgb.rst:25: Line ends with dangling hyphen (dangling-hyphen)
docs/io/unified.rst:190: Line ends with dangling hyphen (dangling-hyphen)
docs/io/unified.rst:669: Line ends with dangling hyphen (dangling-hyphen)
docs/table/operations.rst:405: Line ends with dangling hyphen (dangling-hyphen)
docs/timeseries/lombscargle.rst:929: OMG TABS!!!1 (horizontal-tab)
docs/timeseries/lombscargle.rst:942: OMG TABS!!!1 (horizontal-tab)
docs/timeseries/lombscargle.rst:943: OMG TABS!!!1 (horizontal-tab)
licenses/GATSPY_LICENSE.rst:23: No newline at end of file. (missing-final-newline)
licenses/AURA_LICENSE.rst:18: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
licenses/PYFITS.rst:18: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
docs/wcs/wcsapi.rst:24: Line ends with dangling hyphen (dangling-hyphen)
licenses/WCSLIB_LICENSE.rst:1: OMG TABS!!!1 (horizontal-tab)
docs/io/fits/appendix/history.rst:6: Line ends with dangling hyphen (dangling-hyphen)
docs/io/fits/appendix/history.rst:1490: Line ends with dangling hyphen (dangling-hyphen)
docs/wcs/relax.rst:110: Line ends with dangling hyphen (dangling-hyphen)
docs/wcs/relax.rst:152: Line ends with dangling hyphen (dangling-hyphen)
CHANGES.rst:13753: Line ends with dangling hyphen (dangling-hyphen)
CHANGES.rst:16104: Line ends with dangling hyphen (dangling-hyphen)
CHANGES.rst:524: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
CHANGES.rst:3583: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
CHANGES.rst:3583: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
CHANGES.rst:14326: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
CHANGES.rst:15610: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
@pllim
Copy link
Member

pllim commented Mar 8, 2024

Thanks! Interesting... We already unleash ruff on the Python scripts (#16132) but I guess this one is targeted at RST instead.

I wonder if @eerovaher or @nstarman have thoughts on this. They have been spearheading the linting stuff lately.

@nstarman
Copy link
Member

nstarman commented Mar 8, 2024

This does seem worthwhile! @namurphy do you think it's easier to tackle in one go, or piecemeal?

@eerovaher
Copy link
Member

This looks like it could be a good hook to use, but we'll need to see a pull request to review it properly.

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

No branches or pull requests

4 participants