docs: correct crossreference in docs

This commit is contained in:
2023-11-05 04:32:05 +02:00
parent 6b755b4828
commit dc2eebce39
41 changed files with 244 additions and 137 deletions

View File

@ -32,8 +32,8 @@ class Application(ApplicationPackages, ApplicationRepository):
base application class
Examples:
This class groups ``Repository`` methods into specific method which process all supposed actions caused by
underlying action. E.g.::
This class groups :class:`ahriman.core.repository.repository.Repository` methods into specific method which
process all supposed actions caused by underlying action. E.g.::
>>> from ahriman.core.configuration import Configuration
>>> from ahriman.models.package_source import PackageSource
@ -49,8 +49,8 @@ class Application(ApplicationPackages, ApplicationRepository):
>>> # updates for specified packages
>>> application.update(updates)
In case if specific actions or their order are required, the direct access to ``Repository`` must
be used instead.
In case if specific actions or their order are required, the direct access to
:class:`ahriman.core.repository.repository.Repository` must be used instead.
"""
def _known_packages(self) -> set[str]:
@ -117,7 +117,7 @@ class Application(ApplicationPackages, ApplicationRepository):
Returns:
list[Package]: updated packages list. Packager for dependencies will be copied from
original package
original package
"""
def missing_dependencies(source: Iterable[Package]) -> dict[str, str | None]:
# append list of known packages with packages which are in current sources

View File

@ -39,8 +39,8 @@ class Handler:
ALLOW_MULTI_ARCHITECTURE_RUN(bool): (class attribute) allow running with multiple architectures
Examples:
Wrapper for all command line actions, though each derived class implements ``run`` method, it usually must not
be called directly. The recommended way is to call ``execute`` class method, e.g.::
Wrapper for all command line actions, though each derived class implements :func:`run()` method, it usually
must not be called directly. The recommended way is to call :func:`execute()` class method, e.g.::
>>> from ahriman.application.handlers import Add
>>>

View File

@ -28,15 +28,16 @@ class Remote(SyncHttpClient):
Examples:
These classes are designed to be used without instancing. In order to achieve it several class methods are
provided: ``info``, ``multisearch`` and ``search``. Thus, the basic flow is the following::
provided: :func:`info()`, :func:`multisearch()` and :func:`search()`. Thus, the basic flow is the following::
>>> from ahriman.core.alpm.remote import AUR, Official
>>>
>>> package = AUR.info("ahriman", pacman=pacman)
>>> search_result = Official.multisearch("pacman", "manager", pacman=pacman)
Differnece between ``search`` and ``multisearch`` is that ``search`` passes all arguments to underlying wrapper
directly, whereas ``multisearch`` splits search one by one and finds intersection between search results.
Differnece between :func:`search()` and :func:`multisearch()` is that :func:`search()` passes all arguments to
underlying wrapper directly, whereas :func:`multisearch()` splits search one by one and finds intersection
between search results.
"""
@classmethod

View File

@ -45,8 +45,8 @@ class Configuration(configparser.RawConfigParser):
Examples:
Configuration class provides additional method in order to handle application configuration. Since this class is
derived from built-in ``configparser.RawConfigParser`` class, the same flow is applicable here. Nevertheless,
it is recommended to use ``from_path`` class method which also calls initialization methods::
derived from built-in :class:`configparser.RawConfigParser` class, the same flow is applicable here.
Nevertheless, it is recommended to use :func:`from_path` class method which also calls initialization methods::
>>> from pathlib import Path
>>>
@ -57,8 +57,8 @@ class Configuration(configparser.RawConfigParser):
The configuration instance loaded in this way will contain only sections which are defined for the specified
architecture according to the merge rules. Moreover, the architecture names will be removed from section names.
In order to get current settings, the ``check_loaded`` method can be used. This method will raise an
``InitializeError`` in case if configuration was not yet loaded::
In order to get current settings, the :func:`check_loaded` method can be used. This method will raise an
:exc:`ahriman.core.exceptions.InitializeError` in case if configuration was not yet loaded::
>>> path, repository_id = configuration.check_loaded()
"""
@ -73,7 +73,7 @@ class Configuration(configparser.RawConfigParser):
default constructor. In the most cases must not be called directly
Args:
allow_no_value(bool, optional): copies ``configparser.RawConfigParser`` behaviour. In case if it is set
allow_no_value(bool, optional): copies :class:`configparser.RawConfigParser` behaviour. In case if it is set
to ``True``, the keys without values will be allowed (Default value = False)
"""
configparser.RawConfigParser.__init__(
@ -344,7 +344,7 @@ class Configuration(configparser.RawConfigParser):
def set_option(self, section: str, option: str, value: str) -> None:
"""
set option. Unlike default ``configparser.RawConfigParser.set`` it also creates section if it does not exist
set option. Unlike default :func:`configparser.RawConfigParser.set` it also creates section if it does not exist
Args:
section(str): section name

View File

@ -46,6 +46,6 @@ class ShellInterpolator(configparser.Interpolation):
"""
# At the moment it seems that it is the most legit way to handle environment variables
# Template behaviour is literally the same as shell
# In addition, we are using shell-like variables in some cases (see ``alpm.mirror`` option), thus we would like
# to keep them alive
# In addition, we are using shell-like variables in some cases (see :attr:`alpm.mirror` option),
# thus we would like to keep them alive
return Template(value).safe_substitute(os.environ)

View File

@ -35,7 +35,7 @@ class SQLite(AuthOperations, BuildOperations, LogsOperations, PackageOperations,
Examples:
Database wrapper must be used together with migration and SQLite3 setup. In order to perform it there is
``load`` class method::
:func:`load()` class method::
>>> from ahriman.core.configuration import Configuration
>>>

View File

@ -62,7 +62,7 @@ class BuildError(RuntimeError):
class CalledProcessError(subprocess.CalledProcessError):
"""
like ``subprocess.CalledProcessError``, but better
like :exc:`subprocess.CalledProcessError`, but better
"""
def __init__(self, status_code: int, process: list[str], stderr: str) -> None:

View File

@ -69,7 +69,7 @@ class Printer:
def __call__(self, *, verbose: bool, log_fn: Callable[[str], None] = _print, separator: str = ": ") -> None:
"""
print content. Shortcut for ``Printer.print``
print content. Shortcut for :func:`print()`
Args:
verbose(bool): print all fields

View File

@ -27,8 +27,8 @@ from ahriman.models.repository_id import RepositoryId
class HttpLogHandler(logging.Handler):
"""
handler for the http logging. Because default ``logging.handlers.HTTPHandler`` does not support cookies
authorization, we have to implement own handler which overrides the ``logging.handlers.HTTPHandler.emit`` method
handler for the http logging. Because default :class:`logging.handlers.HTTPHandler` does not support cookies
authorization, we have to implement own handler which overrides the :func:`logging.handlers.HTTPHandler.emit` method
Attributes:
reporter(Client): build status reporter instance

View File

@ -46,9 +46,11 @@ class LogLoader:
def handler(selected: LogHandler | None) -> LogHandler:
"""
try to guess default log handler. In case if ``selected`` is set, it will return specified value with appended
_handler suffix. Otherwise, it will try to import journald handler and returns ``journald_handler`` if library
is available. Otherwise, it will check if there is ``/dev/log`` device and returns ``syslog_handler`` in this
case. And, finally, it will fall back to ``console_handler`` if none were found
_handler suffix. Otherwise, it will try to import journald handler and returns
:attr:`ahriman.models.log_handler.LogHandler.Journald` if library is available. Otherwise, it will check if
there is ``/dev/log`` device and returns :attr:`ahriman.models.log_handler.LogHandler.Syslog` in this
case. And, finally, it will fall back to :attr:`ahriman.models.log_handler.LogHandler.Console`
if none were found
Args:
selected(LogHandler | None): user specified handler if any

View File

@ -37,14 +37,14 @@ class Report(LazyLogging):
repository_id(RepositoryId): repository unique identifier
Examples:
``Report`` classes provide several method in order to operate with the report generation and additional class
method ``load`` which can be used in order to determine right report instance::
:class:`Report` subclasses provide several method in order to operate with the report generation and additional
class method :func:`load()` which can be used in order to determine right report instance::
>>> configuration = Configuration()
>>> report = Report.load(RepositoryId("x86_64", "aur-clone"), configuration, "email")
The ``generate`` method can be used in order to perform the report itself, whereas ``run`` method handles
exception and raises ``ReportFailed`` instead::
The :func:`generate()` method can be used in order to perform the report itself, whereas :func:`run()` method
handles exception and raises :exc:`ahriman.core.exceptions.ReportError` instead::
>>> try:
>>> report.generate([], Result())

View File

@ -213,7 +213,7 @@ class GPG(SyncHttpClient):
sign repository if required by configuration
Notes:
More likely you just want to pass ``repository_sign_args`` to repo wrapper
More likely you just want to pass :attr:`repository_sign_args` to repo wrapper
Args:
path(Path): path to repository database

View File

@ -83,7 +83,8 @@ class Spawn(Thread, LazyLogging):
helper to run external process
Args:
callback(Callable[[argparse.Namespace, str], bool]): application run function (i.e. ``Handler.call`` method)
callback(Callable[[argparse.Namespace, str], bool]): application run function
(i.e. :func:`ahriman.application.handlers.handler.Handler.call()` method)
args(argparse.Namespace): command line arguments
repository_id(RepositoryId): repository unique identifier
process_id(str): process unique identifier
@ -149,7 +150,7 @@ class Spawn(Thread, LazyLogging):
check if given process is alive
Args:
process_id(str): process id to be checked as returned by ``Spawn._spawn_process``
process_id(str): process id to be checked as returned by :func:`_spawn_process()`
Returns:
bool: True in case if process still counts as active and False otherwise

View File

@ -104,7 +104,7 @@ class Client:
def package_update(self, package_base: str, status: BuildStatusEnum) -> None:
"""
update package build status. Unlike ``add`` it does not update package properties
update package build status. Unlike :func:`package_add()` it does not update package properties
Args:
package_base(str): package base to update

View File

@ -33,8 +33,8 @@ class Watcher(LazyLogging):
Attributes:
database(SQLite): database instance
known(dict[str, tuple[Package, BuildStatus]]): list of known packages. For the most cases ``packages`` should
be used instead
known(dict[str, tuple[Package, BuildStatus]]): list of known packages. For the most cases :attr:`packages`
should be used instead
repository_id(RepositoryId): repository unique identifier
status(BuildStatus): daemon status
"""

View File

@ -245,7 +245,7 @@ class WebClient(Client, SyncHttpClient):
def package_update(self, package_base: str, status: BuildStatusEnum) -> None:
"""
update package build status. Unlike ``add`` it does not update package properties
update package build status. Unlike :func:`package_add()` it does not update package properties
Args:
package_base(str): package base to update

View File

@ -182,7 +182,7 @@ class Tree:
Returns:
list[list[Package]]: list of packages lists based on their dependencies. The amount of elements in each
sublist is less or equal to ``count``
sublist is less or equal to ``count``
Raises:
PartitionError: in case if it is impossible to divide tree by specified amount of partitions

View File

@ -88,8 +88,8 @@ class TriggerLoader(LazyLogging):
@staticmethod
def known_triggers(configuration: Configuration) -> list[str]:
"""
read configuration and return list of known triggers. Unlike ``selected_triggers`` this option is used mainly
for configuration and validation and mentioned triggers are not being executed automatically
read configuration and return list of known triggers. Unlike :func:`selected_triggers()` this option is used
mainly for configuration and validation and mentioned triggers are not being executed automatically
Args:
configuration(Configuration): configuration instance
@ -141,7 +141,7 @@ class TriggerLoader(LazyLogging):
"""
self.logger.info("load module %s from path %s", implementation, module_path)
# basically this method is called only if ``module_path`` exists and is file.
# Thus, this method should never throw ``FileNotFoundError`` exception
# Thus, this method should never throw :exc:`FileNotFoundError` exception
loader = machinery.SourceFileLoader(implementation, module_path)
module = ModuleType(loader.name)
loader.exec_module(module)

View File

@ -39,14 +39,14 @@ class Upload(LazyLogging):
Examples:
These classes provide the way to upload packages to remote sources as it is described in their implementations.
Basic flow includes class instantiating by using the ``load`` method and then calling the ``run`` method which
wraps any internal exceptions into the ``SyncFailed`` exception::
Basic flow includes class instantiating by using the :func:`load` method and then calling the :func:`run` method
which wraps any internal exceptions into the :exc:`ahriman.core.exceptions.SynchronizationError` exception::
>>> configuration = Configuration()
>>> upload = Upload.load(RepositoryId("x86_64", "aur-clone"), configuration, "s3")
>>> upload.run(configuration.repository_paths.repository, [])
Or in case if direct access to exception is required, the ``sync`` method can be used::
Or in case if direct access to exception is required, the :func:`sync` method can be used::
>>> try:
>>> upload.sync(configuration.repository_paths.repository, [])

View File

@ -76,8 +76,8 @@ def check_output(*args: str, exception: Exception | Callable[[int, list[str], st
Args:
*args(str): command line arguments
exception(Exception | Callable[[int, list[str], str, str]] | None, optional): exception which has to be raised
instead of default subprocess exception. If callable us is supplied, the ``subprocess.CalledProcessError``
arguments will be passed (Default value = None)
instead of default subprocess exception. If callable us is supplied, the
:exc:`subprocess.CalledProcessError` arguments will be passed (Default value = None)
cwd(Path | None, optional): current working directory (Default value = None)
input_data(str | None, optional): data which will be written to command stdin (Default value = None)
logger(logging.Logger | None, optional): logger to log command result if required (Default value = None)
@ -412,7 +412,7 @@ def srcinfo_property(key: str, srcinfo: dict[str, Any], package_srcinfo: dict[st
default: Any = None) -> Any:
"""
extract property from SRCINFO. This method extracts property from package if this property is presented in
``package``. Otherwise, it looks for the same property in root srcinfo. If none found, the default value will be
``srcinfo``. Otherwise, it looks for the same property in root srcinfo. If none found, the default value will be
returned
Args:
@ -430,9 +430,9 @@ def srcinfo_property(key: str, srcinfo: dict[str, Any], package_srcinfo: dict[st
def srcinfo_property_list(key: str, srcinfo: dict[str, Any], package_srcinfo: dict[str, Any], *,
architecture: str | None = None) -> list[Any]:
"""
extract list property from SRCINFO. Unlike ``srcinfo_property`` it supposes that default return value is always
empty list. If ``architecture`` is supplied, then it will try to lookup for architecture specific values and will
append it at the end of result
extract list property from SRCINFO. Unlike :func:`srcinfo_property()` it supposes that default return value is
always empty list. If ``architecture`` is supplied, then it will try to lookup for architecture specific values and
will append it at the end of result
Args:
key(str): key to extract
@ -468,7 +468,7 @@ def trim_package(package_name: str) -> str:
def unquote(source: str) -> str:
"""
like ``shlex.quote``, but opposite
like :func:`shlex.quote()`, but opposite
Args:
source(str): source string to remove quotes
@ -520,7 +520,8 @@ def walk(directory_path: Path) -> Generator[Path, None, None]:
Path: all found files in given directory with full path
Examples:
Since the ``pathlib`` module does not provide an alternative to ``os.walk``, this wrapper can be used instead::
Since the :mod:`pathlib` module does not provide an alternative to :func:`os.walk()`, this wrapper
can be used instead::
>>> from pathlib import Path
>>>

View File

@ -59,7 +59,7 @@ class AURPackage:
keywords(list[str]): list of package keywords
Examples:
Mainly this class must be used from class methods instead of default ``__init__``::
Mainly this class must be used from class methods instead of default :func:`__init__()`::
>>> package = AURPackage.from_json(metadata) # load package from json dump
>>> # ...or alternatively...

View File

@ -66,11 +66,13 @@ class Package(LazyLogging):
it will probably miss file descriptions (in case if there are multiple packages which belong to the base).
The specific class load method must be defined based on the source provided. The following methods (mostly) must
be used: ``from_archive``, ``from_aur``, ``from_build``, ``from_official`` for sources
``PackageSource.Archive``, ``PackageSource.AUR``, ``PackageSource.Local`` and ``PackageSource.Repository``
repsectively:
be used: :func:`from_archive()`, :func:`from_aur()`, :func:`from_build()`, :func:`from_official()` for sources
:attr:`ahriman.models.package_source.PackageSource.Archive`,
:attr:`ahriman.models.package_source.PackageSource.AUR`,
:attr:`ahriman.models.package_source.PackageSource.Local` and
:attr:`ahriman.models.package_source.PackageSource.Repository` repsectively:
>>> ahriman_package = Package.from_aur("ahriman", pacman)
>>> ahriman_package = Package.from_aur("ahriman")
>>> pacman_package = Package.from_official("pacman", pacman)
"""
@ -540,7 +542,7 @@ class Package(LazyLogging):
def next_pkgrel(self, local_version: str) -> str | None:
"""
generate next pkgrel variable. The package release will be incremented if ``local_version`` is more or equal to
the ``Package.version``; in this case the function will return new pkgrel value, otherwise ``None`` will be
the :attr:`version`; in this case the function will return new pkgrel value, otherwise ``None`` will be
returned
Args:
@ -548,8 +550,8 @@ class Package(LazyLogging):
Returns:
str | None: new generated package release version if any. In case if the release contains dot (e.g. 1.2),
the minor part will be incremented by 1. If the release does not contain major.minor notation, the minor version
equals to 1 will be appended
the minor part will be incremented by 1. If the release does not contain major.minor notation, the minor
version equals to 1 will be appended
"""
epoch, pkgver, _ = parse_version(self.version)
local_epoch, local_pkgver, local_pkgrel = parse_version(local_version)

View File

@ -48,8 +48,9 @@ class PackageDescription:
url(str | None): package url
Examples:
Unlike the ``Package`` class, this implementation only holds properties. The recommended way to deal with it is
to read data based on the source type - either json or ``pyalpm.Package`` instance::
Unlike the :class:`ahriman.models.package.Package` class, this implementation only holds properties.
The recommended way to deal with it is to read data based on the source type - either json or
:class:`pyalpm.Package` instance::
>>> description = PackageDescription.from_json(dump)
>>>

View File

@ -41,11 +41,13 @@ class PackageSource(StrEnum):
Repository(PackageSource): (class attribute) source is official repository
Examples:
In case if source is unknown the ``resolve()`` and the source descriptor is available method must be used::
In case if source is unknown the :func:`resolve()` and the source
descriptor is available method must be used::
>>> real_source = PackageSource.Auto.resolve("ahriman", configuration.repository_paths)
the code above will ensure that the presudo-source ``PackageSource.Auto`` will not be processed later.
the code above will ensure that the presudo-source :attr:`Auto`
will not be processed later.
"""
Auto = "auto"

View File

@ -75,7 +75,7 @@ class RepositoryPaths(LazyLogging):
Returns:
Path: relative path which contains only architecture segment in case if legacy tree is used and repository
name and architecture otherwise
name and architecture otherwise
"""
if not self._force_current_tree:
if (self._repository_root / self.repository_id.architecture).is_dir():
@ -181,7 +181,7 @@ class RepositoryPaths(LazyLogging):
Returns:
set[str]: list of repository names for which there is created tree. Returns empty set in case if repository
is loaded in legacy mode
is loaded in legacy mode
"""
# simply walk through the root. In case if there are subdirectories, emit the name
def walk(paths: RepositoryPaths) -> Generator[str, None, None]:

View File

@ -43,7 +43,8 @@ class User:
>>> password = User.generate_password(24)
>>> user = User(username="ahriman", password=password, access=UserAccess.Full)
Since the password supplied may be plain text, the ``hash_password`` method can be used to hash the password::
Since the password supplied may be plain text, the :func:`hash_password()` method can be used to hash
the password::
>>> user = user.hash_password("salt")

View File

@ -48,8 +48,8 @@ class Waiter:
check if timer is out
Returns:
bool: True in case current monotonic time is more than ``Waiter.start_time`` and
``Waiter.wait_timeout`` doesn't equal to 0
bool: True in case current monotonic time is more than :attr:`start_time` and :attr:`wait_timeout`
doesn't equal to 0
"""
since_start: float = time.monotonic() - self.start_time
return self.wait_timeout != 0 and since_start > self.wait_timeout

View File

@ -68,7 +68,7 @@ def _module(module_info: ModuleInfo) -> ModuleType:
ModuleType: loaded module
Raises:
ValueError: if loader is not an instance of ``SourceFileLoader``
ValueError: if loader is not an instance of :class:`importlib.machinery.SourceFileLoader`
"""
module_spec = module_info.module_finder.find_spec(module_info.name, None)
if module_spec is None:

View File

@ -189,7 +189,7 @@ class BaseView(View, CorsViewMixin):
"""
get_method: Callable[..., Awaitable[StreamResponse]] | None = getattr(self, "get", None)
# using if/else in order to suppress mypy warning which doesn't know that
# ``_raise_allowed_methods`` raises exception
# :func:`aiohttp.web.View._raise_allowed_methods()` raises exception
if get_method is not None:
# there is a bug in pylint, see https://github.com/pylint-dev/pylint/issues/6005
response = await get_method()