diff --git a/.gitignore b/.gitignore index 5ee25fe939..c0ebcf0350 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /vendor/ **/.DS_Store __pycache__/* +hooks/__pycache__/* /site/ **/.idea/ .php-cs-fixer.cache diff --git a/hooks/edit_uri.py b/hooks/edit_uri.py new file mode 100644 index 0000000000..7afb7c3342 --- /dev/null +++ b/hooks/edit_uri.py @@ -0,0 +1,12 @@ +import os + +def on_config(config, **kwargs): + if os.environ.get("READTHEDOCS_VERSION_TYPE") == "external": + ref = os.environ.get("READTHEDOCS_GIT_COMMIT_HASH") + else: + ref = os.environ.get("GITHUB_HEAD_REF") + + if ref: + config["edit_uri"] = f"edit/{ref}/docs/" + + return config diff --git a/mkdocs.yml b/mkdocs.yml index aa8294e9bb..9ccf2c759f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -4,6 +4,8 @@ site_name: Developer Documentation repo_url: https://github.com/ibexa/documentation-developer edit_uri: edit/5.0/docs site_url: https://doc.ibexa.co/en/latest/ +hooks: + - hooks/edit_uri.py copyright: "Copyright 1999-2026 Ibexa AS and others" validation: omitted_files: warn