Skip to content

Commit 6c21fc8

Browse files
committed
docs(cli): add auto-generated CLI reference
1 parent 68a4162 commit 6c21fc8

9 files changed

+49
-8
lines changed

docs/api/gitlab.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
gitlab package
2-
==============
1+
API reference (``gitlab`` package)
2+
==================================
33

44
Subpackages
55
-----------

docs/cli-objects.rst

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##################################
2+
CLI reference (``gitlab`` command)
3+
##################################
4+
5+
.. warning::
6+
7+
The following is a complete, auto-generated list of subcommands available
8+
via the :command:`gitlab` command-line tool. Some of the actions may
9+
currently not work as expected or lack functionality available via the API.
10+
11+
Please see the existing `list of CLI related issues`_, or open a new one if
12+
it is not already listed there.
13+
14+
.. _list of CLI related issues: https://github.com/python-gitlab/python-gitlab/issues?q=is%3Aopen+is%3Aissue+label%3Acli
15+
16+
.. autoprogram:: gitlab.cli:docs()
17+
:prog: gitlab

docs/cli.rst renamed to docs/cli-usage.rst

+4
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ Example:
180180
Examples
181181
========
182182

183+
**Notice:**
184+
185+
For a complete list of objects and actions available, see :doc:`/cli-objects`.
186+
183187
List the projects (paginated):
184188

185189
.. code-block:: console

docs/conf.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
# Add any Sphinx extension module names here, as strings. They can be
4040
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4141
# ones.
42-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary", "ext.docstrings"]
42+
extensions = [
43+
"sphinx.ext.autodoc",
44+
"sphinx.ext.autosummary",
45+
"ext.docstrings",
46+
"sphinxcontrib.autoprogram",
47+
]
4348

4449
# Add any paths that contain templates here, relative to this directory.
4550
templates_path = ["_templates"]

docs/index.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ Contents:
1212
:maxdepth: 2
1313

1414
install
15-
cli
15+
cli-usage
1616
api-usage
1717
faq
18-
switching-to-v4
1918
api-objects
2019
api/gitlab
20+
cli-objects
2121
release_notes
2222
changelog
23+
switching-to-v4
2324

2425

2526
Indices and tables

gitlab/cli.py

+14
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ def _parse_value(v):
149149
return v
150150

151151

152+
def docs():
153+
"""
154+
Provide a statically generated parser for sphinx only, so we don't need
155+
to provide dummy gitlab config for readthedocs.
156+
"""
157+
if "sphinx" not in sys.modules:
158+
sys.exit("Docs parser is only intended for build_sphinx")
159+
160+
parser = _get_base_parser(add_help=False)
161+
cli_module = importlib.import_module("gitlab.v4.cli")
162+
163+
return _get_parser(cli_module)
164+
165+
152166
def main():
153167
if "--version" in sys.argv:
154168
print(gitlab.__version__)

rtd-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
-r requirements.txt
22
jinja2
33
sphinx==3.2.1
4+
sphinx_rtd_theme
5+
sphinxcontrib-autoprogram

test-requirements.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
coverage
22
httmock
3-
jinja2
43
mock
54
pytest
65
pytest-cov
7-
sphinx==3.2.1
8-
sphinx_rtd_theme
96
responses

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ max-line-length = 88
4444
ignore = H501,H803
4545

4646
[testenv:docs]
47+
deps = -r{toxinidir}/rtd-requirements.txt
4748
commands = python setup.py build_sphinx
4849

4950
[testenv:cover]

0 commit comments

Comments
 (0)