WIP CHANGES

This commit is contained in:
InsanePrawn 2024-03-17 17:38:30 +01:00
parent 5e10565c70
commit 3ffe702301
8 changed files with 66 additions and 16 deletions

View file

@ -14,7 +14,7 @@ cleanbuild:
@$(MAKE) html @$(MAKE) html
clean: clean:
rm -rf html source/cli .buildinfo .doctrees versions checkouts rm -rf html source/cli source/code .buildinfo .doctrees versions checkouts
html: html:
sphinx-build $(SPHINXARGS) $(buildargs) html sphinx-build $(SPHINXARGS) $(buildargs) html

View file

@ -1,7 +1,7 @@
# CLI Interface # CLI Interface
```{eval-rst} ```{eval-rst}
.. click:: main:cli .. click:: kupferbootstrap.main:cli
:nested: none :nested: none
:prog: kupferbootstrap :prog: kupferbootstrap

View file

@ -6,6 +6,7 @@ orphan: true
only used to trigger builds of the submodule docs! only used to trigger builds of the submodule docs!
```{eval-rst} ```{eval-rst}
.. currentmodule:: kupferbootstrap
.. autosummary:: .. autosummary::
:toctree: cli :toctree: cli
:template: command.rst :template: command.rst

View file

@ -1,10 +1,14 @@
import logging
import os 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 = [ extensions = [
'sphinx_click', 'sphinx_click',
'sphinx.ext.autosummary', # Create neat summary tables "sphinx.ext.autodoc",
'sphinx.ext.autosummary',
"sphinx.ext.linkcode",
'myst_parser' 'myst_parser'
] ]
myst_all_links_external = True myst_all_links_external = True
@ -29,4 +33,45 @@ html_theme_options = {
"color-brand-content": "#eba38d", "color-brand-content": "#eba38d",
"color-problematic": "#ff7564", "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)

View file

@ -8,4 +8,6 @@ a tool to build and flash packages and images for the [Kupfer](https://gitlab.co
```{toctree} ```{toctree}
usage/index usage/index
cli cli
code
genindex
``` ```

View file

@ -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 :nested: full

View file

@ -205,15 +205,12 @@ def parse_kernel_suffix(deviceinfo: dict[str, Optional[str]], kernel: str = 'mai
https://wiki.postmarketos.org/wiki/Device_specific_package#Multiple_kernels https://wiki.postmarketos.org/wiki/Device_specific_package#Multiple_kernels
:param info: deviceinfo dict, e.g.: :param info: deviceinfo dict, e.g.:
{"a": "first", {"a": "first", "b_mainline": "second", "b_downstream": "third"}
"b_mainline": "second",
"b_downstream": "third"}
:param device: which device info belongs to :param device: which device info belongs to
:param kernel: which kernel suffix to remove (e.g. "mainline") :param kernel: which kernel suffix to remove (e.g. "mainline")
:returns: info, but with the configured kernel suffix removed, e.g: :returns: info, but with the configured kernel suffix removed, e.g:
{"a": "first", {"a": "first", "b": "second", "b_downstream": "third"}
"b": "second",
"b_downstream": "third"}
""" """
# Do nothing if the configured kernel isn't available in the kernel (e.g. # Do nothing if the configured kernel isn't available in the kernel (e.g.
# after switching from device with multiple kernels to device with only one # after switching from device with multiple kernels to device with only one

View file

@ -57,10 +57,12 @@ def wrap_if_foreign_arch(arch: Arch):
def execute_without_exit(f, argv_override: Optional[list[str]], *args, **kwargs): def execute_without_exit(f, argv_override: Optional[list[str]], *args, **kwargs):
"""If no wrap is needed, executes and returns f(*args, **kwargs). """
If no wrap is needed, executes and returns `f(*args, **kwargs)`.
If a wrap is determined to be necessary, force a wrap with argv_override applied. If a wrap is determined to be necessary, force a wrap with argv_override applied.
If a wrap was forced, None is returned. If a wrap was forced, None is returned.
WARNING: No protection against f() returning None is taken.""" WARNING: No protection against f() returning None is taken.
"""
if not needs_wrap(): if not needs_wrap():
return f(*args, **kwargs) return f(*args, **kwargs)
assert get_wrapper_type() != 'none', "needs_wrap() should've returned False" assert get_wrapper_type() != 'none', "needs_wrap() should've returned False"