Skip to content

Commit

Permalink
feat: add example for sphinx-click
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed May 13, 2024
1 parent 22bb89c commit c73c435
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Shibuya uses date based release segments. For pre-releases, it follows :pep:`440
2024.4.27
---------

- **New**: Added integration with :ref:`sqlalchemy`.
- **New**: Added integration with :ref:`sphinx-sqlalchemy`.
- **Fix**: Improve accessibility with ``aria-label``.
- **Fix**: Improve style for nav links and docsearch.
- **Breaking**: Fix typo of ``Lucide`` icons.
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"numpydoc",
"sphinx_sitemap",
"sphinxcontrib.mermaid",
"sphinx_click",
"sphinx_sqlalchemy",
]
todo_include_todos = True
Expand Down
3 changes: 2 additions & 1 deletion docs/contributing/roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Make sure it works well with other extensions. Currently integrated with:
- :bdg-success:`DONE` :ref:`numpydoc`
- :bdg-success:`DONE` ``sphinx-gallery``
- :bdg-success:`DONE` :ref:`sphinxcontrib-mermaid`
- :bdg-success:`DONE` :ref:`sqlalchemy`
- :bdg-success:`DONE` :ref:`sphinx-sqlalchemy`
- :bdg-success:`DONE` :ref:`sphinx-click`

Instant search
--------------
Expand Down
17 changes: 17 additions & 0 deletions docs/example_code/click_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import click

@click.group()
def greet():
"""A sample command group."""
pass

@greet.command()
@click.argument('user', envvar='USER')
def hello(user):
"""Greet a user."""
click.echo('Hello %s' % user)

@greet.command()
def world():
"""Greet the world."""
click.echo('Hello world!')
40 changes: 40 additions & 0 deletions docs/extensions/sphinx-click.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. _sphinx-click:

sphinx-click
=================

sphinx-click is a Sphinx plugin that allows you to automatically extract documentation
from a click-based application and include it in your docs.

- **Documentation**: https://sphinx-click.readthedocs.io/
- **Source Code**: https://github.com/click-contrib/sphinx-click

Usage
-----

Install ``sphinx-click``:

.. code-block:: bash
pip install sphinx-click
Add ``sphinx_click`` to your ``conf.py``:

.. code-block:: python
extensions = [
'sphinx_click',
]
Example
-------

.. code-block:: none
.. click:: click_demo:greet
:prog: greet
:nested: full
.. click:: click_demo:greet
:prog: greet
:nested: full
2 changes: 1 addition & 1 deletion docs/extensions/sphinx-sqlalchemy.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _sqlalchemy:
.. _sphinx-sqlalchemy:

sphinx-sqlalchemy
=================
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Shibuya
extensions/numpydoc
extensions/mermaid
extensions/docsearch
extensions/sphinx-click
extensions/sphinx-sqlalchemy

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jupyter-sphinx
sphinx-togglebutton
sphinxcontrib-mermaid
sphinx-docsearch
sphinx-click
nbsphinx
myst-parser
numpy
Expand Down

0 comments on commit c73c435

Please sign in to comment.