From 30a16571555866d121c490a927bda36e5ebfaa72 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Mon, 6 Nov 2017 12:10:54 +0100 Subject: [PATCH] Use a custom role for including github_version --- docs/compose/setup.rst | 6 +++--- docs/conf.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/compose/setup.rst b/docs/compose/setup.rst index b377e04d..d6f80e09 100644 --- a/docs/compose/setup.rst +++ b/docs/compose/setup.rst @@ -19,12 +19,12 @@ Docker Compose configuration is stored in a file named :download:`docker-compose.yml`. Additionally, Mailu relies on a :download:`.env` file for various settings. Download the proper template files from the git repository. To download the configuration -for the "|github_version|" branch, use: +for the ":var:`github_version`" branch, use: .. parsed-literal:: - wget https://mailu.io/|github_version|/_downloads/docker-compose.yml - wget https://mailu.io/|github_version|/_downloads/.env + wget https://mailu.io/:var:`github_version`/_downloads/docker-compose.yml + wget https://mailu.io/:var:`github_version`/_downloads/.env Then open the ``.env`` file to setup the mail server. Modify the ``ROOT`` setting to match your setup directory if different from ``/mailu``. diff --git a/docs/conf.py b/docs/conf.py index f7aedb53..9d5a7af8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,8 +2,10 @@ # -*- coding: utf-8 -*- # -extensions = ['sphinx.ext.imgmath', - 'sphinx.ext.viewcode'] +import os, sys, docutils + +sys.path.append(os.path.dirname(__file__)) +extensions = ['sphinx.ext.imgmath', 'sphinx.ext.viewcode', 'conf'] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' @@ -37,6 +39,16 @@ html_context = { 'conf_py_path': '/docs/' } + +def setup(app): + """ The configuration acts as an extension itself. + """ + def var_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + return [docutils.nodes.Text(html_context.get(text, ""))], [] + + app.add_role("var", var_role) + + # Upload function when the script is called directly if __name__ == "__main__": import os, sys, paramiko