Compiles all the langs.

This commit is contained in:
pierreozoux
2020-07-30 11:14:37 +02:00
parent 09a0e16b01
commit 81e8a66c62
4 changed files with 70 additions and 11 deletions

3
build/change_file_extension.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
find ./locale -name '*.pot' -exec sh -c 'mv "$0" "${0%.pot}.po"' {} \;

View File

@@ -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 <dd><a href="/$*/">$*</a></dd>' ./_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

View File

@@ -0,0 +1,40 @@
{% if READTHEDOCS %}
{# Add rst-badge after rst-versions for small badge style. #}
<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"> Read the Docs</span>
v: {{ current_version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Languages</dt>
<!--Here goes the Langs-->
</dl>
</div>
<div class="rst-other-versions">
<dl>
<dt>{{ _('Versions') }}</dt>
{% for slug, url in versions %}
<dd><a href="{{ url }}">{{ slug }}</a></dd>
{% endfor %}
</dl>
<dl>
<dt>{{ _('Downloads') }}</dt>
{% for type, url in downloads %}
<dd><a href="{{ url }}">{{ type }}</a></dd>
{% endfor %}
</dl>
<dl>
{# Translators: The phrase "Read the Docs" is not translated #}
<dt>{{ _('On Read the Docs') }}</dt>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/projects/{{ slug }}/?fromdocs={{ slug }}">{{ _('Project Home') }}</a>
</dd>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/builds/{{ slug }}/?fromdocs={{ slug }}">{{ _('Builds') }}</a>
</dd>
</dl>
</div>
</div>
{% endif %}

View File

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