mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add support for other documentation languages.
This commit is contained in:
parent
9ccf0896b5
commit
3cd0ac8642
3 changed files with 72 additions and 23 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -42,4 +42,8 @@ tags
|
|||
|
||||
# ignore Vagrant file
|
||||
Vagrantfile
|
||||
.vagrant
|
||||
.vagrant
|
||||
|
||||
# Compiled translation files should not be VCS'ed
|
||||
# locale/zh_CN/LC_MESSAGES/topics/virt/nic.mo
|
||||
*.mo
|
||||
|
|
76
doc/Makefile
76
doc/Makefile
|
@ -6,20 +6,36 @@ SPHINXOPTS =
|
|||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
SPHINXLANG =
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# ----- Translations Support ------------------------------------------------>
|
||||
# If language is set, also set translation options
|
||||
ifeq ($(shell [ "x$(SPHINXLANG)" != "x" ] && echo 0 || echo 1), 0)
|
||||
TRANSLATIONOPTS = -D language='$(SPHINXLANG)'
|
||||
else
|
||||
TRANSLATIONOPTS =
|
||||
endif
|
||||
|
||||
# Reset settings if sphinx-intl is not available
|
||||
ifeq ($(shell which sphinx-intl >/dev/null 2>&1; echo $$?), 1)
|
||||
SPHINXLANG =
|
||||
TRANSLATIONOPTS =
|
||||
endif
|
||||
# <---- Translations Support -------------------------------------------------
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(TRANSLATIONOPTS) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext all
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
|
@ -49,38 +65,56 @@ help:
|
|||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
translations:
|
||||
|
||||
@if [ "$(SPHINXLANG)" = "en" ] || [ "x$(SPHINXLANG)" = "x" ]; then \
|
||||
echo "No need to update translations. Skipping..."; \
|
||||
elif [ ! -d locale/$(SPHINXLANG) ]; then \
|
||||
echo "The locale directory for $(SPHINXLANG) does not exist"; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "Extracting translatable strings"; \
|
||||
make gettext; \
|
||||
\
|
||||
echo "Updating existing translation catalog for '$(SPHINXLANG)'"; \
|
||||
sphinx-intl update -p _build/locale -l $(SPHINXLANG); \
|
||||
\
|
||||
echo "Compiling exising message catalog for '$(SPHINXLANG)'"; \
|
||||
sphinx-intl build -l $(SPHINXLANG); \
|
||||
fi
|
||||
|
||||
html: translations
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
dirhtml: translations
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
singlehtml: translations
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
pickle: translations
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
json: translations
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
htmlhelp: translations
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
qthelp: translations
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
|
@ -89,7 +123,7 @@ qthelp:
|
|||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Salt.qhc"
|
||||
|
||||
devhelp:
|
||||
devhelp: translations
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
|
@ -98,48 +132,48 @@ devhelp:
|
|||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Salt"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
epub: translations
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
latex: translations
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
latexpdf: translations
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
latexpdfja: translations
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
text: translations
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
man: translations
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
texinfo: translations
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
info: translations
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
|
@ -150,7 +184,7 @@ gettext:
|
|||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
changes: translations
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
@ -166,12 +200,12 @@ doctest:
|
|||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
xml: translations
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
pseudoxml: translations
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
|
|
13
doc/conf.py
13
doc/conf.py
|
@ -72,8 +72,13 @@ for mod_name in MOCK_MODULES:
|
|||
|
||||
|
||||
# -- Add paths to PYTHONPATH ---------------------------------------------------
|
||||
try:
|
||||
docs_basepath = os.path.abspath(os.path.dirname(__file__))
|
||||
except NameError:
|
||||
# sphinx-intl and six execute some code which will raise this NameError
|
||||
# assume we're in the doc/ directory
|
||||
docs_basepath = os.path.abspath(os.path.dirname('.'))
|
||||
|
||||
docs_basepath = os.path.abspath(os.path.dirname(__file__))
|
||||
addtl_paths = (
|
||||
os.pardir, # salt itself (for autodoc)
|
||||
'_ext', # custom Sphinx extensions
|
||||
|
@ -82,6 +87,8 @@ addtl_paths = (
|
|||
for path in addtl_paths:
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(docs_basepath, path)))
|
||||
|
||||
|
||||
# We're now able to import salt
|
||||
import salt.version
|
||||
|
||||
|
||||
|
@ -140,6 +147,10 @@ extlinks = {
|
|||
}
|
||||
|
||||
|
||||
# ----- Localization -------------------------------------------------------->
|
||||
locale_dirs = ['locale/']
|
||||
gettext_compact = False
|
||||
# <---- Localization ---------------------------------------------------------
|
||||
### HTML options
|
||||
if on_rtd:
|
||||
html_theme = 'default'
|
||||
|
|
Loading…
Add table
Reference in a new issue