Add built-in validation checks for directive syntax

Open
#507 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
documentation

Research direction

Review the existing built-in validation checks linked in the issue and compare their behavior with the invalid and corrected directive examples. Add validation for an unindented directive content block, ensuring the proposed diagnostic is reported while correctly indented syntax passes.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
354
Forks
185
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from numpy/numpydoc

All issues in numpy/numpydoc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.