From d2c6c6b8527bf40016eee7931515efbb061d313e Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 12 Jan 2021 15:42:49 +0000 Subject: [PATCH] Make use of newer sphinxcontrib-programoutput2 extension The newer version of programoutput does render ANSI escapes from our examples, making them easier to read. Also swaps the codeclimate docs example with a smaller one, as we do need to display a big file to demonstrate this functionality. --- docs/conf.py | 24 +++++++++++++++++++----- docs/requirements.in | 2 +- docs/requirements.txt | 10 +++++----- docs/usage.rst | 4 ++-- test-requirements.txt | 6 +++--- tox.ini | 4 ++++ 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 98d9ffa9072..9295e17a660 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,6 +18,8 @@ import sys from pathlib import Path +import pkg_resources + # Make in-tree extension importable in non-tox setups/envs, like RTD. # Refs: # https://github.com/readthedocs/readthedocs.org/issues/6311 @@ -55,6 +57,18 @@ 'rules_table_generator_ext', # in-tree extension ] + +# Fail safe protection to detect conflicting packages +try: + pkg_resources.get_distribution("sphinxcontrib-programoutput") + print( + "FATAL: We detected presence of sphinxcontrib-programoutput package instead of sphinxcontrib-programoutput2 one. You must be sure the first is not installed.", + file=sys.stderr, + ) + sys.exit(2) +except pkg_resources.DistributionNotFound: + pass + # Later on, add 'sphinx.ext.viewcode' to the list if you want to have # colorized code generated too for references. @@ -251,8 +265,8 @@ # table width fix via: https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html html_static_path = ['_static'] -html_context = { - 'css_files': [ - '_static/theme_overrides.css', # override wide tables in RTD theme - ], -} + +html_css_files = [ + 'theme_overrides.css', # override wide tables in RTD theme + 'ansi.css', +] diff --git a/docs/requirements.in b/docs/requirements.in index ca6999e2735..4ba7e12edec 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -3,4 +3,4 @@ myst-parser pipdeptree Sphinx sphinx_ansible_theme -sphinxcontrib.programoutput +sphinxcontrib-programoutput2>=2.0a1 diff --git a/docs/requirements.txt b/docs/requirements.txt index fc114a3d794..771847701ee 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -27,27 +27,27 @@ myst-parser==0.13.5 packaging==20.9 pipdeptree==2.0.0 pycparser==2.20 -pygments==2.8.0 +pygments==2.8.1 pyparsing==2.4.7 pytz==2021.1 pyyaml==5.4.1 requests==2.25.1 -rich==9.12.4 +rich==9.13.0 snowballstemmer==2.1.0 sphinx-ansible-theme==0.3.2 sphinx-notfound-page==0.6 sphinx-rtd-theme==0.5.1 -sphinx==3.5.1 +sphinx==3.5.2 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-programoutput2==2.0a1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.4 -sphinxcontrib.programoutput==0.16 typing-extensions==3.7.4.3 urllib3==1.26.3 -wcmatch==8.1.1 +wcmatch==8.1.2 # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/docs/usage.rst b/docs/usage.rst index 3816bd66838..1b6f45ed5cb 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -100,14 +100,14 @@ the following: If playbooks include other playbooks, or tasks, or handlers or roles, these are also handled: -.. command-output:: ansible-lint --offline -p examples/playbooks/include.yml +.. command-output:: ansible-lint --force-color --offline -p examples/playbooks/include.yml :cwd: .. :returncode: 2 :nostderr: A codeclimate report in JSON format can be generated with ansible-lint. -.. command-output:: ansible-lint -f codeclimate examples/playbooks/example.yml +.. command-output:: ansible-lint -f codeclimate examples/playbooks/norole.yml :cwd: .. :returncode: 2 :nostderr: diff --git a/test-requirements.txt b/test-requirements.txt index e6e18abe4ae..bd04fb583dc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -17,17 +17,17 @@ iniconfig==1.1.1 packaging==20.9 pluggy==0.13.1 py==1.10.0 -pygments==2.8.0 +pygments==2.8.1 pyparsing==2.4.7 pytest-cov==2.11.1 pytest-forked==1.3.0 pytest-xdist==2.2.1 pytest==6.2.2 pyyaml==5.4.1 -rich==9.12.4 +rich==9.13.0 toml==0.10.2 typing-extensions==3.7.4.3 -wcmatch==8.1.1 +wcmatch==8.1.2 # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/tox.ini b/tox.ini index 49f741cf806..07765945bbb 100644 --- a/tox.ini +++ b/tox.ini @@ -51,11 +51,15 @@ passenv = PY_COLORS REQUESTS_CA_BUNDLE # https proxies SSL_CERT_FILE # https proxies + LANG + LC_ALL + LC_CTYPE # recreate = True setenv = COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} PIP_DISABLE_PIP_VERSION_CHECK = 1 PRE_COMMIT_COLOR = always + FORCE_COLOR = 1 whitelist_externals = sh