Skip to main content

Sphinx extension to lint shell code blocks

Project description

PyPI version License Python versions supported Format pre-commit Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Continuous integration test status Continuous integration test coverage

sphinxcontrib-shellcheck

The shellcheck Sphinx builder is an extension that uses the shellcheck utility to lint shell code in the documentation.

Interpreter

The extension has been developed and tested with Python 3.5, 3.6, 3.7, and 3.8 under Linux (Debian, Ubuntu), Apple macOS and Microsoft Windows

Installation

The extension is on PyPI, so:

$ pip install sphinxcontrib-shellcheck

Add the shellcheck extension to the extension list in your Sphinx conf.py file to enable it:

extensions = [
    ...,
    "sphinxcontrib.shellcheck",
    ...,
]

Usage

For example, if a reStructuredText file example.rst has the following content:

Follow these instructions:

    .. code-block:: bash

        $ github_user=myname
        $ git clone \
              https://github.com/"${github_user}"/ \
              myrepo.git
        Cloning into 'myrepo'...
        ...
        $ cd myrepo
        $ export MYREPO_DIR=${PWD}
        $ echo "${myvar}"

And all will be good

Then with the extension installed:

$ sphinx-build -b shellcheck . _build example.rst
Running Sphinx v1.8.3
making output directory...
building [mo]: targets for 0 po files that are specified
building [shellcheck]: 1 source files given on command line
updating environment: 4 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
example.rst
Line 11, column 11 [2164]: Use cd ... || exit in case cd fails.
Line 13, column 17 [2154]: myvar is referenced but not assigned.
build succeeded.

Look for any errors in the above output or in _build/shellcheck/output.txt

Configuration variables

These are the configurable variables of the extension:

  • shellcheck_dialects (list of strings): shell dialects to be linted. The default dialects are those supported by shellcheck, ["sh", "bash", "dash", "ksh"], and only a subset of these is valid.

  • shellcheck_executable (string): name of the shellcheck executable (potentially full path to it too). The default is "shellcheck".

  • shellcheck_prompt (string): single character representing the terminal prompt. The default is $.

  • shellcheck_debug (integer): flag that indicates whether debug information shall be printed via the Sphinx logger (1) or not (0). The default is 0. This configuration option is only useful while developing the extension.

These configuration variables can be overridden via the Sphinx configuration file conf.py, or via the -D option of the sphinx-build command. For example:

$ sphinx-build -b shellcheck \
   -D shellcheck_dialects=bash,ksh \
   -D shellcheck_executable=shellcheck-stable \
   -D shellcheck_prompt=$ \
   -D shellcheck_debug=1 \
   . _build example.rst

License

The MIT License (MIT)

Copyright (c) 2018-2020, Pablo Acosta-Serafini All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Changelog

  • 1.1.2 [March 29, 2020] Fixed documentation link

  • 1.1.1 [March 29, 2020] Fixed distribution bugs

  • 1.1.0 [March 29, 2020] Dropped support for Python 2.7. Added support for Python 3.8. Fixed continuous integration bugs.

  • 1.0.10 [March 27, 2019] Correctly set exit code when there are errors

  • 1.0.9 [March 18, 2019] Changed debug parameter default status

  • 1.0.8 [March 17, 2019] Package management update

  • 1.0.7 [March 17, 2019] Package management update

  • 1.0.6 [March 17, 2019] Added check of shellcheck minimum version. Updated package management and testing framework

  • 1.0.5 [January 4, 2019] Initial public release

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

sphinxcontrib-shellcheck-1.1.2.zip (338.7 kB view details)

Uploaded Source

Built Distributions

sphinxcontrib_shellcheck-1.1.2-py38-none-any.whl (11.5 kB view details)

Uploaded Python 3.8

sphinxcontrib_shellcheck-1.1.2-py37-none-any.whl (11.5 kB view details)

Uploaded Python 3.7

sphinxcontrib_shellcheck-1.1.2-py36-none-any.whl (11.5 kB view details)

Uploaded Python 3.6

sphinxcontrib_shellcheck-1.1.2-py35-none-any.whl (11.5 kB view details)

Uploaded Python 3.5

File details

Details for the file sphinxcontrib-shellcheck-1.1.2.zip.

File metadata

  • Download URL: sphinxcontrib-shellcheck-1.1.2.zip
  • Upload date:
  • Size: 338.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for sphinxcontrib-shellcheck-1.1.2.zip
Algorithm Hash digest
SHA256 475a3ae12a1cfc1bc26cff57f0dd15561213818e3b470b3eacc4bb8be7b129c0
MD5 1f2f57a5d9b0bdbadff878c89e6ad27f
BLAKE2b-256 ef2b20717a5e0c7ee99dfd5fcdf11a8cf0ab02533cf62775f24d344ea5cf48c1

See more details on using hashes here.

File details

Details for the file sphinxcontrib_shellcheck-1.1.2-py38-none-any.whl.

File metadata

  • Download URL: sphinxcontrib_shellcheck-1.1.2-py38-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for sphinxcontrib_shellcheck-1.1.2-py38-none-any.whl
Algorithm Hash digest
SHA256 4c5f2840418cd1d7d662c0b3f51a07625f1a8f92755b19347ce85e8258e9d847
MD5 ff8191f56451ee327e2a3fd2da0b280a
BLAKE2b-256 58bacf15480bc238a15e10604ee7f0e3e20ea0bf9a55a4f0b4e50571e8d13e60

See more details on using hashes here.

File details

Details for the file sphinxcontrib_shellcheck-1.1.2-py37-none-any.whl.

File metadata

  • Download URL: sphinxcontrib_shellcheck-1.1.2-py37-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for sphinxcontrib_shellcheck-1.1.2-py37-none-any.whl
Algorithm Hash digest
SHA256 46d1aba8201bbfc7a2c51e08446cab36bdab318c997223c8fc40733a5eedc71f
MD5 1f83922ed7f65ce44057615fe0210a71
BLAKE2b-256 9db5cdc74763bcf0916f47d053830c00114f1de65d97ea2281b66bbf2a587b8a

See more details on using hashes here.

File details

Details for the file sphinxcontrib_shellcheck-1.1.2-py36-none-any.whl.

File metadata

  • Download URL: sphinxcontrib_shellcheck-1.1.2-py36-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for sphinxcontrib_shellcheck-1.1.2-py36-none-any.whl
Algorithm Hash digest
SHA256 bcd8ffd26e6430deff9ffd10705683b502ace3fc8b4d1ba84496b3752f65fe52
MD5 e207ef567cc3cd9091b0d61fe4608199
BLAKE2b-256 9f8c833388d3127d8dc0d5558bf52225eb20ed024ac46ef8ef4bffe7298ceb3d

See more details on using hashes here.

File details

Details for the file sphinxcontrib_shellcheck-1.1.2-py35-none-any.whl.

File metadata

  • Download URL: sphinxcontrib_shellcheck-1.1.2-py35-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3.5
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for sphinxcontrib_shellcheck-1.1.2-py35-none-any.whl
Algorithm Hash digest
SHA256 c0449dc9402521ab1d05a1b9eb8c9099707da64824341686dab4f620dc688514
MD5 5829e7e0d56c5441907edc8c37bb26c8
BLAKE2b-256 069c1ff7fe5174f944fac0fcb53bdaac7b98d73a98dd2ca800d95af6af9edb9a

See more details on using hashes here.

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