Merge pull request #664 from kaiyou/feat-docs-versions

Implement a multi-version documentation
master
mergify[bot] 6 years ago committed by GitHub
commit f2c4e52fee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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,2 +1,9 @@
{% set version=github_version %}
{% extends "!layout.html" %} {% extends "!layout.html" %}
{% block document %}
{% if version != stable_version %}
<div class="wy-alert info">
<p>You are currently browsing documentation for the <b>{{ version }}</b> branch. Documentation for the stable <b>{{ stable_version }}</b> branch can be found <a href="/{{ stable_version }}/">here</a>.</p>
</div>
{% endif %}
{{ super() }}
{% endblock %}

@ -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'
@ -9,9 +11,9 @@ master_doc = 'index'
project = 'Mailu' project = 'Mailu'
copyright = '2018, Mailu authors' copyright = '2018, Mailu authors'
author = 'Mailu authors' author = 'Mailu authors'
version = release = 'latest' version = release = os.environ.get('VERSION', 'master')
language = None language = None
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'Dockerfile', 'docker-compose.yml']
pygments_style = 'sphinx' pygments_style = 'sphinx'
todo_include_todos = False todo_include_todos = False
html_theme = 'sphinx_rtd_theme' html_theme = 'sphinx_rtd_theme'
@ -33,6 +35,11 @@ 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': version,
'stable_version': '1.5',
'versions': [
('1.5', '/1.5/'),
('master', '/master/')
],
'conf_py_path': '/docs/' 'conf_py_path': '/docs/'
} }

@ -113,7 +113,8 @@ Documentation is maintained in the ``docs`` directory and are maintained as `reS
docker build -t docs docs docker build -t docs docs
docker run -p 127.0.0.1:8080:80 docs docker run -p 127.0.0.1:8080:80 docs
You can now read the local documentation by navigating to http://localhost:8080. In a local build Docker always assumes the version to be master.
You can read the local documentation by navigating to http://localhost:8080/master.
.. note:: After modifying the documentation, the image needs to be rebuild and the container restarted for the changes to become visible. .. note:: After modifying the documentation, the image needs to be rebuild and the container restarted for the changes to become visible.

@ -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