Support multiple docs versions

master
kaiyou 6 years ago
parent 5035975c41
commit 8fa80c1589

@ -2,6 +2,9 @@ FROM python:3-alpine
COPY requirements.txt /requirements.txt COPY requirements.txt /requirements.txt
ARG version=master
ENV VERSION=$version
RUN pip install -r /requirements.txt \ RUN pip install -r /requirements.txt \
&& apk add --no-cache nginx \ && apk add --no-cache nginx \
&& mkdir /run/nginx && mkdir /run/nginx
@ -9,6 +12,7 @@ RUN pip install -r /requirements.txt \
COPY ./nginx.conf /etc/nginx/conf.d/default.conf COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY . /docs COPY . /docs
RUN sphinx-build /docs /build RUN mkdir -p /build/$VERSION \
&& sphinx-build /docs /build/$VERSION
CMD nginx -g "daemon off;" CMD nginx -g "daemon off;"

@ -1,4 +0,0 @@
{%- extends "layout.html" %}
{% block body %}
{{ body|replace("VERSION_TAG", version) }}
{% endblock %}

@ -0,0 +1,16 @@
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Versions</span>
v: {{ version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>{{ _('Versions') }}</dt>
{% for slug, url in versions %}
<dd><a href="{{ url }}">{{ slug }}</a></dd>
{% endfor %}
</dl>
</div>
</div>

@ -2,6 +2,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
import os
extensions = ['sphinx.ext.imgmath', 'sphinx.ext.viewcode'] extensions = ['sphinx.ext.imgmath', 'sphinx.ext.viewcode']
templates_path = ['_templates'] templates_path = ['_templates']
source_suffix = '.rst' source_suffix = '.rst'
@ -33,6 +35,10 @@ html_context = {
'display_github': True, 'display_github': True,
'github_user': 'mailu', 'github_user': 'mailu',
'github_repo': 'mailu', 'github_repo': 'mailu',
'github_version': 'master', 'github_version': os.environ.get('VERSION', 'master'),
'versions': [
('1.5', '/1.5/'),
('master', '/master/')
],
'conf_py_path': '/docs/' 'conf_py_path': '/docs/'
} }

@ -0,0 +1,21 @@
version: '3'
services:
docs_master:
image: mailu/docs:master
labels:
- traefik.enable=true
- traefik.port=80
- traefik.main.frontend.rule=Host:${hostname};PathPrefix:/master/
docs_15:
image: mailu/docs:1.5
labels:
- traefik.enable=true
- traefik.port=80
- traefik.root.frontend.redirect.regex=.*
- traefik.root.frontend.redirect.replacement=/1.5/
- traefik.root.frontend.rule=Host:${hostname};PathPrefix:/
- traefik.main.frontend.rule=Host:${hostname};PathPrefix:/1.5/
Loading…
Cancel
Save