Contents Menu Expand
None
None
  • Home
  • Usage
  • Examples
  • API Reference
  • Downloading source code
  • License

Links

  • GitHub
  • PyPI
  • Contributing Guide

flake8_sphinx_links¶

A Flake8 plugin to check docstrings for double backticked strings which should be links to the Python documentation.

Docs

Documentation Build Status Docs Check Status

Tests

Linux Test Status Windows Test Status macOS Test Status Coverage

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Anaconda

Conda - Package Version Conda - Platform

Activity

GitHub last commit GitHub commits since tagged version Maintenance PyPI - Downloads

QA

CodeFactor Grade Flake8 Status mypy status

Other

License GitHub top language Requirements Status

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`

True => True

``False`` => :py:obj:`False`

False => False

``None`` => :py:obj:`None`

None => None

``NotImplemented`` => :py:obj:`NotImplemented`

NotImplemented => NotImplemented

``Ellipsis`` => :py:obj:`Ellipsis`

Ellipsis => Ellipsis

``__debug__`` => :py:obj:`__debug__`

__debug__ => __debug__

``quit`` => :py:obj:`quit`

quit => quit

``exit`` => :py:obj:`exit`

exit => exit

``copyright`` => :py:obj:`python:copyright`

copyright => copyright

``credits`` => :py:obj:`credits`

credits => credits

``license`` => :py:obj:`license`

license => license

``ValueError`` => :exc:`ValueError`

ValueError => ValueError

``BaseException`` => :exc:`BaseException`

BaseException => BaseException

``ValueError`` => :exc:`ValueError`

ValueError => ValueError

``int`` => :class:`int`

int => int

``str`` => :class:`str`

str => 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:

Plugin(tree)

Flake8 plugin to check docstrings for double backticked strings which should be links to the Python documentation.

Visitor()

AST visitor to check docstrings for double backticked strings which should be links to the Python documentation.

Data:

exc

List of keywords which should become :py:exc:`<keyword>`

py_obj

List of keywords which should become :py:obj:`<keyword>`

py_obj_python

List of keywords that should become :py:obj:`python:<keyword>` to prevent conflict with Sphinx objects.

regex

Regex to match keywords that should be Sphinx links.

class Plugin(tree)[source]¶

Bases: Plugin[Visitor]

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']¶

Type:    List[str]

List of keywords which should become :py:exc:`<keyword>`

py_obj = ['True', 'False', 'None', 'NotImplemented', 'Ellipsis', '__debug__', 'quit', 'exit', 'credits', 'license']¶

Type:    List[str]

List of keywords which should become :py:obj:`<keyword>`

py_obj_python = ['copyright']¶

Type:    List[str]

List of keywords that should become :py:obj:`python:<keyword>` to prevent conflict with Sphinx objects.

regex¶

Type:    Pattern

Regex to match keywords that should be Sphinx links.

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.
Alternatively, the code can be downloaded in a ‘zip’ file by clicking:
Clone or download –> Download Zip
Downloading a 'zip' file of the source code.

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
  • Commercial use
  • Modification
  • Distribution
  • Private use
  • License and copyright notice
  • Liability
  • Warranty
See more information on choosealicense.com ➩

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.

Browse the GitHub Repository

Copyright © 2020-2021 Dominic Davis-Foster | Built with Sphinx and @pradyunsg's Furo theme.
Contents
  • Home
  • Usage
    • Flake8 codes
    • Pre-commit hook
  • Examples
  • API Reference
    • Plugin
    • Visitor
    • exc
    • py_obj
    • py_obj_python
    • regex
  • Downloading source code
    • Building from source
  • License

Links

  • GitHub
  • PyPI
  • Contributing Guide