berhoel.sphinx_settings package

Sphinx configuration for documentation for berhoel python packages.

class berhoel.sphinx_settings.ProjectTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum to allow identifying build system.

POETRY = 1
CMAKE = 2
class berhoel.sphinx_settings._ProjectInfo[source]

Bases: ABC

Base class for Project information.

abstract property project: str
abstract property release: str
abstract property author: str
configuration() dict[str, str][source]

Return collected configuration information.

Returns:

dict[str, str]

mapping containing project information

_abc_impl = <_abc._abc_data object>
class berhoel.sphinx_settings.PyProject_toml(cfg_file: Path | str | None = None)[source]

Bases: _ProjectInfo

Provide project information from pyproject.toml file.

__init__(cfg_file: Path | str | None = None)[source]

Process pyproject.toml file for project information.

Parameters:

cfg_file – str|Path|None path to pyproject.toml file for current project. (default: search for appropriate file)

property project: str
property release: str
property author: str
property html_baseurl: str

Return bnase URL for generated documentation.

Used for feeding sitemap extension.

Returns:

str

base URL

_abc_impl = <_abc._abc_data object>
class berhoel.sphinx_settings.CMakeLists_txt(cfg_file: Path | str | None = None)[source]

Bases: _ProjectInfo

Provide project information from CMakeLists.txt file.

__init__(cfg_file: Path | str | None = None)[source]

Process CMakeLists.txt file for project information.

Parameters:

cfg_file – str|Path|None path to CMakeLists.txt file for current project. (default: search for appropriate file)

static _has_project(cfg_file: Path) bool[source]

Check if CMakeLists.txt file has project command.

property project: str

Return project name.

Returns:

str

project information

property release: str

Return release information.

Returns:

str

version string

Raises:

SystemError – in case the version information is not avaliable

property author: str

Return information on author.

Returns:

str

author information

_abc_impl = <_abc._abc_data object>
berhoel.sphinx_settings.configuration(project_type: ProjectTypes = ProjectTypes.POETRY, cfg_file: Path | str | None = None) _ProjectInfo[source]

Get configuration class appropriate to build system for current project.

Parameters:
  • project_type – project_types Type of build system configuration file (poetry or CMake)

  • cfg_file – str | Path | None Path to build system configuration file. Will be search if not given. (default None)

berhoel.sphinx_settings.get_html_theme_path() list[Path][source]

Return path to HTML theme.

Returns:

list[Path]

path to HTML theme

berhoel.sphinx_settings.setup(app: Sphinx) None[source]

Prepare settings for Sphinx.

Parameters:

app – Sphinx app zu configure.