repo_helper.blocks
Reusable blocks of reStructuredText.
Classes:
|
Create the shields block for insertion into the README, documentation etc. |
Functions:
|
Create the installation instructions for insertion into the documentation. |
|
Create the documentation links block. |
|
Create the installation instructions for insertion into the README. |
|
Creates the short description block insertion into the README, documentation etc. |
Loads the docs_links_block template from file and returns a jinja2 |
|
Loads the readme_installation_block_no_pypi template from file and returns a jinja2 |
|
Loads the readme_installation_block template from file and returns a jinja2 |
Data:
Regular expression to match the installation block placeholder. |
|
Regular expression to match the links block placeholder. |
|
Regular expression to match the shields block placeholder. |
|
Regular expression to match the short description block placeholder. |
-
class
ShieldsBlock(username, repo_name, version, *, conda=True, tests=True, docs=True, docs_url='https://{}.readthedocs.io/en/latest/?badge=latest', pypi_name=None, conda_name=None, unique_name='', docker_shields=False, docker_name='', platforms=None, on_pypi=True, primary_conda_channel=None, linters=True)[source] Bases:
objectCreate the shields block for insertion into the README, documentation etc.
- Parameters
username (
str) – The username of the GitHub account that owns the repository.repo_name (
str) – The name of the repository.docs_url (
str) – Default'https://{}.readthedocs.io/en/latest/?badge=latest'.pypi_name (
Optional[str]) – The name of the project on PyPI. Defaults to the value ofrepo_nameif unset. DefaultNone.conda_name (
Optional[str]) – The name of the project on conda. Defaults to the value ofrepo_nameif unset. DefaultNone.unique_name (
str) – An optional unique name for the reST substitutions. Default''.docker_shields (
bool) – Whether to show shields for Docker. DefaultFalse. DefaultFalse.docker_name (
str) – The name of the Docker image on DockerHub. Default''.platforms (
Optional[Iterable[str]]) – List of supported platforms. DefaultNone.primary_conda_channel (
Optional[str]) – The Conda channel the package can be downloaded from. DefaultNone.linters (
bool) – Whether to show badges for linters (mypy and flake8). DefaultTrue.
New in version 2020.12.11.
New in version 2025.6.3: Added
conda_nameoption.New in version $VERSION: Added
lintersoption.Methods:
make()Constructs the contents of the shields block.
Create shields for insertion into Sphinx documentation.
Create shields for insertion into
README.rst.Attributes:
This list controls which sections are included, and their order.
This list controls which substitutions are included, and their order.
-
sections= ('Docs', 'Tests', 'PyPI', 'Anaconda', 'Activity', 'QA', 'Docker', 'Other') Type:
tupleThis list controls which sections are included, and their order.
-
substitutions= ('docs', 'docs_check', 'actions_linux', 'actions_windows', 'actions_macos', 'actions_flake8', 'actions_mypy', 'requires', 'coveralls', 'codefactor', 'pypi-version', 'supported-versions', 'supported-implementations', 'wheel', 'conda-version', 'conda-platform', 'license', 'language', 'commits-since', 'commits-latest', 'maintained', 'pypi-downloads', 'docker_build', 'docker_automated', 'docker_size') Type:
tupleThis list controls which substitutions are included, and their order.
-
create_docs_install_block(repo_name, username, conda=True, pypi=True, pypi_name=None, conda_name=None, conda_channels=None)[source] Create the installation instructions for insertion into the documentation.
- Parameters
repo_name (
str) – The name of the GitHub repository.username (
str) – The username of the GitHub account that owns the repository. (Not used; ensures API compatibility withcreate_readme_install_block())conda (
bool) – Whether to show Anaconda installation instructions. DefaultTrue.pypi (
bool) – Whether to show PyPI installation instructions. DefaultTrue.pypi_name (
Optional[str]) – The name of the project on PyPI. Defaults to the value ofrepo_nameif unset. DefaultNone.conda_name (
Optional[str]) – The name of conda package for the project. Defaults to the value ofrepo_nameif unset. DefaultNone.conda_channels (
Optional[Sequence[str]]) – List of required Conda channels. DefaultNone.
- Return type
- Returns
The installation block created from the above settings.
-
create_readme_install_block(modname, username, conda=True, pypi=True, pypi_name=None, conda_name=None, conda_channels=None)[source] Create the installation instructions for insertion into the README.
- Parameters
modname (
str) – The name of the program / library.username (
str) – The username of the GitHub account that owns the repository.conda (
bool) – Whether to show Anaconda installation instructions. DefaultTrue.pypi (
bool) – Whether to show PyPI installation instructions. DefaultTrue.pypi_name (
Optional[str]) – The name of the project on PyPI. Defaults to the value ofrepo_nameif unset. DefaultNone.conda_name (
Optional[str]) – The name of conda package for the project. Defaults to the value ofrepo_nameif unset. DefaultNone.conda_channels (
Optional[Sequence[str]]) – List of required Conda channels. DefaultNone.
- Return type
- Returns
The installation block created from the above settings.
-
create_short_desc_block(short_desc)[source] Creates the short description block insertion into the README, documentation etc.
-
get_docs_links_block_template()[source] Loads the docs_links_block template from file and returns a jinja2
jinja2.environment.Templatefor it.- Return type
-
get_readme_installation_block_no_pypi_template()[source] Loads the readme_installation_block_no_pypi template from file and returns a jinja2
jinja2.environment.Templatefor it.New in version 2020.12.1.
- Return type
-
get_readme_installation_block_template()[source] Loads the readme_installation_block template from file and returns a jinja2
jinja2.environment.Templatefor it.- Return type
-
installation_regex Type:
PatternRegular expression to match the installation block placeholder.
Pattern
(.. start installation)(.*?)(.. end installation)Flags
-
links_regex Type:
PatternRegular expression to match the links block placeholder.
Pattern
(.. start links)(.*?)(.. end links)Flags