diff --git a/build/change_file_extension.sh b/build/change_file_extension.sh new file mode 100755 index 000000000..fd3d071c0 --- /dev/null +++ b/build/change_file_extension.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find ./locale -name '*.pot' -exec sh -c 'mv "$0" "${0%.pot}.po"' {} \; diff --git a/user_manual/Makefile b/user_manual/Makefile index 4ac248984..f3ee190da 100644 --- a/user_manual/Makefile +++ b/user_manual/Makefile @@ -13,6 +13,7 @@ PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +LANGS = $(shell touch locale/en && ls locale | grep -v source && rm locale/en) # this trick to add en in the list of langs .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext @@ -41,20 +42,34 @@ help: clean: -rm -rf $(BUILDDIR)/* + git clean -d -f ./locale/ + git checkout locale + git checkout ./_templates/versions.html -html: html-com +html: + ../build/change_file_extension.sh + make versions-template-all html-all merge-folders -html-all: html-release html-com +versions-template-all: $(foreach lang, $(LANGS), add-lang-to-versions-template-$(lang)) -html-release: - $(SPHINXBUILD) -b html -D html_theme='sphinx_rtd_theme' $(ALLSPHINXOPTS) $(BUILDDIR)/html/release - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html/release." +add-lang-to-versions-template-%: + sed -i '/Here goes the Langs/i
$*
' ./_templates/versions.html -html-com: - $(SPHINXBUILD) -b html -D html_theme='sphinx_rtd_theme' $(ALLSPHINXOPTS) $(BUILDDIR)/html/com - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html/com." +html-all: $(foreach lang, $(LANGS), html-lang-$(lang)) + +html-lang-%: + $(SPHINXBUILD) -b html -D html_theme='sphinx_rtd_theme' -D language=$* $(ALLSPHINXOPTS) $(BUILDDIR)/html/$* + @echo "Build finished for LANG=$*. The HTML pages are in $(BUILDDIR)/html/$*." + +merge-folders: + mv $(BUILDDIR)/html/en/_static/ . + mv $(BUILDDIR)/html/en/_images/ . + cd $(BUILDDIR)/html/ && rm -rf `find -type d -name _static` + cd $(BUILDDIR)/html/ && rm -rf `find -type d -name _images` + mv ./_static $(BUILDDIR)/html/ + mv ./_images $(BUILDDIR)/html/ + cd $(BUILDDIR)/html/ && find ./ -type f -exec sed -i -e 's/_images/..\/_images/g' {} \; + cd $(BUILDDIR)/html/ && find ./ -type f -exec sed -i -e 's/_static/..\/_static/g' {} \; dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml diff --git a/user_manual/_templates/versions.html b/user_manual/_templates/versions.html new file mode 100644 index 000000000..39ab4da93 --- /dev/null +++ b/user_manual/_templates/versions.html @@ -0,0 +1,40 @@ +{% if READTHEDOCS %} +{# Add rst-badge after rst-versions for small badge style. #} +
+ + Read the Docs + v: {{ current_version }} + + +
+
+
Languages
+ +
+
+
+
+
{{ _('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 %} \ No newline at end of file diff --git a/user_manual/conf.py b/user_manual/conf.py index 1d3c6fdd5..f65dcd893 100644 --- a/user_manual/conf.py +++ b/user_manual/conf.py @@ -32,7 +32,7 @@ from conf import * extensions += ['sphinx.ext.todo', 'rst2pdf.pdfbuilder', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. -templates_path = ['../_shared_assets/templates'] +templates_path = ['../_shared_assets/templates', '_templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -314,4 +314,5 @@ html_context['versions'] = generateVersionsDocs(current_docs) html_context['theme_vcs_pageview_mode'] += current_docs # translation +locale_dirs = ['locale/'] # path is example but recommended. gettext_compact = False # optional.