From d9fbfcc26ad52b1400a3b04a65e7f0bb20972b7b Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Tue, 8 Mar 2022 17:12:32 +0100 Subject: [PATCH] Added suport for multi-versions --- .doc/UI/README.md | 2 + .doc/UI/make.bat | 4 +- .doc/UI/source/_templates/layout.html | 18 ++++++ .../_templates/sphinx_rtd_theme/page.html | 22 +++++++ .../_templates/sphinx_rtd_theme/versions.html | 61 ++++++++----------- .doc/UI/source/_templates/versions.html | 32 ++++++++++ .doc/UI/source/conf.py | 4 +- .doc/UI/source/index.rst | 4 +- 8 files changed, 107 insertions(+), 40 deletions(-) create mode 100644 .doc/UI/source/_templates/layout.html create mode 100644 .doc/UI/source/_templates/sphinx_rtd_theme/page.html create mode 100644 .doc/UI/source/_templates/versions.html diff --git a/.doc/UI/README.md b/.doc/UI/README.md index 4dfee669d..7140ea78e 100644 --- a/.doc/UI/README.md +++ b/.doc/UI/README.md @@ -16,6 +16,7 @@ Install Python from https://www.python.org/downloads/windows/ pip install -U sphinx pip install sphinx-rtd-theme pip install recommonmark +pip install sphinx-multiversion ``` #### doc generation @@ -33,6 +34,7 @@ Under `.doc/UI`, run sudo apt-get install python3-sphinx pip install sphinx-rtd-theme pip install recommonmark +pip install sphinx-multiversion ``` #### doc generation diff --git a/.doc/UI/make.bat b/.doc/UI/make.bat index 9534b0181..afae04e52 100644 --- a/.doc/UI/make.bat +++ b/.doc/UI/make.bat @@ -5,7 +5,7 @@ pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build + set SPHINXBUILD=sphinx-multiversion ) set SOURCEDIR=source set BUILDDIR=build @@ -25,7 +25,7 @@ if errorlevel 9009 ( exit /b 1 ) -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +%SPHINXBUILD% %SOURCEDIR% %BUILDDIR%/%1 %SPHINXOPTS% %O% goto end :help diff --git a/.doc/UI/source/_templates/layout.html b/.doc/UI/source/_templates/layout.html new file mode 100644 index 000000000..41100915e --- /dev/null +++ b/.doc/UI/source/_templates/layout.html @@ -0,0 +1,18 @@ +{%- extends "!layout.html" %} +{% block document %} +{% if current_version and latest_version and current_version.name != 'latest' and current_version != latest_version %} + + +
+

Attention!

+

+ Vous consultez une ancienne version de cette documentation. + Si vous voulez lire la plus récente, c'est par là {{latest_version.name}}. +

+
+{% endif %} +{{ super() }} +{% endblock %}% \ No newline at end of file diff --git a/.doc/UI/source/_templates/sphinx_rtd_theme/page.html b/.doc/UI/source/_templates/sphinx_rtd_theme/page.html new file mode 100644 index 000000000..603872071 --- /dev/null +++ b/.doc/UI/source/_templates/sphinx_rtd_theme/page.html @@ -0,0 +1,22 @@ +{% extends "!page.html" %} +{% block body %} +{% if current_version and latest_version and current_version != latest_version %} + + +

+ + {% if current_version.is_released %} + You're reading an old version of this documentation. + If you want up-to-date information, please have a look at {{latest_version.name}}. + {% else %} + You're reading the documentation for a development version. + For the latest released version, please have a look at {{latest_version.name}}. + {% endif %} + +

+{% endif %} +{{ super() }} +{% endblock %}% \ No newline at end of file diff --git a/.doc/UI/source/_templates/sphinx_rtd_theme/versions.html b/.doc/UI/source/_templates/sphinx_rtd_theme/versions.html index bab969e64..ed1a69496 100644 --- a/.doc/UI/source/_templates/sphinx_rtd_theme/versions.html +++ b/.doc/UI/source/_templates/sphinx_rtd_theme/versions.html @@ -1,34 +1,27 @@ -{% if READTHEDOCS %} -{# Add rst-badge after rst-versions for small badge style. #} -
- - Read the Docs - v: {{ current_version }} - - -
-
-
{{ _('Versions') }}
- {% for slug, url in versions %} -
{{ slug }}
- {% endfor %} -
-
-
{{ _('Downloads') }}
- {% for type, url in downloads %} -
{{ type }}
- {% endfor %} -
-
- {# Translators: The phrase "Read the Docs" is not translated #} -
{{ _('On Read the Docs') }}
-
- {{ _('Project Home') }} -
-
- {{ _('Builds') }} -
-
-
-
-{% endif %} +{%- if current_version %} +
+ + Other Versions + v: {{ current_version.name }} + + +
+ {%- if versions.tags %} +
+
Tags
+ {%- for item in versions.tags %} +
{{ item.name }}
+ {%- endfor %} +
+ {%- endif %} + {%- if versions.branches %} +
+
Branches
+ {%- for item in versions.branches %} +
{{ item.name }}
+ {%- endfor %} +
+ {%- endif %} +
+
+{%- endif %} \ No newline at end of file diff --git a/.doc/UI/source/_templates/versions.html b/.doc/UI/source/_templates/versions.html new file mode 100644 index 000000000..3b1a705d3 --- /dev/null +++ b/.doc/UI/source/_templates/versions.html @@ -0,0 +1,32 @@ +{%- if current_version %} + + +
+ + Other Versions + v: {{ current_version.name }} + + +
+ {%- if versions.tags %} +
+
Tags
+ {%- for item in versions.tags %} +
{{ item.name }}
+ {%- endfor %} +
+ {%- endif %} + {%- if versions.branches %} +
+
Branches
+ {%- for item in versions.branches %} +
{{ item.name }}
+ {%- endfor %} +
+ {%- endif %} +
+
+{%- endif %} \ No newline at end of file diff --git a/.doc/UI/source/conf.py b/.doc/UI/source/conf.py index d11607d13..b809e43dd 100644 --- a/.doc/UI/source/conf.py +++ b/.doc/UI/source/conf.py @@ -22,7 +22,7 @@ copyright = '2022, Combodo' author = 'Combodo' # The full version, including alpha/beta/rc tags -release = '3.1.0' +release = 'iTop 3.1.0' # -- General configuration --------------------------------------------------- @@ -30,7 +30,7 @@ release = '3.1.0' # 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.autosectionlabel','recommonmark'] +extensions = ['sphinx.ext.autosectionlabel', 'recommonmark', 'sphinx_multiversion'] autosectionlabel_prefix_document = True diff --git a/.doc/UI/source/index.rst b/.doc/UI/source/index.rst index c93ea76a0..faa96e336 100644 --- a/.doc/UI/source/index.rst +++ b/.doc/UI/source/index.rst @@ -1,8 +1,8 @@ .. Copyright (C) 2010-2021 Combodo SARL .. http://opensource.org/licenses/AGPL-3.0 -Welcome to iTop 3.0 UI's documentation! -======================================= +Welcome to iTop UI documentation! +================================= .. toctree:: :maxdepth: 1