From 2bb78cbc49eb6f9363de822e60ebaab581278eac Mon Sep 17 00:00:00 2001 From: Adrian Gao Date: Sun, 2 Feb 2025 18:17:20 +1100 Subject: [PATCH] Use mike for doc versioning --- .github/workflows/docs.yml | 12 ++++++-- mkdocs.yml | 8 +++-- overrides/main.html | 8 +++++ pyproject.toml | 1 + uv.lock | 62 +++++++++++++++++++++++++++++++++++++- 5 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 overrides/main.html diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f5fee92..3ea2cbc 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: docs +name: Documentation on: push: branches: @@ -26,7 +26,13 @@ jobs: run: | uv sync --all-extras --dev uv pip install . - - name: Deploy MkDocs + - name: Get Version from pyproject.toml + id: version run: | source .venv/bin/activate - mkdocs gh-deploy --force --remote-branch gh-pages \ No newline at end of file + echo "VERSION=$(python -c 'import importlib.metadata; print(importlib.metadata.version("brms"))')" >> $GITHUB_ENV + - name: Deploy MkDocs with Mike + run: | + source .venv/bin/activate + mike deploy --push --branch gh-pages --update-aliases ${{ env.VERSION }} latest + mike set-default --push --branch gh-pages latest \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 245d9b3..8459341 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ site_name: Bank Risk Management Simulation site_author: Mingze Gao -site_url: https://bankrisk.org +site_url: https://bankrisk.org/ site_description: >- A bank risk management simulation framework @@ -18,6 +18,7 @@ validation: theme: name: material + custom_dir: overrides favicon: icon.png logo: icon.png palette: @@ -54,8 +55,6 @@ theme: - search.suggest - search.highlight - search.share - # - content.action.edit - # - content.action.view - content.code.copy - content.code.select - content.code.annotate @@ -70,6 +69,9 @@ theme: extra: generator: false + version: + provider: mike + alias: true social: - icon: fontawesome/brands/github link: https://github.com/mgao6767/brms diff --git a/overrides/main.html b/overrides/main.html new file mode 100644 index 0000000..3cf182c --- /dev/null +++ b/overrides/main.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block outdated %} + You're not viewing the latest version. + + Click here to go to latest. + +{% endblock %} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index acaaf78..cff6afe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ Homepage = "https://bankrisk.org" [dependency-groups] dev = [ "isort>=5.13.2", + "mike>=2.1.3", "mkdocs-git-revision-date-localized-plugin>=1.3.0", "mkdocs-material>=9.6.1", "pytest>=8.3.4", diff --git a/uv.lock b/uv.lock index cbd4534..c8256df 100644 --- a/uv.lock +++ b/uv.lock @@ -12,7 +12,7 @@ wheels = [ [[package]] name = "brms" -version = "0.1.0" +version = "0.1.0.dev1" source = { virtual = "." } dependencies = [ { name = "matplotlib" }, @@ -27,6 +27,7 @@ dependencies = [ [package.dev-dependencies] dev = [ { name = "isort" }, + { name = "mike" }, { name = "mkdocs-git-revision-date-localized-plugin" }, { name = "mkdocs-material" }, { name = "pytest" }, @@ -47,6 +48,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ { name = "isort", specifier = ">=5.13.2" }, + { name = "mike", specifier = ">=2.1.3" }, { name = "mkdocs-git-revision-date-localized-plugin", specifier = ">=1.3.0" }, { name = "mkdocs-material", specifier = ">=9.6.1" }, { name = "pytest", specifier = ">=8.3.4" }, @@ -238,6 +240,27 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 }, ] +[[package]] +name = "importlib-metadata" +version = "8.6.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "zipp" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/33/08/c1395a292bb23fd03bdf572a1357c5a733d3eecbab877641ceacab23db6e/importlib_metadata-8.6.1.tar.gz", hash = "sha256:310b41d755445d74569f993ccfc22838295d9fe005425094fad953d7f15c8580", size = 55767 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/9d/0fb148dc4d6fa4a7dd1d8378168d9b4cd8d4560a6fbf6f0121c5fc34eb68/importlib_metadata-8.6.1-py3-none-any.whl", hash = "sha256:02a89390c1e15fdfdc0d7c6b25cb3e62650d0494005c97d6f148bf5b9787525e", size = 26971 }, +] + +[[package]] +name = "importlib-resources" +version = "6.5.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cf/8c/f834fbf984f691b4f7ff60f50b514cc3de5cc08abfc3295564dd89c5e2e7/importlib_resources-6.5.2.tar.gz", hash = "sha256:185f87adef5bcc288449d98fb4fba07cea78bc036455dd44c5fc4a2fe78fed2c", size = 44693 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a4/ed/1f1afb2e9e7f38a545d628f864d562a5ae64fe6f7a10e28ffb9b185b4e89/importlib_resources-6.5.2-py3-none-any.whl", hash = "sha256:789cfdc3ed28c78b67a06acb8126751ced69a3d5f79c095a98298cd8a760ccec", size = 37461 }, +] + [[package]] name = "iniconfig" version = "2.0.0" @@ -433,6 +456,25 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2c/19/04f9b178c2d8a15b076c8b5140708fa6ffc5601fb6f1e975537072df5b2a/mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307", size = 6354 }, ] +[[package]] +name = "mike" +version = "2.1.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "importlib-metadata" }, + { name = "importlib-resources" }, + { name = "jinja2" }, + { name = "mkdocs" }, + { name = "pyparsing" }, + { name = "pyyaml" }, + { name = "pyyaml-env-tag" }, + { name = "verspec" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ab/f7/2933f1a1fb0e0f077d5d6a92c6c7f8a54e6128241f116dff4df8b6050bbf/mike-2.1.3.tar.gz", hash = "sha256:abd79b8ea483fb0275b7972825d3082e5ae67a41820f8d8a0dc7a3f49944e810", size = 38119 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fd/1a/31b7cd6e4e7a02df4e076162e9783620777592bea9e4bb036389389af99d/mike-2.1.3-py3-none-any.whl", hash = "sha256:d90c64077e84f06272437b464735130d380703a76a5738b152932884c60c062a", size = 33754 }, +] + [[package]] name = "mkdocs" version = "1.6.1" @@ -1010,6 +1052,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c8/19/4ec628951a74043532ca2cf5d97b7b14863931476d117c471e8e2b1eb39f/urllib3-2.3.0-py3-none-any.whl", hash = "sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df", size = 128369 }, ] +[[package]] +name = "verspec" +version = "0.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/44/8126f9f0c44319b2efc65feaad589cadef4d77ece200ae3c9133d58464d0/verspec-0.1.0.tar.gz", hash = "sha256:c4504ca697b2056cdb4bfa7121461f5a0e81809255b41c03dda4ba823637c01e", size = 27123 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a4/ce/3b6fee91c85626eaf769d617f1be9d2e15c1cca027bbdeb2e0d751469355/verspec-0.1.0-py3-none-any.whl", hash = "sha256:741877d5633cc9464c45a469ae2a31e801e6dbbaa85b9675d481cda100f11c31", size = 19640 }, +] + [[package]] name = "watchdog" version = "6.0.0" @@ -1033,3 +1084,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/db/d9/c495884c6e548fce18a8f40568ff120bc3a4b7b99813081c8ac0c936fa64/watchdog-6.0.0-py3-none-win_amd64.whl", hash = "sha256:cbafb470cf848d93b5d013e2ecb245d4aa1c8fd0504e863ccefa32445359d680", size = 79070 }, { url = "https://files.pythonhosted.org/packages/33/e8/e40370e6d74ddba47f002a32919d91310d6074130fe4e17dabcafc15cbf1/watchdog-6.0.0-py3-none-win_ia64.whl", hash = "sha256:a1914259fa9e1454315171103c6a30961236f508b9b623eae470268bbcc6a22f", size = 79067 }, ] + +[[package]] +name = "zipp" +version = "3.21.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3f/50/bad581df71744867e9468ebd0bcd6505de3b275e06f202c2cb016e3ff56f/zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4", size = 24545 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/1a/7e4798e9339adc931158c9d69ecc34f5e6791489d469f5e50ec15e35f458/zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931", size = 9630 }, +]