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 built-in validation checks for directive syntax #507

Open
user27182 opened this issue Sep 27, 2023 · 1 comment
Open

Add built-in validation checks for directive syntax #507

user27182 opened this issue Sep 27, 2023 · 1 comment

Comments

@user27182
Copy link

user27182 commented Sep 27, 2023

Issue/bug

Currently, the following invalid directive syntax is not checked by numpydoc-validation

.. directive::
Some text

The numpydoc-validation checks will pass, but the invalid syntax will result in a documentation build failure with a warning and/or error such as:

WARNING: Explicit markup ends without a blank line; unexpected unindent.
ERROR: Content block expected for the "note" directive; none found.

The correct syntax, according to the reST documentation, is:

+-------+-------------------------------+
| ".. " | directive type "::" directive |
+-------+ block                         |
        |                               |
        +-------------------------------+

Therefore, in the first example provided above, the errors/warnings are resolved by indenting the block of text, i.e.:

.. directive::
    Some text

Here is an example build failure and the subsequent commit diff with added indentation which resolved the warnings and errors and resulted in a successful documentation build. Ideally, this invalid syntax would have been caught by a pre-commit hook such as numpydoc-validation so that it could be addressed before running CI testing to avoid the inevitable documentation build failure.

This appears to be a somewhat common problem, e.g. reported here and here.

Feature request

The feature request is to add additional validation check(s) for the correct syntax of directives, e.g. add a new mapping to the existing checks, something like:

  • "GL11": "reST directives {directives} text block must be indented."

Thank you for your time.

@rossbar
Copy link
Contributor

rossbar commented Sep 27, 2023

Thanks for the suggestion @user27182 . Currently, the validation code is intended to validate for compliance against the numpydoc docstring format specifically. I think there's already been some scope creep, but adding general rst validation would be a significant jump. My own two cents is that an rst validation tool would be best handled in/as a separate project.

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

No branches or pull requests

2 participants