Skip to content

enforce 'rstcheck' checks - #8408

Open
jameslamb wants to merge 2 commits into
NVIDIA:mainfrom
jameslamb:rstcheck
Open

enforce 'rstcheck' checks#8408
jameslamb wants to merge 2 commits into
NVIDIA:mainfrom
jameslamb:rstcheck

Conversation

@jameslamb

Copy link
Copy Markdown
Member

Contributes to rapidsai/build-planning#262

Proposes introducing rstcheck (rstcheck/rstcheck), a linter for ReStructuredText.

In my experience, it runs pretty quickly and catches things that sphinx-build -W does not, like:

  • invalid syntax in .. code-block:: blocks
  • duplicated references (which can lead to unexpected behavior when sharing URLs with anchors)

Notes for Reviewers

Planning to try this across all of RAPIDS, but starting here partially because @jcrist and I talked about .rst linting at SciPy 😊

@jameslamb
jameslamb requested a review from a team as a code owner July 27, 2026 15:30
@jameslamb jameslamb added the improvement Improvement / enhancement to an existing function label Jul 27, 2026
@jameslamb
jameslamb requested a review from a team as a code owner July 27, 2026 15:30
@jameslamb jameslamb added the non-breaking Non-breaking change label Jul 27, 2026
@jameslamb
jameslamb requested review from csadorf and msarahan July 27, 2026 15:30
Here we provide a few examples of using ``cuml.accel``. The code for the
examples in this section is available in the cuML GitHub repository at `examples
<https://github.com/rapidsai/cuml/tree/HEAD/docs/source/cuml-accel/examples>`_.
examples in this section is available in the cuML GitHub repository at `<https://github.com/rapidsai/cuml/tree/HEAD/docs/source/cuml-accel/examples>`__.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's a section title also called Examples in this page, which made the reference #examples ambiguous.

Changing this to an anonymous URL resolves that.

@csadorf csadorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

accelerate:

.. code-block:: python
.. code-block:: ipython

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Any of these code blocks with cell magic like %load_ext are reported as invalid syntax and Python code that follows them may not render correctly.

Using ipython fixes that. And works because cuML already uses a Sphinx extension to support that highlighting:

https://github.com/rapidsai/cuml/blob/0f4af33b1b003c6a57de4557661ea41f24857bbe/docs/source/conf.py#L52


You can find many more complete examples in the `Introductory Notebook
<estimator_intro.ipynb>`_ and in the cuML API documentation.
<estimator_intro.ipynb>`__ and in the cuML API documentation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are 2 references in this file both name "Introductory Notebook". Making these anonymous links resolves that.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Improved rendering of documentation links and cross-references.
    • Updated Jupyter and IPython examples to use appropriate syntax highlighting.
  • Chores
    • Updated pre-commit tooling.
    • Added automated reStructuredText documentation checks with project-specific validation settings.

Walkthrough

The pull request adds rstcheck to pre-commit validation, configures its accepted directives and ignored messages, and updates documentation code-block and hyperlink markup.

Changes

Documentation tooling and markup

Layer / File(s) Summary
Configure rstcheck validation
.pre-commit-config.yaml, pyproject.toml
Adds the rstcheck hook, updates pre-commit-hooks, and configures rstcheck handling for project documentation.
Update documentation markup
docs/source/cuml-accel/**/*.rst, docs/source/cuml_intro.rst
Marks Jupyter examples as ipython blocks and corrects selected reStructuredText link markup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: doc

Suggested reviewers: bdice, msarahan, betatim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main change: enforcing rstcheck checks.
Description check ✅ Passed The description directly explains the new rstcheck linter and why it was added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pyproject.toml`:
- Around line 42-45: Restrict the rstcheck ignore pattern in ignore_messages to
the documented stable-anchor names or a narrowly defined anchor allowlist,
rather than matching every “Hyperlink target .* is not referenced” warning.
Preserve suppression for known intentional anchors while allowing typo and
dead-anchor warnings to surface.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0c34c479-06c0-4c8a-b109-38fe1d56072c

📥 Commits

Reviewing files that changed from the base of the PR and between 0f4af33 and 6f1bfb9.

📒 Files selected for processing (8)
  • .pre-commit-config.yaml
  • docs/source/cuml-accel/examples/index.rst
  • docs/source/cuml-accel/faq.rst
  • docs/source/cuml-accel/index.rst
  • docs/source/cuml-accel/logging-and-profiling.rst
  • docs/source/cuml-accel/usage.rst
  • docs/source/cuml_intro.rst
  • pyproject.toml

Comment thread pyproject.toml
Comment on lines +42 to +45
ignore_messages = '''(?x)(
# ignore links that look "unused" because they're there to provide stable anchors in hyperlinks
Hyperlink\ target\ .*\ is\ not\ referenced
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Scope the rstcheck ignore to known anchors. Hyperlink target .* is not referenced suppresses every unreferenced-target warning, so typos and dead anchors will be missed; restrict this to explicit anchors or a narrower allowlist. pyproject.toml:42-45

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pyproject.toml` around lines 42 - 45, Restrict the rstcheck ignore pattern in
ignore_messages to the documented stable-anchor names or a narrowly defined
anchor allowlist, rather than matching every “Hyperlink target .* is not
referenced” warning. Preserve suppression for known intentional anchors while
allowing typo and dead-anchor warnings to surface.

Comment thread pyproject.toml

ignore_messages = '''(?x)(
# ignore links that look "unused" because they're there to provide stable anchors in hyperlinks
Hyperlink\ target\ .*\ is\ not\ referenced

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Example of this:

https://github.com/rapidsai/cuml/blob/0f4af33b1b003c6a57de4557661ea41f24857bbe/docs/source/cuml_intro.rst#L19

Without this configuration, rstcheck reports:

docs/source/cuml_intro.rst:19: (INFO/1) Hyperlink target "where-possible-match-the-scikit-learn-api" is not referenced.

But we want to keep that, because it creates this anchor: https://docs.rapids.ai/api/cuml/nightly/cuml_intro/#where-possible-match-the-scikit-learn-api

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

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants