Skip to content

docs(cli): add auto-generated CLI reference #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/gitlab.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gitlab package
==============
API reference (``gitlab`` package)
==================================

Subpackages
-----------
Expand Down
17 changes: 17 additions & 0 deletions docs/cli-objects.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##################################
CLI reference (``gitlab`` command)
##################################

.. warning::

The following is a complete, auto-generated list of subcommands available
via the :command:`gitlab` command-line tool. Some of the actions may
currently not work as expected or lack functionality available via the API.

Please see the existing `list of CLI related issues`_, or open a new one if
it is not already listed there.

.. _list of CLI related issues: https://github.com/python-gitlab/python-gitlab/issues?q=is%3Aopen+is%3Aissue+label%3Acli

.. autoprogram:: gitlab.cli:docs()
:prog: gitlab
4 changes: 4 additions & 0 deletions docs/cli.rst → docs/cli-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ Example:
Examples
========

**Notice:**

For a complete list of objects and actions available, see :doc:`/cli-objects`.

List the projects (paginated):

.. code-block:: console
Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary", "ext.docstrings"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"ext.docstrings",
"sphinxcontrib.autoprogram",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ Contents:
:maxdepth: 2

install
cli
cli-usage
api-usage
faq
switching-to-v4
api-objects
api/gitlab
cli-objects
release_notes
changelog
switching-to-v4


Indices and tables
Expand Down
14 changes: 14 additions & 0 deletions gitlab/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ def _parse_value(v):
return v


def docs():
"""
Provide a statically generated parser for sphinx only, so we don't need
to provide dummy gitlab config for readthedocs.
"""
if "sphinx" not in sys.modules:
sys.exit("Docs parser is only intended for build_sphinx")

parser = _get_base_parser(add_help=False)
cli_module = importlib.import_module("gitlab.v4.cli")

return _get_parser(cli_module)


def main():
if "--version" in sys.argv:
print(gitlab.__version__)
Expand Down
2 changes: 2 additions & 0 deletions rtd-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r requirements.txt
jinja2
sphinx==3.2.1
sphinx_rtd_theme
sphinxcontrib-autoprogram
3 changes: 0 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
coverage
httmock
jinja2
mock
pytest
pytest-cov
sphinx==3.2.1
sphinx_rtd_theme
responses
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ max-line-length = 88
ignore = H501,H803

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

[testenv:cover]
Expand Down