This commit is contained in:
Tobias Oberstein
2014-07-26 17:49:02 +02:00
parent b4139c0c6e
commit aa2ef4b4a5
13 changed files with 26 additions and 481 deletions

4
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
_build
_upload
_static/img/gen
.sconsign.dblite

View File

@@ -1,181 +0,0 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# 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
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
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) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)
mkdir $(BUILDDIR)
api:
sphinx-apidoc -o ./reference ../autobahn/autobahn/
html:
PYTHONPATH="../autobahn" $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(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:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/textblob.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/textblob.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/textblob"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/textblob"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(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:
$(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:
$(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:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(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:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

View File

@@ -48,3 +48,7 @@ scons -uc
```
to cleanup.
sphinx-apidoc -o ./reference ../autobahn/autobahn/
http://svn.python.org/projects/external/Sphinx-1.2/doc/templating.rst

View File

@@ -23,8 +23,10 @@ SVG_FILES = [
IMG_SOURCE_DIR = "design"
IMG_GEN_DIR = "_static/img/gen"
DOCSDIR = '_build/html'
S3DIR = '_upload'
DOCSDIR = '_build'
UPLOADED = '_upload'
BUCKET = 'autobahn.ws'
BUCKET_PREFIX = 'python'
@@ -32,60 +34,37 @@ import os
import json
import pkg_resources
taschenmesser = pkg_resources.resource_filename('taschenmesser', '..')
#taschenmesser = "../../../infrequent/taschenmesser"
#taschenmesser = pkg_resources.resource_filename('taschenmesser', '..')
taschenmesser = "../../../infrequent/taschenmesser"
env = Environment(tools = ['default', 'taschenmesser'],
toolpath = [taschenmesser],
ENV = os.environ)
## build optimized SVGs, PNGs and gzipped versions of the former
## inside IMG_GEN_DIR
## Process SVGs
##
imgs = []
for svg in SVG_FILES:
svgOpt = env.Scour("%s/%s" % (IMG_GEN_DIR, svg),
"%s/%s" % (IMG_SOURCE_DIR, svg),
SCOUR_OPTIONS = {'enable_viewboxing': True})
imgs.append(svgOpt)
imgs.append(env.GZip("%s.gz" % svgOpt[0], svgOpt))
png = env.Svg2Png("%s.png" % os.path.splitext(str(svgOpt[0]))[0], svgOpt, SVG2PNG_OPTIONS = {})
imgs.append(png)
imgs.append(env.GZip("%s.gz" % png[0], png))
imgs = env.process_svg(SVG_FILES, IMG_SOURCE_DIR, IMG_GEN_DIR)
#Alias("img", imgs)
Alias("img", imgs)
##
## Sphinx Build
##
docs = env.Command(DOCSDIR, [], "sphinx-build -b html . $TARGET")
env.AlwaysBuild(docs)
Depends(docs, imgs)
Clean(docs, DOCSDIR)
Alias("doc", docs)
Default([imgs, docs])
##
## Upload to Amazon S3
##
uploaded = env.s3_dir_uploader(S3DIR, DOCSDIR, 'autobahn.ws', 'python/')
uploaded = env.s3_dir_uploader(UPLOADED, DOCSDIR, BUCKET, BUCKET_PREFIX)
# env['S3_RELPATH'] = DOCSDIR
# env['S3_BUCKET'] = 'autobahn.ws'
# env['S3_BUCKET_PREFIX'] = 'python/' # note the trailing slash!
# env['S3_OBJECT_ACL'] = 'public-read'
Depends(uploaded, docs)
Depends(uploaded, imgs)
# uploaded = []
# import fnmatch
# for root, dirnames, filenames in os.walk(DOCSDIR):
# if not root.endswith('.doctrees'):
# for filename in filenames:
# if not fnmatch.fnmatch(filename, '*.s3'):
# source = os.path.join(root, filename)
# target = os.path.join(S3DIR, source)
# uploaded.append(env.S3('{}.s3'.format(target), source))
# Depends(uploaded, docs)
# Clean(docs, S3DIR)
# Alias("publish", uploaded)
Clean(uploaded, UPLOADED)
Alias("publish", uploaded)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 209 29" xmlns:dc="http://purl.org/dc/elements/1.1/">
<g transform="matrix(.67518 0 0 .67518 -25.571 -4.0585)">
<path d="m71.172 39.208h-6.641l-2.6399-6.8679h-12.086l-2.4955 6.8679h-6.476l11.776-30.235h6.4554zm-11.24-11.962-4.1661-11.22-4.0836 11.22z" fill="#027eae"/>
<path d="m88.806 39.208v-3.2793c-0.7974 1.1688-1.8458 2.09-3.1451 2.7637-1.2994 0.6737-2.6709 1.0106-4.1146 1.0106-1.4712 0-2.7911-0.3231-3.9598-0.9694-1.1687-0.6462-2.0143-1.5537-2.5368-2.7224s-0.7837-2.7842-0.7837-4.8466v-13.86h5.7954v10.065c0 3.0799 0.1065 4.967 0.3197 5.6613 0.2131 0.6944 0.6015 1.2444 1.1652 1.65 0.5638 0.4056 1.2787 0.6084 2.145 0.6084 0.9899 0 1.8767-0.2716 2.6605-0.8147 0.7837-0.5431 1.3199-1.2168 1.6087-2.0211 0.2887-0.8044 0.433-2.774 0.4331-5.9089v-9.2396h5.7954v21.903z" fill="#027eae"/>
<path d="m110.26 17.305v4.6198h-3.9598v8.8272c0 1.7874 0.038 2.8289 0.1134 3.1245 0.076 0.2957 0.2475 0.5397 0.5156 0.7322s0.5947 0.2887 0.9797 0.2887c0.5362 0 1.313-0.1856 2.3305-0.5568l0.495 4.4961c-1.3475 0.5774-2.8737 0.8662-4.5786 0.8662-1.045 0-1.9868-0.1753-2.8255-0.5259-0.8387-0.3507-1.454-0.8044-1.8459-1.3612-0.3918-0.5569-0.6634-1.3097-0.8146-2.2584-0.1238-0.6737-0.1857-2.0349-0.1857-4.0836v-9.549h-2.6605v-4.6198h2.6605v-4.3517l5.8161-3.3824v7.7341z" fill="#027eae"/>
<path d="m112.98 27.947c0-1.9249 0.4744-3.788 1.4231-5.5892 0.9487-1.8011 2.2927-3.1761 4.032-4.1248s3.6814-1.4231 5.8263-1.4231c3.3136 0 6.0292 1.0759 8.1466 3.2277s3.1761 4.8708 3.1761 8.1569c0 3.3136-1.069 6.0601-3.2071 8.2393-2.138 2.1793-4.8295 3.269-8.0743 3.269-2.0075 0-3.9221-0.4538-5.7439-1.3612-1.8218-0.9075-3.207-2.2377-4.1557-3.9908s-1.4231-3.8877-1.4231-6.4038zm5.9398 0.3093c0 2.1725 0.5156 3.8362 1.5468 4.9911 1.0312 1.155 2.303 1.7324 3.8155 1.7324 1.5124 0 2.7808-0.5774 3.8051-1.7324 1.0243-1.1549 1.5365-2.8324 1.5365-5.0323 0-2.1449-0.5122-3.7948-1.5365-4.9498-1.0243-1.1549-2.2927-1.7324-3.8051-1.7324-1.5125 0-2.7843 0.5775-3.8155 1.7324-1.0312 1.155-1.5468 2.8186-1.5468 4.991z" fill="#027eae"/>
<path d="m139.89 39.208v-30.235h5.7954v10.89c1.7874-2.0349 3.9048-3.0524 6.3522-3.0524 2.6674 0 4.8742 0.9659 6.6204 2.8977 1.7461 1.9318 2.6192 4.7058 2.6193 8.3219-0.0001 3.7398-0.8903 6.6204-2.6709 8.6415-1.7806 2.0212-3.9427 3.0318-6.4863 3.0318-1.2512 0-2.4852-0.3128-3.702-0.9384-1.2169-0.6256-2.2653-1.5503-3.1452-2.774v3.2174zm5.7541-11.426c0 2.2687 0.3575 3.9461 1.0725 5.0323 1.0037 1.5399 2.3374 2.3099 4.0011 2.3099 1.2787 0 2.3683-0.5465 3.2689-1.6396s1.3509-2.8152 1.3509-5.1664c0-2.5024-0.4538-4.307-1.3612-5.4138-0.9075-1.1068-2.0693-1.6603-3.4855-1.6603-1.3887 0-2.5437 0.5397-3.4649 1.619-0.9212 1.0794-1.3818 2.719-1.3818 4.9189z" fill="#027eae"/>
<path d="m170.29 23.988-5.2591-0.9487c0.5912-2.1174 1.6086-3.6848 3.0523-4.7023 1.4437-1.0174 3.5886-1.5262 6.4348-1.5262 2.5849 0 4.5098 0.306 5.7748 0.9178 1.2649 0.6119 2.1552 1.3887 2.6708 2.3305 0.5156 0.9419 0.7734 2.6709 0.7734 5.187l-0.062 6.7647c0 1.925 0.093 3.3446 0.2785 4.2589 0.1855 0.9144 0.5327 1.894 1.0415 2.939h-5.7336c-0.1512-0.385-0.3368-0.9556-0.5568-1.7118-0.096-0.3438-0.165-0.5706-0.2062-0.6806-0.99 0.9624-2.0487 1.6843-3.1762 2.1655-1.1274 0.4813-2.3305 0.7219-3.6092 0.7219-2.2549 0-4.032-0.6119-5.3314-1.8356-1.2993-1.2237-1.9489-2.7705-1.9489-4.6404 0-1.2375 0.2956-2.3409 0.8868-3.3102s1.4196-1.7118 2.4852-2.2274 2.6021-0.9659 4.6095-1.3509c2.7086-0.5087 4.5854-0.9831 5.6304-1.4231v-0.5774c0-1.1137-0.275-1.9078-0.8249-2.3821-0.55-0.4744-1.5881-0.7116-3.1143-0.7116-1.0312 0-1.8356 0.2028-2.413 0.6084-0.5775 0.4057-1.045 1.1172-1.4025 2.1346zm7.7547 4.7024c-0.7425 0.2475-1.918 0.5431-3.5267 0.8868s-2.6605 0.6806-3.1555 1.0106c-0.7562 0.5362-1.1344 1.2168-1.1343 2.0418-0.0001 0.8112 0.3024 1.5124 0.9074 2.1036 0.605 0.5913 1.375 0.8869 2.3099 0.8869 1.045 0 2.0418-0.3438 2.9905-1.0312 0.7012-0.5225 1.1618-1.1619 1.3819-1.9181 0.1512-0.495 0.2268-1.4368 0.2268-2.8255z" fill="#027eae"/>
<path d="m195.25 8.9731v11.116c1.8699-2.1862 4.1042-3.2793 6.7029-3.2793 1.3336 0 2.5367 0.2475 3.6092 0.7425 1.0724 0.495 1.8802 1.1275 2.4233 1.8974 0.5431 0.77 0.9143 1.6225 1.1137 2.5574 0.1994 0.935 0.2991 2.3856 0.2991 4.3517v12.849h-5.7954v-11.57c0-2.2961-0.11-3.7536-0.33-4.3723s-0.6084-1.1103-1.1653-1.4746c-0.5568-0.3644-1.2546-0.5466-2.0933-0.5466-0.9625 0-1.8218 0.2338-2.578 0.7012-0.7563 0.4675-1.3097 1.1722-1.6603 2.114-0.3506 0.9419-0.5259 2.334-0.5259 4.1764v10.972h-5.7954v-30.235z" fill="#027eae"/>
<path d="m235.22 39.208h-5.7954v-11.178c0-2.3649-0.1238-3.8945-0.3713-4.5889-0.2475-0.6943-0.6496-1.234-1.2065-1.619-0.5568-0.385-1.2271-0.5775-2.0108-0.5775-1.0038 0-1.9043 0.275-2.7018 0.825s-1.344 1.2787-1.6396 2.1862c-0.2956 0.9074-0.4435 2.5849-0.4434 5.0323v9.9202h-5.7954v-21.903h5.3829v3.2174c1.9111-2.4749 4.3173-3.7124 7.2184-3.7124 1.2787 0 2.4474 0.2303 3.5062 0.6909 1.0586 0.4607 1.8595 1.0484 2.4027 1.7634 0.5431 0.715 0.9212 1.5262 1.1343 2.4337 0.2131 0.9074 0.3197 2.2068 0.3197 3.8979z" fill="#027eae"/>
<path d="m241.05 46v-30.287h2.4741v30.287z" fill="#9ed106"/>
<path d="m248.96 39.208v-23.102h8.7143c1.5338 0 2.7052 0.074 3.5141 0.2206 1.1346 0.1892 2.0853 0.549 2.8523 1.0795 0.7668 0.5305 1.384 1.2738 1.8516 2.2298 0.4674 0.956 0.7012 2.0066 0.7012 3.1516 0 1.9646-0.6251 3.6271-1.8752 4.9875-1.2502 1.3605-3.5089 2.0408-6.7761 2.0407h-5.9251v9.392zm3.0571-12.118h5.9724c1.975 0 3.3775-0.3677 4.2074-1.1031 0.83-0.7354 1.2449-1.7702 1.2449-3.1044 0-0.9665-0.2442-1.7938-0.7327-2.4819s-1.132-1.1425-1.9304-1.3631c-0.5148-0.1366-1.4655-0.2049-2.8523-0.2049h-5.9093z" fill="#666"/>
<path d="m270.03 45.653-0.3152-2.6631c0.6199 0.1681 1.1609 0.2521 1.6231 0.2521 0.6304 0 1.1346-0.105 1.5128-0.3151 0.3782-0.2102 0.6881-0.5043 0.9298-0.8825 0.1786-0.2837 0.4675-0.9875 0.8667-2.1116 0.053-0.1576 0.1366-0.3887 0.2521-0.6934l-6.3506-16.767h3.0571l3.4826 9.6913c0.4518 1.2292 0.8562 2.5214 1.2134 3.8766 0.3257-1.3027 0.7144-2.5739 1.1661-3.8135l3.5772-9.7544h2.8365l-6.3664 17.019c-0.6829 1.8385-1.2134 3.1044-1.5916 3.7978-0.5043 0.935-1.0821 1.6205-1.7334 2.0564-0.6514 0.436-1.4288 0.654-2.3322 0.654-0.5463 0-1.1556-0.1155-1.828-0.3467z" fill="#666"/>
<path d="m292.48 36.671 0.4097 2.5056c-0.7984 0.1681-1.5128 0.2521-2.1431 0.2521-1.0296 0-1.828-0.1628-2.3953-0.4885s-0.9665-0.7538-1.1976-1.2843-0.3467-1.6467-0.3467-3.3486v-9.6284h-2.0801v-2.2061h2.0801v-4.1445l2.8207-1.7018v5.8463h2.8523v2.2061h-2.8523v9.7859c0 0.809 0.05 1.329 0.1497 1.5601 0.1 0.2311 0.2627 0.415 0.4885 0.5516 0.2259 0.1365 0.549 0.2048 0.9692 0.2048 0.3151 0 0.7301-0.037 1.2449-0.1103z" fill="#666"/>
<path d="m295.24 39.208v-23.102h2.8365v8.2889c1.3237-1.5338 2.9941-2.3007 5.0111-2.3007 1.2397 0 2.3165 0.2443 3.2305 0.7327 0.9139 0.4886 1.5679 1.1635 1.9619 2.025 0.3939 0.8614 0.5909 2.1116 0.5909 3.7505v10.605h-2.8365v-10.605c0-1.4183-0.3073-2.4504-0.9218-3.0965-0.6146-0.6461-1.4839-0.9692-2.608-0.9692-0.8405 0-1.631 0.218-2.3717 0.654-0.7406 0.436-1.2685 1.0269-1.5837 1.7728-0.3151 0.7459-0.4727 1.7754-0.4727 3.0886v9.1556z" fill="#666"/>
<path d="m312.15 30.841c0-3.0991 0.8615-5.3945 2.5844-6.8863 1.4392-1.2397 3.1937-1.8595 5.2633-1.8595 2.3007 0 4.1812 0.7538 5.6414 2.2613 1.4603 1.5076 2.1904 3.5903 2.1904 6.2482 0 2.1536-0.323 3.8476-0.9691 5.082s-1.5863 2.193-2.8207 2.8759-2.5818 1.0243-4.042 1.0243c-2.3428 0-4.2364-0.7512-5.6809-2.2534-1.4445-1.5023-2.1668-3.6665-2.1668-6.4925zm2.9153 0c0 2.1432 0.4675 3.7479 1.4025 4.8142s2.1116 1.5995 3.5299 1.5995c1.4077 0 2.5791-0.5358 3.5141-1.6074 0.9349-1.0715 1.4024-2.7052 1.4025-4.9008-0.0001-2.0696-0.4702-3.6375-1.4104-4.7039-0.9403-1.0663-2.109-1.5994-3.5062-1.5994-1.4183 0-2.5949 0.5305-3.5299 1.5916-0.935 1.061-1.4025 2.6631-1.4025 4.8062z" fill="#666"/>
<path d="m331.17 39.208v-16.735h2.5529v2.3795c1.2291-1.8385 3.0045-2.7577 5.3263-2.7577 1.0085 0 1.9356 0.1812 2.7813 0.5436 0.8457 0.3625 1.4786 0.8379 1.8989 1.4262 0.4202 0.5883 0.7143 1.2869 0.8824 2.0958 0.1051 0.5253 0.1576 1.4445 0.1576 2.7577v10.29h-2.8365v-10.18c0-1.1556-0.1103-2.0196-0.3309-2.5922-0.2206-0.5725-0.6119-1.0295-1.174-1.371-0.562-0.3414-1.2213-0.5121-1.9776-0.5121-1.2082 0-2.2509 0.3834-3.1281 1.1503s-1.3158 2.222-1.3158 4.3651v9.1398z" fill="#666"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

View File

@@ -1,241 +0,0 @@
.. _templating:
Templating
==========
Sphinx uses the `Jinja <http://jinja.pocoo.org>`_ templating engine for its HTML
templates. Jinja is a text-based engine, and inspired by Django templates, so
anyone having used Django will already be familiar with it. It also has
excellent documentation for those who need to make themselves familiar with it.
Do I need to use Sphinx' templates to produce HTML?
---------------------------------------------------
No. You have several other options:
* You can write a :class:`~sphinx.application.TemplateBridge` subclass that
calls your template engine of choice, and set the :confval:`template_bridge`
configuration value accordingly.
* You can :ref:`write a custom builder <writing-builders>` that derives from
:class:`~sphinx.builders.StandaloneHTMLBuilder` and calls your template engine
of choice.
* You can use the :class:`~sphinx.builders.PickleHTMLBuilder` that produces
pickle files with the page contents, and postprocess them using a custom tool,
or use them in your Web application.
Jinja/Sphinx Templating Primer
------------------------------
The default templating language in Sphinx is Jinja. It's Django/Smarty inspired
and easy to understand. The most important concept in Jinja is :dfn:`template
inheritance`, which means that you can overwrite only specific blocks within a
template, customizing it while also keeping the changes at a minimum.
To customize the output of your documentation you can override all the templates
(both the layout templates and the child templates) by adding files with the
same name as the original filename into the template directory of the folder the
Sphinx quickstart generated for you.
Sphinx will look for templates in the folders of :confval:`templates_path`
first, and if it can't find the template it's looking for there, it falls back
to the builtin templates that come with Sphinx.
A template contains **variables**, which are replaced with values when the
template is evaluated, **tags**, which control the logic of the template and
**blocks** which are used for template inheritance.
Sphinx provides base templates with a couple of blocks it will fill with data.
The default templates are located in the :file:`templates` folder of the Sphinx
installation directory. Templates with the same name in the
:confval:`templates_path` override templates located in the builtin folder.
For example, to add a new link to the template area containing related links all
you have to do is to add a new template called ``layout.html`` with the
following contents:
.. sourcecode:: html+jinja
{% extends "!layout.html" %}
{% block rootrellink %}
<li><a href="http://project.invalid/">Project Homepage</a> &raquo;</li>
{{ super() }}
{% endblock %}
By prefixing the name of the extended template with an exclamation mark, Sphinx
will load the builtin layout template. If you override a block, you should call
``{{ super() }}`` somewhere to render the block's content in the extended
template -- unless you don't want that content to show up.
Blocks
~~~~~~
The following blocks exist in the ``layout`` template:
`doctype`
The doctype of the output format. By default this is XHTML 1.0 Transitional
as this is the closest to what Sphinx and Docutils generate and it's a good
idea not to change it unless you want to switch to HTML 5 or a different but
compatible XHTML doctype.
`linktags`
This block adds a couple of ``<link>`` tags to the head section of the
template.
`extrahead`
This block is empty by default and can be used to add extra contents into
the ``<head>`` tag of the generated HTML file. This is the right place to
add references to JavaScript or extra CSS files.
`relbar1` / `relbar2`
This block contains the list of related links (the parent documents on the
left, and the links to index, modules etc. on the right). `relbar1` appears
before the document, `relbar2` after the document. By default, both blocks
are filled; to show the relbar only before the document, you would override
`relbar2` like this::
{% block relbar2 %}{% endblock %}
`rootrellink` / `relbaritems`
Inside the relbar there are three sections: The `rootrellink`, the links
from the documentation and the custom `relbaritems`. The `rootrellink` is a
block that by default contains a list item pointing to the master document
by default, the `relbaritems` is an empty block. If you override them to
add extra links into the bar make sure that they are list items and end with
the :data:`reldelim1`.
`document`
The contents of the document itself.
`sidebar1` / `sidebar2`
A possible location for a sidebar. `sidebar1` appears before the document
and is empty by default, `sidebar2` after the document and contains the
default sidebar. If you want to swap the sidebar location override this and
call the `sidebar` helper:
.. sourcecode:: html+jinja
{% block sidebar1 %}{{ sidebar() }}{% endblock %}
{% block sidebar2 %}{% endblock %}
(The `sidebar2` location for the sidebar is needed by the ``sphinxdoc.css``
stylesheet, for example.)
`sidebarlogo`
The logo location within the sidebar. Override this if you want to place
some content at the top of the sidebar.
`sidebartoc`
The table of contents within the sidebar.
`sidebarrel`
The relation links (previous, next document) within the sidebar.
`sidebarsourcelink`
The "Show source" link within the sidebar (normally only shown if this is
enabled by :confval:`html_show_sourcelink`).
`sidebarsearch`
The search box within the sidebar. Override this if you want to place some
content at the bottom of the sidebar.
`footer`
The block for the footer div. If you want a custom footer or markup before
or after it, override this one.
Configuration Variables
~~~~~~~~~~~~~~~~~~~~~~~
Inside templates you can set a couple of variables used by the layout template
using the ``{% set %}`` tag:
.. data:: reldelim1
The delimiter for the items on the left side of the related bar. This
defaults to ``' &raquo;'`` Each item in the related bar ends with the value
of this variable.
.. data:: reldelim2
The delimiter for the items on the right side of the related bar. This
defaults to ``' |'``. Each item except of the last one in the related bar
ends with the value of this variable.
Overriding works like this:
.. sourcecode:: html+jinja
{% extends "!layout.html" %}
{% set reldelim1 = ' &gt;' %}
Helper Functions
~~~~~~~~~~~~~~~~
Sphinx provides various Jinja functions as helpers in the template. You can use
them to generate links or output multiply used elements.
.. function:: pathto(document)
Return the path to a Sphinx document as a URL. Use this to refer to built
documents.
.. function:: pathto(file, 1)
Return the path to a *file* which is a filename relative to the root of the
generated output. Use this to refer to static files.
.. function:: hasdoc(document)
Check if a document with the name *document* exists.
.. function:: sidebar()
Return the rendered sidebar.
.. function:: relbar()
Return the rendered relbar.
Global Variables
~~~~~~~~~~~~~~~~
These global variables are available in every template and are safe to use.
There are more, but most of them are an implementation detail and might change
in the future.
.. data:: docstitle
The title of the documentation (the value of :confval:`html_title`).
.. data:: sourcename
The name of the copied source file for the current document. This is only
nonempty if the :confval:`html_copy_source` value is true.
.. data:: builder
The name of the builder (for builtin builders, ``html``, ``htmlhelp``, or
``web``).
.. data:: next
The next document for the navigation. This variable is either false or has
two attributes `link` and `title`. The title contains HTML markup. For
example, to generate a link to the next page, you can use this snippet:
.. sourcecode:: html+jinja
{% if next %}
<a href="{{ next.link|e }}">{{ next.title }}</a>
{% endif %}
.. data:: prev
Like :data:`next`, but for the previous page.