Verified Commit 8312520d authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Add sphinx documentation

parent 2c77c586
Pipeline #6493 failed with stage
in 17 seconds
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
#import os
#import sys
#sys.path.insert(0, os.path.abspath('../pytest_pacman'))
# -- Project information -----------------------------------------------------
project = 'pytest-pacman'
copyright = '2021, Jelle van der Waa'
author = 'Jelle van der Waa'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
.. pytest-pacman documentation master file, created by
sphinx-quickstart on Wed Apr 14 21:20:59 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
pytest-pacman documentation
===========================
This is a pytest plugin which will generate a test pacman sync, local db and a
pacman package. To be used in pyalpm, archweb and arch-signoff for testing.
Basic Usage
-----------
.. code-block:: python
from pyalpm import Handle
@pytest.fixture(scope="session")
def empty_localdb(generate_localdb):
return generate_localdb([])
def test_handle(empty_localdb):
handle = Handle("/", empty_localdb)
localdb = handle.get_localdb()
@pytest.fixture(scope="session")
def empty_localdb(generate_localdb):
return generate_localdb([])
@pytest.fixture(scope="session")
def db_data():
return [{
"name": "linux-firmware",
"base": "linux-firmware",
"arch": "any",
"csize": "2483776",
"builddate": "1573556456",
"version": "20200204.b791e15-1",
"desc": "Firmware files for Linux",
"url": "https://kernel.org",
"license": "GPL2",
"packager": "Arch Dev <developer@archlinux.org>",
"conflicts": ["linux-firmware-git"],
"replaces": ["kernel26-firmware"],
"depends": [""],
"makedepends": ["git"],
"optdepends": [""]
}]
@pytest.fixture(scope="session")
def localdb(generate_localdb, db_data):
return generate_localdb(db_data)
def test_handle(localdb):
handle = Handle("/", localdb)
localdb = handle.get_localdb()
Module
------
The package object for generate_syncdb/generate_localdb should be a dictionary with the following members:
.. code-block:: python
{
"name": "linux-firmware",
"base": "linux-firmware",
"arch": "any",
"csize": "2483776",
"builddate": "1573556456",
"version": "20200204.b791e15-1",
"desc": "Firmware files for Linux",
"url": "https://kernel.org",
"license": "GPL2",
"packager": "Arch Dev <developer@archlinux.org>",
"conflicts": ["linux-firmware-git"],
"replaces": ["kernel26-firmware"],
"depends": [""],
"makedepends": ["git"],
"optdepends": [""]
}
.. py:function:: generate_syncdb(pkgs: list, dbname: string, dbloc: string)
Generates a sync database in a provided location or when not provided pytest tmpdir
:param list pkgs: a list of package objects
:param str dbname: sync database name (default 'test.db')
:param str dbloc: location where sync database will be created (optional)
:returns: path to dbroot for when dbroot is not provided
.. py:function:: generate_localdb(pkgs: list, dbroot: string, alpm_db_version: string)
Generates a sync database in a provided location or when not provided pytest tmpdir
:param list pkgs: a list of package objects
:param str dbroot: the path to the root (normally /var/lib/pacman)
:param str alpm_db_version: the ALPM_DB_VERSION (default 9)
:returns: path to dbroot for when dbroot is not provided
.. py:function:: generate_package(data: object, pkgname: string, pkgpath: string)
Generates a package in provided location or when not provided pytest tmpdir
:param object data: dict containing the fields for PKGINFO
:param str dbname: the package file name ($pkgname-$pkgver-$pkgrel.pkg.tar)
:param str dbloc: the path to save the pkg file
:returns: path to the package
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment