diff --git a/docs/macros.py b/docs/macros.py new file mode 100644 index 00000000..9ec28af3 --- /dev/null +++ b/docs/macros.py @@ -0,0 +1,11 @@ +import tomllib +from pathlib import Path + +from mkdocs_macros.plugin import MacrosPlugin + + +def define_env(env: MacrosPlugin) -> None: + project = tomllib.loads( + (Path(__file__).parent.parent / "pyproject.toml").read_text(encoding="utf-8") + ) + env.variables["package_version"] = project["project"]["version"] diff --git a/docs/tutorial/getting_started.md b/docs/tutorial/getting_started.md index fd06207f..dce1e7d1 100644 --- a/docs/tutorial/getting_started.md +++ b/docs/tutorial/getting_started.md @@ -27,7 +27,7 @@ contains a selection of basic problems. We can install it with uv just like the package: ```console -uv tool install --with algobattle-problems algobattle-base==4.4.2 +uv tool install --with algobattle-problems algobattle-base=={{ package_version }} ``` ## Setting up the workspace diff --git a/docs/tutorial/installation.md b/docs/tutorial/installation.md index d6499c79..4d55e22e 100644 --- a/docs/tutorial/installation.md +++ b/docs/tutorial/installation.md @@ -83,7 +83,7 @@ whichever installation process and version you like. Then all we need to do is run this command: ```console -uv tool install algobattle-base==4.4.2 +uv tool install algobattle-base=={{ package_version }} ``` This will take care of installing the correct Python version and all dependencies we need. It also diff --git a/mkdocs.yml b/mkdocs.yml index 3c13c9f8..6f9fe5d1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -6,7 +6,8 @@ edit_uri: "" plugins: - search - + - macros: + module_name: docs/macros - mkdocstrings: handlers: python: diff --git a/pyproject.toml b/pyproject.toml index d31b5074..7902c442 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ dev = [ "pymdown-extensions>=12.1.0", "mkdocstrings[python]>=1.0.6", "mdx-include>=1.4.2", + "mkdocs-macros-plugin>=1.5.0", ] diff --git a/uv.lock b/uv.lock index 04411b12..b6214f97 100644 --- a/uv.lock +++ b/uv.lock @@ -20,6 +20,7 @@ dependencies = [ dev = [ { name = "mdx-include" }, { name = "mkdocs" }, + { name = "mkdocs-macros-plugin" }, { name = "mkdocs-material" }, { name = "mkdocstrings", extra = ["python"] }, { name = "pymdown-extensions" }, @@ -41,6 +42,7 @@ requires-dist = [ dev = [ { name = "mdx-include", specifier = ">=1.4.2" }, { name = "mkdocs", specifier = ">=1.6.1" }, + { name = "mkdocs-macros-plugin", specifier = ">=1.5.0" }, { name = "mkdocs-material", specifier = ">=9.7.7" }, { name = "mkdocstrings", extras = ["python"], specifier = ">=1.0.6" }, { name = "pymdown-extensions", specifier = ">=12.1.0" }, @@ -265,6 +267,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/41/63/e876e789525063c840ccfa8857febdabd6523bcef9ce7eb979b9305ea895/griffelib-2.3.0-py3-none-any.whl", hash = "sha256:1b8f9cd525681c26b1d6d574faa1371651e8459ca51d209684f50b8096ae06e0", size = 169423, upload-time = "2026-09-04T15:08:12.956Z" }, ] +[[package]] +name = "hjson" +version = "3.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/82/e5/0b56d723a76ca67abadbf7fb71609fb0ea7e6926e94fcca6c65a85b36a0e/hjson-3.1.0.tar.gz", hash = "sha256:55af475a27cf83a7969c808399d7bccdec8fb836a07ddbd574587593b9cdcf75", size = 40541, upload-time = "2022-08-13T02:53:01.919Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1f/7f/13cd798d180af4bf4c0ceddeefba2b864a63c71645abc0308b768d67bb81/hjson-3.1.0-py3-none-any.whl", hash = "sha256:65713cdcf13214fb554eb8b4ef803419733f4f5e551047c9b711098ab7186b89", size = 54018, upload-time = "2022-08-13T02:52:59.899Z" }, +] + [[package]] name = "idna" version = "3.20" @@ -421,6 +432,27 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/88/29/744136411e785c4b0b744d5413e56555265939ab3a104c6a4b719dad33fd/mkdocs_get_deps-0.2.2-py3-none-any.whl", hash = "sha256:e7878cbeac04860b8b5e0ca31d3abad3df9411a75a32cde82f8e44b6c16ff650", size = 9555, upload-time = "2026-03-10T02:46:32.256Z" }, ] +[[package]] +name = "mkdocs-macros-plugin" +version = "1.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "hjson" }, + { name = "jinja2" }, + { name = "mkdocs" }, + { name = "packaging" }, + { name = "pathspec" }, + { name = "python-dateutil" }, + { name = "pyyaml" }, + { name = "requests" }, + { name = "super-collections" }, + { name = "termcolor" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/92/15/e6a44839841ebc9c5872fa0e6fad1c3757424e4fe026093b68e9f386d136/mkdocs_macros_plugin-1.5.0.tar.gz", hash = "sha256:12aa45ce7ecb7a445c66b9f649f3dd05e9b92e8af6bc65e4acd91d26f878c01f", size = 37730, upload-time = "2025-11-13T08:08:55.545Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/62/9fffba5bb9ed3d31a932ad35038ba9483d59850256ee0fea7f1187173983/mkdocs_macros_plugin-1.5.0-py3-none-any.whl", hash = "sha256:c10fabd812bf50f9170609d0ed518e54f1f0e12c334ac29141723a83c881dd6f", size = 44626, upload-time = "2025-11-13T08:08:53.878Z" }, +] + [[package]] name = "mkdocs-material" version = "9.7.7" @@ -745,6 +777,27 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] +[[package]] +name = "super-collections" +version = "0.6.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "hjson" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e0/de/a0c3d1244912c260638f0f925e190e493ccea37ecaea9bbad7c14413b803/super_collections-0.6.2.tar.gz", hash = "sha256:0c8d8abacd9fad2c7c1c715f036c29f5db213f8cac65f24d45ecba12b4da187a", size = 31315, upload-time = "2025-09-30T00:37:08.067Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/17/43/47c7cf84b3bd74a8631b02d47db356656bb8dff6f2e61a4c749963814d0d/super_collections-0.6.2-py3-none-any.whl", hash = "sha256:291b74d26299e9051d69ad9d89e61b07b6646f86a57a2f5ab3063d206eee9c56", size = 16173, upload-time = "2025-09-30T00:37:07.104Z" }, +] + +[[package]] +name = "termcolor" +version = "3.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/46/79/cf31d7a93a8fdc6aa0fbb665be84426a8c5a557d9240b6239e9e11e35fc5/termcolor-3.3.0.tar.gz", hash = "sha256:348871ca648ec6a9a983a13ab626c0acce02f515b9e1983332b17af7979521c5", size = 14434, upload-time = "2025-12-29T12:55:21.882Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/d1/8bb87d21e9aeb323cc03034f5eaf2c8f69841e40e4853c2627edf8111ed3/termcolor-3.3.0-py3-none-any.whl", hash = "sha256:cf642efadaf0a8ebbbf4bc7a31cec2f9b5f21a9f726f4ccbb08192c9c26f43a5", size = 7734, upload-time = "2025-12-29T12:55:20.718Z" }, +] + [[package]] name = "tomlkit" version = "0.15.1"