mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-27 10:45:37 -04:00
docs: adjust to pip installation, add code index
This commit is contained in:
parent
0969f342d0
commit
c8d7a5bc1d
13 changed files with 122 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
# CLI Interface
|
||||
|
||||
```{eval-rst}
|
||||
.. click:: main:cli
|
||||
.. click:: kupferbootstrap.main:cli
|
||||
:nested: none
|
||||
:prog: kupferbootstrap
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ orphan: true
|
|||
only used to trigger builds of the submodule docs!
|
||||
|
||||
```{eval-rst}
|
||||
.. currentmodule:: kupferbootstrap
|
||||
.. autosummary::
|
||||
:toctree: cli
|
||||
:template: command.rst
|
||||
|
|
9
docs/source/code.md
Normal file
9
docs/source/code.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Code
|
||||
|
||||
Code documentation is available here
|
||||
|
||||
```{toctree}
|
||||
:glob: true
|
||||
|
||||
code/kupferbootstrap
|
||||
```
|
8
docs/source/codegen.rst
Normal file
8
docs/source/codegen.rst
Normal file
|
@ -0,0 +1,8 @@
|
|||
:nosearch:
|
||||
:orphan:
|
||||
|
||||
.. autosummary::
|
||||
:toctree: code
|
||||
:recursive:
|
||||
|
||||
kupferbootstrap
|
|
@ -1,10 +1,14 @@
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
from sphinx.config import getenv
|
||||
from kupferbootstrap.utils import git
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
#sys.path.insert(0, os.path.abspath('../..'))
|
||||
extensions = [
|
||||
'sphinx_click',
|
||||
'sphinx.ext.autosummary', # Create neat summary tables
|
||||
"sphinx.ext.autodoc",
|
||||
'sphinx.ext.autosummary',
|
||||
"sphinx.ext.linkcode",
|
||||
'myst_parser'
|
||||
]
|
||||
myst_all_links_external = True
|
||||
|
@ -29,4 +33,45 @@ html_theme_options = {
|
|||
"color-brand-content": "#eba38d",
|
||||
"color-problematic": "#ff7564",
|
||||
},
|
||||
"source_repository": "https://gitlab.com/kupfer/kupferbootstrap",
|
||||
"source_directory": "docs/source/",
|
||||
}
|
||||
|
||||
|
||||
autosummary_generate = True
|
||||
autodoc_default_options = {
|
||||
"members": True,
|
||||
"undoc-members": True,
|
||||
"show-inheritance": True,
|
||||
"inherited-members": True,
|
||||
}
|
||||
autodoc_preserve_defaults = True
|
||||
|
||||
|
||||
def get_version():
|
||||
try:
|
||||
res = git(
|
||||
["rev-parse", "HEAD"],
|
||||
dir=os.path.join(os.path.dirname(__file__), "../.."),
|
||||
use_git_dir=True,
|
||||
capture_output=True,
|
||||
)
|
||||
res.check_returncode()
|
||||
ver = res.stdout.decode().strip()
|
||||
logging.info(f"Detected git {ver=}")
|
||||
return ver
|
||||
except Exception as ex:
|
||||
logging.warning("Couldn't get git branch:", exc_info=ex)
|
||||
return "HEAD"
|
||||
|
||||
|
||||
version = getenv("version") or get_version()
|
||||
|
||||
|
||||
def linkcode_resolve(domain, info):
|
||||
if domain != 'py':
|
||||
return None
|
||||
if not info['module']:
|
||||
return None
|
||||
filename = info['module'].replace('.', '/')
|
||||
return "%s/-/blob/%s/src/%s.py" % (html_theme_options["source_repository"], version, filename)
|
||||
|
|
2
docs/source/genindex.rst
Normal file
2
docs/source/genindex.rst
Normal file
|
@ -0,0 +1,2 @@
|
|||
Module Index
|
||||
============
|
|
@ -8,4 +8,6 @@ a tool to build and flash packages and images for the [Kupfer](https://gitlab.co
|
|||
```{toctree}
|
||||
usage/index
|
||||
cli
|
||||
code
|
||||
genindex
|
||||
```
|
||||
|
|
36
docs/source/templates/code.rst
Normal file
36
docs/source/templates/code.rst
Normal file
|
@ -0,0 +1,36 @@
|
|||
{% set reduced_name = fullname.split(".", 1)[-1] if fullname.startswith("kupferbootstrap.") else fullname %}
|
||||
|
||||
{{ fullname | escape | underline }}
|
||||
|
||||
.. rubric:: Description
|
||||
|
||||
.. automodule:: {{ fullname }}
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. currentmodule:: {{ fullname }}
|
||||
|
||||
|
||||
|
||||
|
||||
{% if classes %}
|
||||
.. rubric:: Classes
|
||||
|
||||
.. autosummary::
|
||||
:toctree: .
|
||||
{% for class in classes %}
|
||||
{{ class }}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if functions %}
|
||||
.. rubric:: Functions
|
||||
|
||||
.. autosummary::
|
||||
:toctree: .
|
||||
{% for function in functions %}
|
||||
{{ function }}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
|
@ -1,6 +1,9 @@
|
|||
.. title: {{fullname}}
|
||||
{% set reduced_name = fullname.split(".", 1)[-1] if fullname.startswith("kupferbootstrap.") else fullname %}
|
||||
.. title: {{reduced_name}}
|
||||
|
||||
.. click:: {% if fullname == 'main' %}main:cli{% else %}{{fullname}}.cli:cmd_{{fullname}}{% endif %}
|
||||
:prog: kupferbootstrap {{fullname}}
|
||||
|
||||
.. currentmodule:: {{ fullname }}
|
||||
.. click:: {% if fullname == 'main' %}kupferbootstrap.main:cli{% else %}{{fullname}}.cli:cmd_{{reduced_name}}{% endif %}
|
||||
:prog: kupferbootstrap {{reduced_name}}
|
||||
:nested: full
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue