From f94ad5642f594a6c9da38595ae592984eb840742 Mon Sep 17 00:00:00 2001 From: coretl Date: Fri, 6 Sep 2024 15:06:18 +0000 Subject: [PATCH] deploy: DiamondLightSource/python-copier-template@b0dabb0b5323c1931aa816bf441c37810c97c808 --- .copier-answers.yml | 2 +- .github/pages/make_switcher.py | 14 ++++++++------ docs/conf.py | 11 ++++++----- src/python_copier_template_example/__main__.py | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 0da6259..a125729 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: 2.2.0-18-gca3deba +_commit: 2.2.0-20-gb0dabb0 _src_path: gh:DiamondLightSource/python-copier-template author_email: tom.cobb@diamond.ac.uk author_name: Tom Cobb diff --git a/.github/pages/make_switcher.py b/.github/pages/make_switcher.py index 29f646c..c06813a 100755 --- a/.github/pages/make_switcher.py +++ b/.github/pages/make_switcher.py @@ -1,3 +1,5 @@ +"""Make switcher.json to allow docs to switch between different versions.""" + import json import logging from argparse import ArgumentParser @@ -6,6 +8,7 @@ def report_output(stdout: bytes, label: str) -> list[str]: + """Print and return something received frm stdout.""" ret = stdout.decode().strip().split("\n") print(f"{label}: {ret}") return ret @@ -52,14 +55,12 @@ def get_versions(ref: str, add: str | None) -> list[str]: return versions -def write_json(path: Path, repository: str, versions: str): +def write_json(path: Path, repository: str, versions: list[str]): + """Write the JSON switcher to path.""" org, repo_name = repository.split("/") - pages_url = f"https://{org}.github.io" - if repo_name != f"{org}.github.io": - # Only add the repo name if it isn't the source for the org pages site - pages_url += f"/{repo_name}" struct = [ - {"version": version, "url": f"{pages_url}/{version}/"} for version in versions + {"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"} + for version in versions ] text = json.dumps(struct, indent=2) print(f"JSON switcher:\n{text}") @@ -67,6 +68,7 @@ def write_json(path: Path, repository: str, versions: str): def main(args=None): + """Parse args and write switcher.""" parser = ArgumentParser( description="Make a versions.json file from gh-pages directories" ) diff --git a/docs/conf.py b/docs/conf.py index 0e9d346..f5a6657 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,9 @@ -# 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 +"""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 +""" import sys from pathlib import Path diff --git a/src/python_copier_template_example/__main__.py b/src/python_copier_template_example/__main__.py index fb75d83..9d3ee90 100644 --- a/src/python_copier_template_example/__main__.py +++ b/src/python_copier_template_example/__main__.py @@ -1,3 +1,4 @@ +"""Interface for ``python -m python_copier_template_example``.""" from argparse import ArgumentParser from collections.abc import Sequence @@ -7,6 +8,7 @@ def main(args: Sequence[str] | None = None) -> None: + """Argument parser for the CLI.""" parser = ArgumentParser() parser.add_argument( "-v", @@ -17,6 +19,5 @@ def main(args: Sequence[str] | None = None) -> None: parser.parse_args(args) -# test with: python -m python_copier_template_example if __name__ == "__main__": main()