Skip to main content

Style checker for Sphinx (or other) RST documentation

Project description

Doc8 is a opinionated style checker for sphinx (or other) rst documentation.

Features

  • Ability to parse and validate rst files.

QuickStart

pip install doc8

To run doc8 just invoke it against any doc directory:

$ doc8 coolproject/docs

Usage

Command line usage

$ doc8  -h

usage: doc8 [-h] [--config path] [--allow-long-titles] [--ignore code]
            [--no-sphinx] [--ignore-path path] [--max-line-length int]
            [-e extension] [-v]
            [path [path ...]]

Check documentation for simple style requirements.

What is checked:
    - invalid rst format - D000
    - lines should not be longer than 79 characters - D001
      - exception: line with no whitespace except in the beginning
      - exception: lines with http or https urls
      - exception: literal blocks
      - exception: rst target directives
    - no trailing whitespace - D002
    - no tabulation for indentation - D003
    - no carriage returns (use unix newlines) - D004

positional arguments:
  path                  path to scan for doc files (default: os.getcwd())

optional arguments:
  -h, --help            show this help message and exit
  --config path         user config file location (default: doc8.ini, tox.ini,
                        pep8.ini, setup.cfg)
  --allow-long-titles   allow long section titles (default: False)
  --ignore code         ignore the given errors code/codes
  --no-sphinx           do not ignore sphinx specific false positives
  --ignore-path path    ignore the given directory or file (globs are
                        supported)
  --max-line-length int
                        maximum allowed line length (default: 79)
  -e extension, --extension extension
                        check file extensions of the given type (default:
                        .rst, .txt)
  -v, --verbose         run in verbose mode

Ini file usage

Instead of using the CLI for options the following files will also be examined for [doc8] sections that can also provided the same set of options. If the --config path option is used these files will not be scanned for the current working directory and that configuration path will be used instead.

  • $CWD/doc8.ini

  • $CWD/tox.ini

  • $CWD/pep8.ini

  • $CWD/setup.cfg

An example section that can be placed into one of these files:

[doc8]

ignore_path=/tmp/stuff,/tmp/other_stuff
max_line_length=99
verbose=1

Note: The option names are the same as the command line ones but instead of dashes underscores are used instead (with the only variation of this being the no-sphinx option which from configuration file will be sphinx instead).

Option conflict resolution

When the same option is passed on the command line and also via configuration files the following strategies are applied to resolve these types of conflicts.

Option

Overrides

Merges

allow-long-titles

Yes

No

extension

No

Yes

ignore-path

No

Yes

ignore

No

Yes

max-line-length

Yes

No

sphinx

Yes

No

Note: In the above table the configuration file option when specified as overrides will replace the same option given via the command line. When merges is stated then the option will be combined with the command line option (for example by becoming a larger list or set of values that contains the values passed on the command line and the values passed via configuration).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc8-0.4.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

doc8-0.4.0-py2.py3-none-any.whl (16.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file doc8-0.4.0.tar.gz.

File metadata

  • Download URL: doc8-0.4.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for doc8-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1a34520fea554d14abe605a622ac5b99227ea542f80d3a2133b1882a87b307d9
MD5 c89b71d295af3547c1f663ecb8f40719
BLAKE2b-256 1c1f1fe39a42e1b4b563eb3cfa91453980a5469019ee4ca7400860eb81bb02b4

See more details on using hashes here.

Provenance

File details

Details for the file doc8-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for doc8-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 40ac6463368215d63466d68d0421028795ddaead030de2399958cccd4b87ce67
MD5 49ce81abf8015b751083410edfdf4d55
BLAKE2b-256 fa7516f648897ec38b01fef35b9265607007ea5c42f3a12762513690dba8becb

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page