Skip to content

Commit 00a2beb

Browse files
committed
docs: add CLI output with color to page
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
1 parent 4910b64 commit 00a2beb

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/conf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
# Add any Sphinx extension module names here, as strings. They can be
1818
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
1919
extensions = [
20+
"erbsland.sphinx.ansi",
2021
"sphinx.ext.autodoc",
2122
"sphinx.ext.doctest",
2223
"sphinx.ext.extlinks",
2324
"sphinx.ext.intersphinx",
25+
"sphinxcontrib.programoutput",
2426
]
2527

2628
# General information about the project.
@@ -103,3 +105,14 @@
103105
"python": ("https://docs.python.org/3/", None),
104106
"pypug": ("https://packaging.python.org/", None),
105107
}
108+
109+
110+
# -- Options for programout ----------------------------------------------------------
111+
# https://sphinxcontrib-programoutput.readthedocs.io
112+
113+
programoutput_use_ansi = True
114+
115+
# Needed to ensure color output
116+
# See https://github.com/OpenNTI/sphinxcontrib-programoutput/issues/77
117+
os.environ["FORCE_COLOR"] = "1"
118+
os.environ.pop("NO_COLOR", None)

docs/version.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,17 @@ Reference
5252
.. automodule:: packaging.version
5353
:members:
5454
:special-members:
55+
56+
57+
CLI
58+
---
59+
60+
A CLI utility is provided:
61+
62+
.. program-output:: python -m packaging.version --help
63+
64+
You can compare two versions:
65+
66+
.. program-output:: python -m packaging.version compare --help
67+
68+
.. versionadded:: 26.1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ test = [
4646
"tomli_w",
4747
]
4848
docs = [
49+
"erbsland-sphinx-ansi; python_version>='3.10'",
4950
"furo",
51+
"sphinx",
52+
"sphinxcontrib-programoutput >=0.19",
5053
"typing-extensions>=4.1.0; python_version < '3.9'",
5154
]
5255
benchmark = [

0 commit comments

Comments
 (0)