flake8_sphinx_links¶
A Flake8 plugin to check docstrings for double backticked strings which should be links to the Python documentation.
Installation¶
python3 -m pip install flake8_sphinx_links --user
First add the required channels
conda config --add channels https://conda.anaconda.org/conda-forge
conda config --add channels https://conda.anaconda.org/domdfcoding
Then install
conda install flake8_sphinx_links
python3 -m pip install git+https://github.com/python-formate/flake8-sphinx-links@master --user
Contents¶
Usage¶
This library provides the Flake8 plugin flake8-sphinx-links
to check docstrings for double backticked
strings which should be links to the Python documentation.
For example, ``True`` should be py:obj:`True`, which Sphinx will render as a link to the Python documentation. See Examples for further examples.
reStructuredText .rst files are not currently checked.
Flake8 codes¶
Code |
Description |
---|---|
SXL001 |
Double backticked strings should be a link to Python documentation. |
Pre-commit hook¶
flake8-sphinx-links
can also be used as a pre-commit
hook
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-sphinx-links==0.2.2
Examples¶
``True`` => :py:obj:`True` |
|
``False`` => :py:obj:`False` |
|
``None`` => :py:obj:`None` |
|
``NotImplemented`` => :py:obj:`NotImplemented` |
|
``Ellipsis`` => :py:obj:`Ellipsis` |
|
``__debug__`` => :py:obj:`__debug__` |
|
``quit`` => :py:obj:`quit` |
|
``exit`` => :py:obj:`exit` |
|
``copyright`` => :py:obj:`python:copyright` |
|
``credits`` => :py:obj:`credits` |
|
``license`` => :py:obj:`license` |
|
``ValueError`` => :exc:`ValueError` |
|
``BaseException`` => :exc:`BaseException` |
|
``ValueError`` => :exc:`ValueError` |
|
``int`` => :class:`int` |
|
``str`` => :class:`str` |
|
API Reference¶
In addition to the Flake8 plugin, the following public API is available
to allow other plugins to build on top of flake8-sphinx-links
.
Classes:
|
Flake8 plugin to check docstrings for double backticked strings which should be links to the Python documentation. |
|
AST visitor to check docstrings for double backticked strings which should be links to the Python documentation. |
Data:
List of keywords which should become |
|
List of keywords which should become |
|
List of keywords that should become |
|
Regex to match keywords that should be Sphinx links. |
-
class
Plugin
(tree)[source]¶ -
Flake8 plugin to check docstrings for double backticked strings which should be links to the Python documentation.
-
class
Visitor
[source]¶ Bases:
Visitor
AST visitor to check docstrings for double backticked strings which should be links to the Python documentation.
-
exc
= ['BaseException', 'Exception', 'ArithmeticError', 'BufferError', 'LookupError', 'AssertionError', 'AttributeError', 'EOFError', 'FloatingPointError', 'GeneratorExit', 'ImportError', 'ModuleNotFoundError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'MemoryError', 'NameError', 'NotImplementedError', 'OSError', 'OverflowError', 'RecursionError', 'ReferenceError', 'RuntimeError', 'StopIteration', 'StopAsyncIteration', 'SyntaxError', 'IndentationError', 'TabError', 'SyntaxError', 'IndentationError', 'TabError', 'SystemError', 'SystemExit', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UnicodeEncodeError', 'UnicodeDecodeError', 'UnicodeTranslateError', 'ValueError', 'ZeroDivisionError', 'EnvironmentError', 'IOError', 'WindowsError', 'BlockingIOError', 'ChildProcessError', 'ConnectionError', 'BrokenPipeError', 'ConnectionAbortedError', 'ConnectionRefusedError', 'ConnectionResetError', 'FileExistsError', 'FileNotFoundError', 'InterruptedError', 'IsADirectoryError', 'NotADirectoryError', 'PermissionError', 'ProcessLookupError', 'TimeoutError', 'Warning', 'UserWarning', 'DeprecationWarning', 'PendingDeprecationWarning', 'SyntaxWarning', 'RuntimeWarning', 'FutureWarning', 'ImportWarning', 'UnicodeWarning', 'BytesWarning', 'ResourceWarning']¶ -
List of keywords which should become
:py:exc:`<keyword>`
-
py_obj
= ['True', 'False', 'None', 'NotImplemented', 'Ellipsis', '__debug__', 'quit', 'exit', 'credits', 'license']¶ -
List of keywords which should become
:py:obj:`<keyword>`
-
py_obj_python
= ['copyright']¶ -
List of keywords that should become
:py:obj:`python:<keyword>`
to prevent conflict with Sphinx objects.
Downloading source code¶
The flake8_sphinx_links
source code is available on GitHub,
and can be accessed from the following URL: https://github.com/python-formate/flake8-sphinx-links
If you have git
installed, you can clone the repository with the following command:
git clone https://github.com/python-formate/flake8-sphinx-links
Cloning into 'flake8-sphinx-links'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (66/66), done.

Downloading a ‘zip’ file of the source code¶
Building from source¶
The recommended way to build flake8_sphinx_links
is to use tox:
tox -e build
The source and wheel distributions will be in the directory dist
.
If you wish, you may also use pep517.build or another PEP 517-compatible build tool.
License¶
flake8_sphinx_links
is licensed under the MIT License
A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
Permissions | Conditions | Limitations |
---|---|---|
|
|
Copyright (c) 2020 Dominic Davis-Foster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
View the Function Index or browse the Source Code.