-
-
Notifications
You must be signed in to change notification settings - Fork 20
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 check for missing space after directive :: #8
Conversation
For example: .. versionadded::0.1 This is taken as a comment, thus no warning from docutils/Sphinx. This doesn't yield any false positives in CPython. Closes #7
Found a false positive in kitchen-sink: Centered text
-------------
You can create a statement with centered text with ``.. centered::``
.. centered:: This is centered text! It may be solved by adding +=============================+=============================+======================+
| :c:type:`allocfunc` | .. line-block:: | :c:type:`PyObject` * |
| | | |
| | :c:type:`PyTypeObject` * | |
| | Py_ssize_t | |
+-----------------------------+-----------------------------+----------------------+ but we know we don't handle tables yet. |
Darn, good catch. Actually, running
Maybe |
Heads up: sphinx-lint should soon pass consistently on sphinx-doc: sphinx-doc/sphinx#10389 |
@@ -119,6 +119,10 @@ | |||
# .. versionchanged:: 3.6 | |||
three_dot_directive_re = re.compile(r"\.\.\. %s::" % all_directives) | |||
|
|||
# Find directive missing space after double colon, like: | |||
# .. versionchanged::3.6 | |||
missing_space_directive_re = re.compile(r"(?<!\.)\.\. %s::[^\s]" % simplename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing_space_directive_re = re.compile(r"(?<!\.)\.\. %s::[^\s]" % simplename) | |
missing_space_directive_re = re.compile(r"(?<!\.)\.\. %s::[^`\s]" % simplename) |
Would this tweak be enough?
>>> simplename = r"(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*"
>>> missing_space_directive_re = re.compile(r"(?<!\.)\.\. %s::[^`\s]" % simplename)
>>> missing_space_directive_re.match('`.. foo::123`')
>>> missing_space_directive_re.match('``.. foo::123``')
>>> missing_space_directive_re.match('``.. foo::``')
>>> missing_space_directive_re.match(':dir:`.. foo::`')
>>> missing_space_directive_re.match('.. foo::')
>>> missing_space_directive_re.match('.. foo:: ')
>>> missing_space_directive_re.match('| .. foo:: |')
>>> missing_space_directive_re.match('.. foo::`bar`')
>>> missing_space_directive_re.match('.. foo:: valid')
>>> missing_space_directive_re.match('.. foo::invalid')
<re.Match object; span=(0, 9), match='.. foo::i'>
>>> missing_space_directive_re.match('.. foo::3.7 invalid')
<re.Match object; span=(0, 9), match='.. foo::3'>
It catches the last two (invalid), and ignores all the other ones. It will miss something like .. foo::`bar`
(the user might have wanted .. foo:: `bar`
, which should be valid), but this seems quite unlikely.
For example:
.. versionadded::0.1
This is taken as a comment, thus no warning from docutils/Sphinx.
This doesn't yield any false positives in CPython.
Closes #7
This is a first PR to get familiar with the script.