docs: extract version for the manpage

This commit is contained in:
2025-06-23 18:51:25 +03:00
parent 7769a4a6e0
commit 5b0a8eeb07
7 changed files with 106 additions and 29 deletions

View File

@ -1,6 +1,6 @@
.TH AHRIMAN "1" "2025\-06\-16" "ahriman" "Generated Python Manual"
.TH AHRIMAN "1" "2025\-06\-23" "ahriman 2.18.3" "ArcH linux ReposItory MANager"
.SH NAME
ahriman
ahriman \- ArcH linux ReposItory MANager
.SH SYNOPSIS
.B ahriman
[-h] [-a ARCHITECTURE] [-c CONFIGURATION] [--force] [-l LOCK] [--log-handler {console,syslog,journald}] [-q] [--report | --no-report] [-r REPOSITORY] [--unsafe] [-V] [--wait-timeout WAIT_TIMEOUT] {add,aur-search,check,clean,config,config-validate,copy,daemon,help,help-commands-unsafe,help-updates,help-version,init,key-import,package-add,package-changes,package-changes-remove,package-copy,package-remove,package-status,package-status-remove,package-status-update,package-update,patch-add,patch-list,patch-remove,patch-set-add,rebuild,remove,remove-unknown,repo-backup,repo-check,repo-clean,repo-config,repo-config-validate,repo-create-keyring,repo-create-mirrorlist,repo-daemon,repo-init,repo-rebuild,repo-remove-unknown,repo-report,repo-restore,repo-setup,repo-sign,repo-statistics,repo-status-update,repo-sync,repo-tree,repo-triggers,repo-update,report,run,search,service-clean,service-config,service-config-validate,service-key-import,service-repositories,service-run,service-setup,service-shell,service-tree-migrate,setup,shell,sign,status,status-update,sync,update,user-add,user-list,user-remove,version,web} ...

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2021-2023 ahriman team.
# Copyright (c) 2021-2025 ahriman team.
#
# This file is part of ahriman
# (see https://github.com/arcan1s/ahriman).

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2021-2023 ahriman team.
# Copyright (c) 2021-2025 ahriman team.
#
# This file is part of ahriman
# (see https://github.com/arcan1s/ahriman).

View File

@ -58,23 +58,23 @@ web = [
"aiohttp_cors",
"aiohttp_jinja2",
]
web_api-docs = [
"ahriman[web]",
"aiohttp-apispec",
"setuptools", # required by aiohttp-apispec
]
web_auth = [
web-auth = [
"ahriman[web]",
"aiohttp_session",
"aiohttp_security",
"cryptography",
]
web_metrics = [
web-docs = [
"ahriman[web]",
"aiohttp-apispec",
"setuptools", # required by aiohttp-apispec
]
web-metrics = [
"ahriman[web]",
"aiohttp-openmetrics",
]
web_oauth2 = [
"ahriman[web_auth]",
web-oauth2 = [
"ahriman[web-auth]",
"aioauth-client",
]

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2021-2024 ahriman team.
# Copyright (c) 2021-2025 ahriman team.
#
# This file is part of ahriman
# (see https://github.com/arcan1s/ahriman).

44
tox.ini
View File

@ -1,15 +1,30 @@
[tox]
envlist = check, tests
envlist =
check
tests
isolated_build = true
labels =
release = version, docs, publish
dependencies = -e .[journald,pacman,reports,s3,shell,stats,unixsocket,validator,web,web_api-docs,web_auth,web_oauth2,web_metrics]
extras =
journald
pacman
reports
s3
shell
stats
unixsocket
validator
web
web-auth
web-docs
web-oauth2
web-metrics
project_name = ahriman
[flags]
autopep8 = --max-line-length 120 -aa --in-place
bandit = --configfile .bandit.yml
manpage = --author "ahriman team" --author-email "" --description "ArcH linux ReposItory MANager" --manual-title "ArcH linux ReposItory MANager" --project-name ahriman --url https://github.com/arcan1s/ahriman
manpage = --author "ahriman team" --author-email "" --description "ArcH linux ReposItory MANager" --manual-title "ArcH linux ReposItory MANager" --project-name ahriman --version {env:VERSION} --url https://github.com/arcan1s/ahriman
mypy = --implicit-reexport --strict --allow-untyped-decorators --allow-subclassing-any
pydeps = --no-config --cluster
pylint = --rcfile .pylint.toml
@ -32,8 +47,8 @@ commands =
description = Run common checks like linter, mypy, etc
dependency_groups =
check
deps =
{[tox]dependencies}
extras =
{[tox]extras}
pip_pre = true
setenv =
CFLAGS="-Wno-unterminated-string-initialization"
@ -49,26 +64,25 @@ commands =
description = Generate source files for documentation
allowlist_externals =
bash
find
dependency_groups =
docs
depends =
version
deps =
{[tox]dependencies}
uv
extras =
{[tox]extras}
pip_pre = true
setenv =
PYTHONPATH=src
SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
dynamic_version = ahriman.__version__
commands =
bash -c 'shtab {[flags]shtab} --shell bash > package/share/bash-completion/completions/_ahriman'
bash -c 'shtab {[flags]shtab} --shell zsh > package/share/zsh/site-functions/_ahriman'
argparse-manpage {[flags]manpage} --module ahriman.application.ahriman --function _parser --output ../package/share/man/man1/ahriman.1
argparse-manpage {[flags]manpage} --module ahriman.application.ahriman --function _parser --output package/share/man/man1/ahriman.1
pydeps {[flags]pydeps} --no-output --show-dot --dot-output {tox_root}{/}docs/_static/architecture.dot src/ahriman
# remove autogenerated modules rst files
find docs -type f -name "{[tox]project_name}*.rst" -delete
sphinx-apidoc --output-dir docs src
sphinx-apidoc --force --no-toc --output-dir docs src
# compile list of dependencies for rtd.io
uv pip compile --group pyproject.toml:docs --extra s3 --extra validator --extra web --output-file docs/requirements.txt --quiet pyproject.toml
@ -76,8 +90,8 @@ commands =
description = Generate html documentation
dependency_groups =
docs
deps =
{[tox]dependencies}
extras =
{[tox]extras}
pip_pre = true
recreate = true
commands =
@ -102,8 +116,8 @@ commands =
description = Run tests
dependency_groups =
tests
deps =
{[tox]dependencies}
extras =
{[tox]extras}
pip_pre = true
setenv =
CFLAGS="-Wno-unterminated-string-initialization"

63
toxfile.py Normal file
View File

@ -0,0 +1,63 @@
#
# Copyright (c) 2021-2025 ahriman team.
#
# This file is part of ahriman
# (see https://github.com/arcan1s/ahriman).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import importlib
import sys
from tox.config.sets import EnvConfigSet
from tox.plugin import impl
from tox.session.state import State
from tox.tox_env.api import ToxEnv
@impl
def tox_add_env_config(env_conf: EnvConfigSet, _: State) -> None:
"""
append plugin options to the configuration keys
Args:
env_conf(EnvConfigSet): environment configuration set
"""
env_conf.add_config(
keys=["dynamic_version"],
of_type=str,
default="",
desc="import version from",
)
@impl
def tox_before_run_commands(tox_env: ToxEnv) -> None:
"""
extract version dynamically and set VERSION environment variable
Args:
tox_env(ToxEnv): current tox environment
"""
if not tox_env.conf["dynamic_version"]:
return
set_env = tox_env.conf["set_env"]
if "PYTHONPATH" in set_env:
sys.path.append(set_env.load("PYTHONPATH"))
module_name, variable_name = tox_env.conf["dynamic_version"].rsplit(".", maxsplit=1)
module = importlib.import_module(module_name)
set_env.update({"VERSION": getattr(module, variable_name)})