From 073cf9bcf69f22d8cc933f45a5bd3f10724dc857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Wed, 8 May 2019 09:24:02 -0400 Subject: [PATCH 1/3] Add a proto for the deprecation warning for the former version of Python --- python_docs_theme/layout.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python_docs_theme/layout.html b/python_docs_theme/layout.html index 822e6eda..830ddaf8 100644 --- a/python_docs_theme/layout.html +++ b/python_docs_theme/layout.html @@ -1,5 +1,17 @@ {% extends "classic/layout.html" %} +{% block header %} + +
+ This document is for a version of Python that is no longer supported. Please upgrade to a newer release! +
+{% endblock %} + {% block rootrellink %}
  • From 4179fba34e293c6e64f410c52a305b721d1623af Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Wed, 8 May 2019 17:17:15 +0200 Subject: [PATCH 2/3] Conditionally write an outdated message with a link to newest available version. --- python_docs_theme/layout.html | 14 ++++++-------- python_docs_theme/static/pydoctheme.css | 7 +++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/python_docs_theme/layout.html b/python_docs_theme/layout.html index 830ddaf8..11fd43d9 100644 --- a/python_docs_theme/layout.html +++ b/python_docs_theme/layout.html @@ -1,15 +1,13 @@ {% extends "classic/layout.html" %} {% block header %} - -
    - This document is for a version of Python that is no longer supported. Please upgrade to a newer release! +{%- if outdated is defined %} +
    + This document is for an old version of Python that is no longer supported. + You should upgrade, and read the + Python documentation for the last stable release.
    +{%- endif %} {% endblock %} {% block rootrellink %} diff --git a/python_docs_theme/static/pydoctheme.css b/python_docs_theme/static/pydoctheme.css index 2aa5bad9..d7ba11e0 100644 --- a/python_docs_theme/static/pydoctheme.css +++ b/python_docs_theme/static/pydoctheme.css @@ -195,3 +195,10 @@ div.footer a:hover { dl > dt span ~ em { font-family: monospace, sans-serif; } + +#outdated-warning { + padding: .5em; + text-align: center; + background-color: #FFBABA; + color: #6A0E0E; +} From bca037d5a3362f90411cc99f0ca4d3d938e41b3e Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Wed, 8 May 2019 19:22:40 +0200 Subject: [PATCH 3/3] Generic version, documented. --- README.rst | 28 ++++++++++++++++++++++++++++ python_docs_theme/layout.html | 7 +++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 1ba79624..0c42335c 100644 --- a/README.rst +++ b/README.rst @@ -13,3 +13,31 @@ trust. To use the theme, install it into your docs build environment via ``pip``:: pip install python-docs-theme + + +Features +======== + +Outdated redirection +-------------------- + +You can define the ``outdated_message`` and ``outdated_link_text`` +variables to show a red banner on each page redirecting to the "latest" +version. + +The ``outdated_message`` comes first, the ``outdated_link_text`` comes +afterwards and is the one user can click. When clicking on +``outdated_link_text``, they will be redirected to the same page +stripped from any prefix. + +Meaning if they're on ``/2.7/``, they'll go to ``/``, if they're on +``/2.7/tutorial/`` they'll go to ``/tutorial/``. + +Sadly it also mean that if you're on ``/fr/3.7/c-api/`` you'll be +redirected to ``/c-api/``, but as we don't know your URL patterns we +can't really do better. + +You can personalize the URL by redefining the ``outdated_href`` block, +by default it contains:: + + /{{ pagename }}{{ file_suffix }} diff --git a/python_docs_theme/layout.html b/python_docs_theme/layout.html index 11fd43d9..1e0e11af 100644 --- a/python_docs_theme/layout.html +++ b/python_docs_theme/layout.html @@ -1,11 +1,10 @@ {% extends "classic/layout.html" %} {% block header %} -{%- if outdated is defined %} +{%- if outdated_message is defined and outdated_link_text is defined %}
    - This document is for an old version of Python that is no longer supported. - You should upgrade, and read the - Python documentation for the last stable release. + {{ outdated_message }} + {{ outdated_link_text }}.
    {%- endif %} {% endblock %}