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

Include C construct directives for RST checks #109

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
__pycache__/
*.egg-info/
.coverage
.coverage.*
.envrc
.tox/
.venv/
Expand Down
5 changes: 4 additions & 1 deletion sphinxlint/rst.py
Copy link
Member

Choose a reason for hiding this comment

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

In https://github.com/sphinx-contrib/sphinx-lint/pull/26/files#diff-91cfb2b6e0fd957947632d6fee27472ac6aaff7d825f02bdea3e54cda9005b0b, which I haven't had the time to revisit, I enumerated the list of directives more exhaustively:

DIRECTIVES_CONTAINING_RST = [
    # reStructuredText directives:
    'admonition', 'attention', 'caution', 'class', 'compound', 'container',
    'danger', 'epigraph', 'error', 'figure', 'footer', 'header', 'highlights',
    'hint', 'image', 'important', 'line-block', 'list-table', 'math', 'meta',
    'note', 'parsed-literal', 'pull-quote', 'replace', 'sidebar', 'tip',
    'topic', 'warning',
    # Added by Sphinx:
    'acks', 'centered', 'codeauthor', 'default-domain', 'deprecated(?!-removed)',
    'describe', 'highlight', 'hlist', 'index', 'literalinclude', 'moduleauthor',
    'object', 'only', 'rst-class', 'sectionauthor', 'seealso', 'tabularcolumns',
    'toctree', 'versionadded', 'versionchanged',
    # Added by Sphinx (since removed):
    'highlightlang',  # removed in Sphinx 4.0
    # Added by Sphinx (Standard domain):
    'cmdoption', 'envvar', 'glossary', 'option', 'productionlist', 'program',
    # Added by Sphinx (Python domain):
    'py:attribute', 'py:class', 'py:classmethod', 'py:currentmodule', 'py:data',
    'py:decorator', 'py:decoratormethod', 'py:exception', 'py:function',
    'py:method', 'py:module', 'py:property', 'py:staticmethod',
    'attribute', 'class', 'classmethod', 'currentmodule', 'data',
    'decorator', 'decoratormethod', 'exception', 'function',
    'method', 'module', 'property', 'staticmethod',
    # Added by Sphinx (C domain):
    'c:alias', 'c:enum', 'c:enumerator', 'c:function', 'c:macro', 'c:member',
    'c:struct', 'c:type', 'c:union', 'c:var',
    'cfunction', 'cmacro', 'cmember', 'ctype', 'cvar',
    # Added by Sphinx (sphinx.ext.todo):
    'todo', 'todolist',
    # Added in Sphinx's own documentation only:
    'confval', 'event',
    # Added in the Python documentation (directives):
    'audit-event', 'audit-event-table', 'availability',
    'deprecated-removed', 'impl-detail', 'miscnews',
    # Added in the Python documentation (objects with implicit directives):
    '2to3fixer', 'opcode', 'pdbcommand',
    # Added in the Python documentation (Python domain):
    'coroutinefunction', 'coroutinemethod', 'abstractmethod',
    'awaitablefunction', 'awaitablemethod',
    'py:coroutinefunction', 'py:coroutinemethod', 'py:abstractmethod',
    'py:awaitablefunction', 'py:awaitablemethod',
]

DIRECTIVES_CONTAINING_ARBITRARY_CONTENT = [
    # reStructuredText directives:
    'code', 'code-block', 'contents', 'csv-table', 'date', 'default-role',
    'include', 'raw', 'restructuredtext-test-directive', 'role', 'rubric',
    'section-numbering', 'sectnum', 'sourcecode', 'table', 'target-notes',
    'title', 'unicode',
    # Added by Sphinx (core):
    'cssclass',
    # Added by Sphinx (Standard domain):
    'productionlist',
    # Added by Sphinx (C domain):
    'c:namespace', 'c:namespace-pop', 'c:namespace-push',
    # Added by Sphinx (sphinx.ext.autodoc):
    'autoattribute', 'autoclass', 'autodata', 'autodecorator', 'autoexception',
    'autofunction', 'automethod', 'automodule', 'autonewtypedata',
    'autonewvarattribute', 'autoproperty',
    # Added by Sphinx (sphinx.ext.doctest):
    'doctest', 'testcleanup', 'testcode', 'testoutput', 'testsetup',
    # Added in the Python documentation:
    'limited-api-list',
]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you suggest? Shall we wait for #26 to be merged instead, or merge this as an incremental improvement?

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
# fmt: off
DIRECTIVES_CONTAINING_RST = [
# standard docutils ones
'admonition', 'attention', 'caution', 'class', 'compound', 'container',
'admonition', 'attention',
'c:data', 'c:enum', 'c:enumerator', 'c:func', 'c:macro', 'c:member',
'c:struct', 'c:type', 'c:union', 'c:var',
'caution', 'class', 'compound', 'container',
'danger', 'epigraph', 'error', 'figure', 'footer', 'header', 'highlights',
'hint', 'image', 'important', 'include', 'line-block', 'list-table', 'meta',
'note', 'parsed-literal', 'pull-quote', 'replace', 'sidebar', 'tip', 'topic',
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/xfail/default-role-in-c-type.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. expect: default role used (hint: for inline literals, use double backticks) (default-role)

.. c:type:: int (*PyCode_WatchCallback)(PyCodeEvent event, PyCodeObject* co)

If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
after `co` has been fully initialized. Otherwise, the callback is invoked
before the destruction of *co* takes place, so the prior state of *co*
can be inspected.
Loading