diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 58423b9..cc8df66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: # manually triggered jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: @@ -33,3 +33,48 @@ jobs: uv run ruff format . --check uv run ruff check . .venv/bin/pytest -x tests --cov=confetti --cov-report=html + + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@main + - name: Install the default version of uv + id: setup-uv + uses: astral-sh/setup-uv@v3 + - name: Building docs + run: | + uv venv --python 3.11 + uv pip install ".[doc]" + .venv/bin/sphinx-build -a -W -E doc build/sphinx/html + + publish: + if: startsWith(github.ref, 'refs/tags/') + needs: test + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install hatch + run: pip install hatch + + - name: Build package + run: hatch build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true + skip-existing: true diff --git a/Makefile b/Makefile index ec27fff..58cc346 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ test: env env: uv venv - uv pip install -e ".[testing]" + uv pip install -e ".[testing,doc]" doc: env .venv/bin/sphinx-build -a -W -E doc build/sphinx/html diff --git a/doc/conf.py b/doc/conf.py index 7441d6c..62f4d2c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,7 +11,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -# import sys, os +import alabaster +import importlib.metadata # 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 @@ -25,7 +26,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest"] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest", "releases"] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -47,10 +48,7 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = "1.1.0" -# The full version, including alpha/beta/rc tags. -release = "1.1.0" +version = release = importlib.metadata.distribution("confetti").version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -91,7 +89,24 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = "default" +html_theme_path = [alabaster.get_path()] + +html_theme = "alabaster" +html_theme_options = { + "github_user": "getslash", + "github_repo": "confetti", + "github_button": True, + "github_banner": True, + "travis_button": False, +} +html_sidebars = { + "**": [ + "about.html", + "navigation.html", + "searchbox.html", + "donate.html", + ] +} # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -120,7 +135,7 @@ # 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"] +# html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff --git a/doc/index.rst b/doc/index.rst index f620669..4cd4ee3 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -109,7 +109,7 @@ However, it is not allowed to extend using a Config object if it will remove exi Traceback (most recent call last): ... CannotSetValue: ... - + In the above example, in order to add the path c.root.extended_value.child2, without re-specifying extended_value.child1, use the :func:`.Config.update` method: >>> c.update(Config({'extended_value':{'child2':2}})) @@ -117,7 +117,7 @@ In the above example, in order to add the path c.root.extended_value.child2, wit 1 >>> c.root.extended_value.child2 2 - + Advanced Uses ~~~~~~~~~~~~~ @@ -132,7 +132,7 @@ Config objects can assign to paths using the :func:`.Config.assign_path` method: 2 Which is a synonym for: - + >>> c.get_config("a.b.c").set_value(2) In some cases you want to process config overrides from various sources that are not completely type safe, e.g. command-line or environment variables. Such variables would look like ``'some.value=2'``. Confetti provides a utility for easily assigning such expressions, optionally deducing the leaf type:: @@ -141,7 +141,7 @@ In some cases you want to process config overrides from various sources that are >>> c.root.a.b.c 234 -The default is no type deduction, which results in string values always:: +The default is no type deduction, which results in string values always:: >>> c.assign_path_expression("a.b.c=230") >>> c.root.a.b.c diff --git a/pyproject.toml b/pyproject.toml index 00d0786..cbd35be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ authors = [{ name = "Rotem Yaari", email = "vmalloc@gmail.com" }] [project.optional-dependencies] testing = ["pytest", "pytest-cov", "ruff"] +doc = ["Sphinx", "alabaster", "releases"] [tool.hatch.version] source = "vcs"