mirror of
https://gitee.com/openharmony/third_party_jinja2
synced 2024-11-23 15:19:46 +00:00
Merge branch '2.10.x'
This commit is contained in:
commit
9550dc85ff
869
CHANGES.rst
869
CHANGES.rst
File diff suppressed because it is too large
Load Diff
11
README.rst
11
README.rst
@ -49,3 +49,14 @@ Builds
|
||||
| ``2.9-maintenance`` | .. image:: https://travis-ci.org/pallets/jinja.svg?branch=2.9-maintenance |
|
||||
| | :target: https://travis-ci.org/pallets/jinja |
|
||||
+---------------------+------------------------------------------------------------------------------+
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: http://jinja.pocoo.org/
|
||||
* Documentation: http://jinja.pocoo.org/docs/
|
||||
* License: `BSD <https://raw.githubusercontent.com/pallets/jinja/master/LICENSE>`_
|
||||
* Releases: https://pypi.org/project/Jinja/
|
||||
* Code: https://github.com/pallets/jinja
|
||||
* Issue tracker: https://github.com/pallets/jinja/issues
|
||||
* Official chat: https://discord.gg/t6rrQZH
|
||||
|
117
docs/Makefile
117
docs/Makefile
@ -1,118 +1,19 @@
|
||||
# Makefile for Sphinx documentation
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp epub latex changes linkcheck doctest
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
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 " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
clean:
|
||||
-rm -rf $(BUILDDIR)/*
|
||||
.PHONY: help Makefile
|
||||
|
||||
html:
|
||||
$(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/Flask.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Flask.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) _build/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/Flask"
|
||||
@echo "# ln -s _build/devhelp $$HOME/.local/share/devhelp/Flask"
|
||||
@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 all-pdf' or \`make all-ps' in that directory to" \
|
||||
"run these through (pdf)latex."
|
||||
|
||||
latexpdf: latex
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
make -C _build/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in _build/latex."
|
||||
|
||||
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."
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
0
docs/_build/.ignore
vendored
0
docs/_build/.ignore
vendored
0
docs/_static/.ignore
vendored
0
docs/_static/.ignore
vendored
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
BIN
docs/_static/jinja-logo.png
vendored
Normal file
BIN
docs/_static/jinja-logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
20
docs/_templates/sidebarintro.html
vendored
20
docs/_templates/sidebarintro.html
vendored
@ -1,20 +0,0 @@
|
||||
<h3>About Jinja2</h3>
|
||||
<p>
|
||||
Jinja2 is a full featured template engine for Python. It has full unicode
|
||||
support, an optional integrated sandboxed execution environment, widely used
|
||||
and BSD licensed.
|
||||
</p>
|
||||
<h3>Other Formats</h3>
|
||||
<p>
|
||||
You can download the documentation in other formats as well:
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="http://jinja.pocoo.org/docs/jinja-docs.pdf">as PDF</a>
|
||||
<li><a href="http://jinja.pocoo.org/docs/jinja-docs.zip">as zipped HTML</a>
|
||||
</ul>
|
||||
<h3>Useful Links</h3>
|
||||
<ul>
|
||||
<li><a href="http://jinja.pocoo.org/">The Jinja2 Website</a></li>
|
||||
<li><a href="https://pypi.org/project/Jinja2/">Jinja2 @ PyPI</a></li>
|
||||
<li><a href="https://github.com/pallets/jinja">Jinja2 @ github</a></li>
|
||||
</ul>
|
3
docs/_templates/sidebarlogo.html
vendored
3
docs/_templates/sidebarlogo.html
vendored
@ -1,3 +0,0 @@
|
||||
<p class="logo"><a href="{{ pathto(master_doc) }}">
|
||||
<img class="logo" src="{{ pathto('_static/jinja-small.png', 1) }}" alt="Logo"/>
|
||||
</a></p>
|
37
docs/_themes/LICENSE
vendored
37
docs/_themes/LICENSE
vendored
@ -1,37 +0,0 @@
|
||||
Copyright (c) 2010 by Armin Ronacher.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms of the theme, with or
|
||||
without modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* The names of the contributors may not be used to endorse or
|
||||
promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
We kindly ask you to only use these themes in an unmodified manner just
|
||||
for Flask and Flask-related products, not for unrelated projects. If you
|
||||
like the visual style and want to use it for your own projects, please
|
||||
consider making some larger changes to the themes (such as changing
|
||||
font faces, sizes, colors or margins).
|
||||
|
||||
THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
31
docs/_themes/README
vendored
31
docs/_themes/README
vendored
@ -1,31 +0,0 @@
|
||||
Flask Sphinx Styles
|
||||
===================
|
||||
|
||||
This repository contains sphinx styles for Flask and Flask related
|
||||
projects. To use this style in your Sphinx documentation, follow
|
||||
this guide:
|
||||
|
||||
1. put this folder as _themes into your docs folder. Alternatively
|
||||
you can also use git submodules to check out the contents there.
|
||||
2. add this to your conf.py:
|
||||
|
||||
sys.path.append(os.path.abspath('_themes'))
|
||||
html_theme_path = ['_themes']
|
||||
html_theme = 'flask'
|
||||
|
||||
The following themes exist:
|
||||
|
||||
- 'flask' - the standard flask documentation theme for large
|
||||
projects
|
||||
- 'flask_small' - small one-page theme. Intended to be used by
|
||||
very small addon libraries for flask.
|
||||
|
||||
The following options exist for the flask_small theme:
|
||||
|
||||
[options]
|
||||
index_logo = '' filename of a picture in _static
|
||||
to be used as replacement for the
|
||||
h1 in the index.rst file.
|
||||
index_logo_height = 120px height of the index logo
|
||||
github_fork = '' repository name on github for the
|
||||
"fork me" badge
|
8
docs/_themes/jinja/layout.html
vendored
8
docs/_themes/jinja/layout.html
vendored
@ -1,8 +0,0 @@
|
||||
{%- extends "basic/layout.html" %}
|
||||
{%- block relbar2 %}{% endblock %}
|
||||
{%- block footer %}
|
||||
<div class="footer">
|
||||
© Copyright {{ copyright }}.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
|
||||
</div>
|
||||
{%- endblock %}
|
19
docs/_themes/jinja/relations.html
vendored
19
docs/_themes/jinja/relations.html
vendored
@ -1,19 +0,0 @@
|
||||
<h3>Related Topics</h3>
|
||||
<ul>
|
||||
<li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>
|
||||
{%- for parent in parents %}
|
||||
<li><a href="{{ parent.link|e }}">{{ parent.title }}</a><ul>
|
||||
{%- endfor %}
|
||||
{%- if prev %}
|
||||
<li>Previous: <a href="{{ prev.link|e }}" title="{{ _('previous chapter')
|
||||
}}">{{ prev.title }}</a></li>
|
||||
{%- endif %}
|
||||
{%- if next %}
|
||||
<li>Next: <a href="{{ next.link|e }}" title="{{ _('next chapter')
|
||||
}}">{{ next.title }}</a></li>
|
||||
{%- endif %}
|
||||
{%- for parent in parents %}
|
||||
</ul></li>
|
||||
{%- endfor %}
|
||||
</ul></li>
|
||||
</ul>
|
396
docs/_themes/jinja/static/jinja.css_t
vendored
396
docs/_themes/jinja/static/jinja.css_t
vendored
@ -1,396 +0,0 @@
|
||||
/*
|
||||
* jinja.css_t
|
||||
* ~~~~~~~~~~~
|
||||
*
|
||||
* :copyright: Copyright 2011 by Armin Ronacher.
|
||||
* :license: Flask Design License, see LICENSE for details.
|
||||
*/
|
||||
|
||||
@import url(http://fonts.googleapis.com/css?family=Crimson+Text);
|
||||
|
||||
{% set page_width = '940px' %}
|
||||
{% set sidebar_width = '220px' %}
|
||||
{% set font_family = 'Georgia, serif' %}
|
||||
{% set header_font_family = 'Crimson Text, ' ~ font_family %}
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: {{ font_family }};
|
||||
font-size: 17px;
|
||||
background-color: white;
|
||||
color: #000;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.document {
|
||||
width: {{ page_width }};
|
||||
margin: 30px auto 0 auto;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 {{ sidebar_width }};
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
width: {{ sidebar_width }};
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 1px solid #B1B4B6;
|
||||
}
|
||||
|
||||
div.body {
|
||||
background-color: #ffffff;
|
||||
color: #3E4349;
|
||||
padding: 0 30px 0 30px;
|
||||
}
|
||||
|
||||
img.floatingflask {
|
||||
padding: 0 0 10px 10px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.footer {
|
||||
width: {{ page_width }};
|
||||
margin: 20px auto 30px auto;
|
||||
font-size: 14px;
|
||||
color: #888;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
div.related {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dotted #999;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a:hover {
|
||||
border-bottom: 1px solid #999;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 18px 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper p.logo {
|
||||
padding: 0 0 20px 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3,
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: {{ font_family }};
|
||||
color: #444;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
margin: 0 0 5px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h4 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p.logo a,
|
||||
div.sphinxsidebar h3 a,
|
||||
div.sphinxsidebar p.logo a:hover,
|
||||
div.sphinxsidebar h3 a:hover {
|
||||
border: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p {
|
||||
color: #555;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
margin: 10px 0;
|
||||
padding: 0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #ccc;
|
||||
font-family: {{ font_family }};
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form.search input[name="q"] {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
a {
|
||||
color: #aa0000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #dd0000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: {{ header_font_family }};
|
||||
font-weight: normal;
|
||||
margin: 30px 0px 10px 0px;
|
||||
padding: 0;
|
||||
color: black;
|
||||
}
|
||||
|
||||
div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
|
||||
div.body h2 { font-size: 180%; }
|
||||
div.body h3 { font-size: 150%; }
|
||||
div.body h4 { font-size: 130%; }
|
||||
div.body h5 { font-size: 100%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
a.headerlink {
|
||||
color: #ddd;
|
||||
padding: 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
color: #444;
|
||||
background: #eaeaea;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
div.admonition {
|
||||
background: #fafafa;
|
||||
margin: 20px -30px;
|
||||
padding: 10px 30px;
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.admonition tt.xref, div.admonition a tt {
|
||||
border-bottom: 1px solid #fafafa;
|
||||
}
|
||||
|
||||
dd div.admonition {
|
||||
margin-left: -60px;
|
||||
padding-left: 60px;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title {
|
||||
font-family: {{ font_family }};
|
||||
font-weight: normal;
|
||||
font-size: 24px;
|
||||
margin: 0 0 10px 0;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
div.admonition p.last {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.highlight {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
dt:target, .highlight {
|
||||
background: #FAF3E8;
|
||||
}
|
||||
|
||||
div.note {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #ffc;
|
||||
border: 1px solid #ff6;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
pre, tt {
|
||||
font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
img.screenshot {
|
||||
}
|
||||
|
||||
tt.descname, tt.descclassname {
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
tt.descname {
|
||||
padding-right: 0.08em;
|
||||
}
|
||||
|
||||
img.screenshot {
|
||||
-moz-box-shadow: 2px 2px 4px #eee;
|
||||
-webkit-box-shadow: 2px 2px 4px #eee;
|
||||
box-shadow: 2px 2px 4px #eee;
|
||||
}
|
||||
|
||||
table.docutils {
|
||||
border: 1px solid #888;
|
||||
-moz-box-shadow: 2px 2px 4px #eee;
|
||||
-webkit-box-shadow: 2px 2px 4px #eee;
|
||||
box-shadow: 2px 2px 4px #eee;
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
border: 1px solid #888;
|
||||
padding: 0.25em 0.7em;
|
||||
}
|
||||
|
||||
table.field-list, table.footnote {
|
||||
border: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
table.footnote {
|
||||
margin: 15px 0;
|
||||
width: 100%;
|
||||
border: 1px solid #eee;
|
||||
background: #fdfdfd;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
table.footnote + table.footnote {
|
||||
margin-top: -15px;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
table.field-list th {
|
||||
padding: 0 0.8em 0 0;
|
||||
}
|
||||
|
||||
table.field-list td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.footnote td.label {
|
||||
width: 0px;
|
||||
padding: 0.3em 0 0.3em 0.5em;
|
||||
}
|
||||
|
||||
table.footnote td {
|
||||
padding: 0.3em 0.5em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
dl dd {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 0 30px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin: 10px 0 10px 30px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 7px 30px;
|
||||
margin: 15px -30px;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
dl pre, blockquote pre, li pre {
|
||||
margin-left: -60px;
|
||||
padding-left: 60px;
|
||||
}
|
||||
|
||||
dl dl pre {
|
||||
margin-left: -90px;
|
||||
padding-left: 90px;
|
||||
}
|
||||
|
||||
tt {
|
||||
background-color: #E8EFF0;
|
||||
color: #222;
|
||||
/* padding: 1px 2px; */
|
||||
}
|
||||
|
||||
tt.xref, a tt {
|
||||
background-color: #E8EFF0;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
a.reference {
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dotted #bb0000;
|
||||
}
|
||||
|
||||
a.reference:hover {
|
||||
border-bottom: 1px solid #dd0000;
|
||||
}
|
||||
|
||||
a.footnote-reference {
|
||||
text-decoration: none;
|
||||
font-size: 0.7em;
|
||||
vertical-align: top;
|
||||
border-bottom: 1px dotted #bb0000;
|
||||
}
|
||||
|
||||
a.footnote-reference:hover {
|
||||
border-bottom: 1px solid #dd0000;
|
||||
}
|
||||
|
||||
a:hover tt {
|
||||
background: #EEE;
|
||||
}
|
3
docs/_themes/jinja/theme.conf
vendored
3
docs/_themes/jinja/theme.conf
vendored
@ -1,3 +0,0 @@
|
||||
[theme]
|
||||
inherit = basic
|
||||
stylesheet = jinja.css
|
@ -115,7 +115,7 @@ for everything else `unicode`:
|
||||
u'f\xf6\xf6'
|
||||
|
||||
|
||||
.. _Unicode documentation: https://docs.python.org/dev/howto/unicode.html
|
||||
.. _Unicode documentation: https://docs.python.org/3/howto/unicode.html
|
||||
|
||||
High Level API
|
||||
--------------
|
||||
|
@ -4,7 +4,7 @@ from jinja2.ext import Extension
|
||||
|
||||
class FragmentCacheExtension(Extension):
|
||||
# a set of names that trigger the extension.
|
||||
tags = set(['cache'])
|
||||
tags = {'cache'}
|
||||
|
||||
def __init__(self, environment):
|
||||
super(FragmentCacheExtension, self).__init__(environment)
|
||||
|
@ -1,3 +1,4 @@
|
||||
.. module:: jinja2
|
||||
Changelog
|
||||
=========
|
||||
|
||||
.. include:: ../CHANGES.rst
|
||||
|
192
docs/conf.py
192
docs/conf.py
@ -1,160 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Jinja2 documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sun Apr 27 21:42:41 2008.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# The contents of this file are pickled, so don't put values in the namespace
|
||||
# that aren't pickleable (module imports are okay, they're removed automatically).
|
||||
#
|
||||
# All configuration values have a default value; values that are commented out
|
||||
# serve to show the default value.
|
||||
from pallets_sphinx_themes import get_version
|
||||
from pallets_sphinx_themes import ProjectLink
|
||||
|
||||
import sys, os
|
||||
# Project --------------------------------------------------------------
|
||||
|
||||
# If your extensions are in another directory, add it here. If the directory
|
||||
# is relative to the documentation root, use os.path.abspath to make it
|
||||
# absolute, like shown here.
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
project = "Jinja"
|
||||
copyright = "2007 Pallets"
|
||||
author = "Pallets"
|
||||
release, version = get_version("Jinja2")
|
||||
|
||||
# General configuration
|
||||
# ---------------------
|
||||
# General --------------------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'jinjaext']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General substitutions.
|
||||
project = 'Jinja2'
|
||||
copyright = '2008, Armin Ronacher'
|
||||
|
||||
# The default replacements for |version| and |release|, also used in various
|
||||
# other places throughout the built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
import pkg_resources
|
||||
try:
|
||||
release = pkg_resources.get_distribution('Jinja2').version
|
||||
except ImportError:
|
||||
print('To build the documentation, The distribution information of Jinja2')
|
||||
print('Has to be available. Either install the package into your')
|
||||
print('development environment or run "setup.py develop" to setup the')
|
||||
print('metadata. A virtualenv is recommended!')
|
||||
sys.exit(1)
|
||||
if 'dev' in release:
|
||||
release = release.split('dev')[0] + 'dev'
|
||||
version = '.'.join(release.split('.')[:2])
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'jinjaext.JinjaStyle'
|
||||
|
||||
|
||||
# Options for HTML output
|
||||
# -----------------------
|
||||
|
||||
html_theme = 'jinja'
|
||||
html_theme_path = ['_themes']
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# no modindex
|
||||
html_use_modindex = False
|
||||
|
||||
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||
#html_copy_source = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it.
|
||||
#html_use_opensearch = False
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Jinja2doc'
|
||||
|
||||
|
||||
# Options for LaTeX output
|
||||
# ------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
latex_paper_size = 'a4'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
latex_documents = [
|
||||
('latexindex', 'Jinja2.tex', 'Jinja2 Documentation', 'Armin Ronacher',
|
||||
'manual'),
|
||||
master_doc = "index"
|
||||
extensions = [
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"pallets_sphinx_themes",
|
||||
"sphinxcontrib.log_cabinet",
|
||||
"sphinx_issues",
|
||||
]
|
||||
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
|
||||
issues_github_path = "pallets/jinja"
|
||||
|
||||
# Additional stuff for LaTeX
|
||||
latex_elements = {
|
||||
'fontpkg': r'\usepackage{mathpazo}',
|
||||
'papersize': 'a4paper',
|
||||
'pointsize': '12pt',
|
||||
'preamble': r'''
|
||||
\usepackage{jinjastyle}
|
||||
# HTML -----------------------------------------------------------------
|
||||
|
||||
% i hate you latex
|
||||
\DeclareUnicodeCharacter{14D}{o}
|
||||
'''
|
||||
html_theme = "jinja"
|
||||
html_theme_options = {"index_sidebar_logo": False}
|
||||
html_context = {
|
||||
"project_links": [
|
||||
ProjectLink("Donate to Pallets", "https://palletsprojects.com/donate"),
|
||||
ProjectLink("Jinja Website", "https://palletsprojects.com/p/jinja/"),
|
||||
ProjectLink("PyPI releases", "https://pypi.org/project/Jinja2/"),
|
||||
ProjectLink("Source Code", "https://github.com/pallets/jinja/"),
|
||||
ProjectLink("Issue Tracker", "https://github.com/pallets/jinja/issues/"),
|
||||
]
|
||||
}
|
||||
|
||||
latex_use_parts = True
|
||||
|
||||
latex_additional_files = ['jinjastyle.sty', 'logo.pdf']
|
||||
|
||||
# If false, no module index is generated.
|
||||
latex_use_modindex = False
|
||||
|
||||
html_sidebars = {
|
||||
'index': ['sidebarlogo.html', 'sidebarintro.html', 'sourcelink.html',
|
||||
'searchbox.html'],
|
||||
'**': ['sidebarlogo.html', 'localtoc.html', 'relations.html',
|
||||
'sourcelink.html', 'searchbox.html']
|
||||
"index": ["project.html", "localtoc.html", "searchbox.html"],
|
||||
"**": ["localtoc.html", "relations.html", "searchbox.html"],
|
||||
}
|
||||
singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
|
||||
html_static_path = ["_static"]
|
||||
html_favicon = "_static/jinja-logo-sidebar.png"
|
||||
html_logo = "_static/jinja-logo-sidebar.png"
|
||||
html_title = "Jinja Documentation ({})".format(version)
|
||||
html_show_sourcelink = False
|
||||
|
||||
# LaTeX ----------------------------------------------------------------
|
||||
|
||||
latex_documents = [
|
||||
(master_doc, "Jinja-{}.tex".format(version), html_title, author, "manual")
|
||||
]
|
||||
|
@ -1,24 +0,0 @@
|
||||
Jinja2 Documentation
|
||||
--------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
intro
|
||||
api
|
||||
sandbox
|
||||
nativetypes
|
||||
templates
|
||||
extensions
|
||||
integration
|
||||
switching
|
||||
tricks
|
||||
|
||||
Additional Information
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
faq
|
||||
changelog
|
@ -106,7 +106,7 @@ current configuration. (For example by using `gettext.find`)
|
||||
The usage of the `i18n` extension for template designers is covered as part
|
||||
:ref:`of the template documentation <i18n-in-templates>`.
|
||||
|
||||
.. _gettext: https://docs.python.org/dev/library/gettext
|
||||
.. _gettext: https://docs.python.org/3/library/gettext.html
|
||||
.. _Babel: http://babel.pocoo.org/
|
||||
|
||||
.. _newstyle-gettext:
|
||||
@ -232,7 +232,7 @@ Example Extension
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
The following example implements a `cache` tag for Jinja2 by using the
|
||||
`Werkzeug`_ caching contrib module:
|
||||
`cachelib`_ library:
|
||||
|
||||
.. literalinclude:: cache_extension.py
|
||||
:language: python
|
||||
@ -240,7 +240,7 @@ The following example implements a `cache` tag for Jinja2 by using the
|
||||
And here is how you use it in an environment::
|
||||
|
||||
from jinja2 import Environment
|
||||
from werkzeug.contrib.cache import SimpleCache
|
||||
from cachelib import SimpleCache
|
||||
|
||||
env = Environment(extensions=[FragmentCacheExtension])
|
||||
env.fragment_cache = SimpleCache()
|
||||
@ -256,7 +256,7 @@ following example caches a sidebar for 300 seconds:
|
||||
</div>
|
||||
{% endcache %}
|
||||
|
||||
.. _Werkzeug: http://werkzeug.pocoo.org/
|
||||
.. _cachelib: https://github.com/pallets/cachelib
|
||||
|
||||
Extension API
|
||||
~~~~~~~~~~~~~
|
||||
@ -345,6 +345,6 @@ For more information have a look at the repr of :meth:`jinja2.Environment.parse`
|
||||
|
||||
.. module:: jinja2.nodes
|
||||
|
||||
.. jinjanodes::
|
||||
.. jinja:nodes:: jinja2.nodes.Node
|
||||
|
||||
.. autoexception:: Impossible
|
||||
|
@ -26,7 +26,7 @@ speaking the performance of a template engine doesn't matter much as the
|
||||
usual bottleneck in a web application is either the database or the application
|
||||
code.
|
||||
|
||||
.. _Mako: http://www.makotemplates.org/
|
||||
.. _Mako: https://www.makotemplates.org/
|
||||
|
||||
How Compatible is Jinja2 with Django?
|
||||
-------------------------------------
|
||||
@ -192,3 +192,4 @@ templates passing information to the parent template. To avoid this
|
||||
issue rename the macro or variable in the parent template to have an
|
||||
uncommon prefix.
|
||||
|
||||
.. _Jinja 1: https://pypi.org/project/Jinja/
|
||||
|
@ -1,7 +1,13 @@
|
||||
Welcome to Jinja2
|
||||
=================
|
||||
.. rst-class:: hide-header
|
||||
|
||||
Jinja2 is a modern and designer-friendly templating language for Python,
|
||||
Jinja
|
||||
=====
|
||||
|
||||
.. image:: _static/jinja-logo.png
|
||||
:align: center
|
||||
:target: https://palletsprojects.com/p/jinja/
|
||||
|
||||
Jinja is a modern and designer-friendly templating language for Python,
|
||||
modelled after Django's templates. It is fast, widely used and secure
|
||||
with the optional sandboxed template execution environment:
|
||||
|
||||
@ -14,7 +20,7 @@ with the optional sandboxed template execution environment:
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
**Features:**
|
||||
Features:
|
||||
|
||||
- sandboxed execution
|
||||
- powerful automatic HTML escaping system for XSS prevention
|
||||
@ -25,10 +31,21 @@ with the optional sandboxed template execution environment:
|
||||
the correct line in the template.
|
||||
- configurable syntax
|
||||
|
||||
.. include:: contents.rst.inc
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
If you can't find the information you're looking for, have a look at the
|
||||
index or try to find it using the search function:
|
||||
intro
|
||||
api
|
||||
sandbox
|
||||
nativetypes
|
||||
templates
|
||||
extensions
|
||||
integration
|
||||
switching
|
||||
tricks
|
||||
faq
|
||||
changelog
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
|
@ -76,7 +76,7 @@ snippet and add it into your `config/environment.py`::
|
||||
|
||||
config['pylons.strict_c'] = True
|
||||
|
||||
.. _Pylons: http://www.pylonshq.com/
|
||||
.. _Pylons: https://pylonshq.com/
|
||||
|
||||
TextMate
|
||||
--------
|
||||
@ -102,5 +102,5 @@ If you are using a plugin manager like `Pathogen`_, see the `vim-jinja
|
||||
``bundle/`` directory.
|
||||
|
||||
.. _Babel: http://babel.pocoo.org/
|
||||
.. _Vim: http://www.vim.org/
|
||||
.. _Vim: https://www.vim.org/
|
||||
.. _Pathogen: https://github.com/tpope/vim-pathogen
|
||||
|
@ -42,9 +42,9 @@ which will install the package via `distribute` in development mode. This also
|
||||
has the advantage that the C extensions are compiled.
|
||||
|
||||
.. _distribute: https://pypi.org/project/distribute/
|
||||
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
|
||||
.. _setuptools: https://pypi.org/project/setuptools/
|
||||
.. _pip: https://pypi.org/project/pip/
|
||||
.. _git: https://git-scm.org/
|
||||
.. _git: https://git-scm.com/
|
||||
|
||||
|
||||
MarkupSafe Dependency
|
||||
@ -53,7 +53,7 @@ MarkupSafe Dependency
|
||||
As of version 2.7 Jinja2 depends on the `MarkupSafe`_ module. If you install
|
||||
Jinja2 via ``pip`` it will be installed automatically for you.
|
||||
|
||||
.. _MarkupSafe: https://pypi.org/project/MarkupSafe/
|
||||
.. _MarkupSafe: https://markupsafe.palletsprojects.com/
|
||||
|
||||
Basic API Usage
|
||||
---------------
|
||||
|
206
docs/jinjaext.py
206
docs/jinjaext.py
@ -1,206 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Jinja Documentation Extensions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Support for automatically documenting filters and tests.
|
||||
|
||||
:copyright: Copyright 2008 by Armin Ronacher.
|
||||
:license: BSD.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import inspect
|
||||
|
||||
import logging
|
||||
|
||||
import jinja2
|
||||
from itertools import islice
|
||||
from types import BuiltinFunctionType
|
||||
from docutils import nodes
|
||||
from docutils.statemachine import ViewList
|
||||
from sphinx.ext.autodoc import prepare_docstring
|
||||
from sphinx.application import TemplateBridge
|
||||
from pygments.style import Style
|
||||
from pygments.token import Keyword, Name, Comment, String, Error, \
|
||||
Number, Operator, Generic
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from jinja2._compat import abc
|
||||
|
||||
|
||||
def parse_rst(state, content_offset, doc):
|
||||
node = nodes.section()
|
||||
# hack around title style bookkeeping
|
||||
surrounding_title_styles = state.memo.title_styles
|
||||
surrounding_section_level = state.memo.section_level
|
||||
state.memo.title_styles = []
|
||||
state.memo.section_level = 0
|
||||
state.nested_parse(doc, content_offset, node, match_titles=1)
|
||||
state.memo.title_styles = surrounding_title_styles
|
||||
state.memo.section_level = surrounding_section_level
|
||||
return node.children
|
||||
|
||||
|
||||
class JinjaStyle(Style):
|
||||
title = 'Jinja Style'
|
||||
default_style = ""
|
||||
styles = {
|
||||
Comment: 'italic #aaaaaa',
|
||||
Comment.Preproc: 'noitalic #B11414',
|
||||
Comment.Special: 'italic #505050',
|
||||
|
||||
Keyword: 'bold #B80000',
|
||||
Keyword.Type: '#808080',
|
||||
|
||||
Operator.Word: 'bold #B80000',
|
||||
|
||||
Name.Builtin: '#333333',
|
||||
Name.Function: '#333333',
|
||||
Name.Class: 'bold #333333',
|
||||
Name.Namespace: 'bold #333333',
|
||||
Name.Entity: 'bold #363636',
|
||||
Name.Attribute: '#686868',
|
||||
Name.Tag: 'bold #686868',
|
||||
Name.Decorator: '#686868',
|
||||
|
||||
String: '#AA891C',
|
||||
Number: '#444444',
|
||||
|
||||
Generic.Heading: 'bold #000080',
|
||||
Generic.Subheading: 'bold #800080',
|
||||
Generic.Deleted: '#aa0000',
|
||||
Generic.Inserted: '#00aa00',
|
||||
Generic.Error: '#aa0000',
|
||||
Generic.Emph: 'italic',
|
||||
Generic.Strong: 'bold',
|
||||
Generic.Prompt: '#555555',
|
||||
Generic.Output: '#888888',
|
||||
Generic.Traceback: '#aa0000',
|
||||
|
||||
Error: '#F00 bg:#FAA'
|
||||
}
|
||||
|
||||
|
||||
_sig_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*(\(.*?\))')
|
||||
|
||||
|
||||
def format_function(name, aliases, func):
|
||||
lines = inspect.getdoc(func).splitlines()
|
||||
signature = '()'
|
||||
if isinstance(func, BuiltinFunctionType):
|
||||
match = _sig_re.match(lines[0])
|
||||
if match is not None:
|
||||
del lines[:1 + bool(lines and not lines[0])]
|
||||
signature = match.group(1)
|
||||
else:
|
||||
try:
|
||||
argspec = inspect.getargspec(func)
|
||||
if getattr(func, 'environmentfilter', False) or \
|
||||
getattr(func, 'contextfilter', False) or \
|
||||
getattr(func, 'evalcontextfilter', False):
|
||||
del argspec[0][0]
|
||||
signature = inspect.formatargspec(*argspec)
|
||||
except:
|
||||
pass
|
||||
result = ['.. function:: %s%s' % (name, signature), '']
|
||||
result.extend(' ' + line for line in lines)
|
||||
if aliases:
|
||||
result.extend(('', ' :aliases: %s' % ', '.join(
|
||||
'``%s``' % x for x in sorted(aliases))))
|
||||
return result
|
||||
|
||||
|
||||
def dump_functions(mapping):
|
||||
def directive(
|
||||
dirname, arguments, options, content, lineno, content_offset,
|
||||
block_text, state, state_machine
|
||||
):
|
||||
reverse_mapping = {}
|
||||
|
||||
for name, func in mapping.items():
|
||||
reverse_mapping.setdefault(func, []).append(name)
|
||||
|
||||
filters = []
|
||||
compare_ops = set(('lt', 'le', 'eq', 'ne', 'ge', 'gt'))
|
||||
|
||||
for func, names in reverse_mapping.items():
|
||||
aliases = sorted(names, key=len)
|
||||
aliases = sorted(aliases, key=lambda x: x in compare_ops)
|
||||
name = aliases.pop()
|
||||
filters.append((name, aliases, func))
|
||||
|
||||
filters.sort()
|
||||
result = ViewList()
|
||||
|
||||
for name, aliases, func in filters:
|
||||
for item in format_function(name, aliases, func):
|
||||
result.append(item, '<jinjaext>')
|
||||
|
||||
node = nodes.paragraph()
|
||||
state.nested_parse(result, content_offset, node)
|
||||
return node.children
|
||||
|
||||
return directive
|
||||
|
||||
|
||||
from jinja2.defaults import DEFAULT_FILTERS, DEFAULT_TESTS
|
||||
jinja_filters = dump_functions(DEFAULT_FILTERS)
|
||||
jinja_tests = dump_functions(DEFAULT_TESTS)
|
||||
|
||||
|
||||
def jinja_nodes(dirname, arguments, options, content, lineno,
|
||||
content_offset, block_text, state, state_machine):
|
||||
from jinja2.nodes import Node
|
||||
doc = ViewList()
|
||||
def walk(node, indent):
|
||||
p = ' ' * indent
|
||||
sig = ', '.join(node.fields)
|
||||
doc.append(p + '.. autoclass:: %s(%s)' % (node.__name__, sig), '')
|
||||
if node.abstract:
|
||||
members = []
|
||||
for key, name in node.__dict__.items():
|
||||
if not key.startswith('_') and \
|
||||
not hasattr(node.__base__, key) and isinstance(name, abc.Callable):
|
||||
members.append(key)
|
||||
if members:
|
||||
members.sort()
|
||||
doc.append('%s :members: %s' % (p, ', '.join(members)), '')
|
||||
if node.__base__ != object:
|
||||
doc.append('', '')
|
||||
doc.append('%s :Node type: :class:`%s`' %
|
||||
(p, node.__base__.__name__), '')
|
||||
doc.append('', '')
|
||||
children = node.__subclasses__()
|
||||
children.sort(key=lambda x: x.__name__.lower())
|
||||
for child in children:
|
||||
walk(child, indent)
|
||||
walk(Node, 0)
|
||||
return parse_rst(state, content_offset, doc)
|
||||
|
||||
|
||||
def inject_toc(app, doctree, docname):
|
||||
titleiter = iter(doctree.traverse(nodes.title))
|
||||
try:
|
||||
# skip first title, we are not interested in that one
|
||||
next(titleiter)
|
||||
title = next(titleiter)
|
||||
# and check if there is at least another title
|
||||
next(titleiter)
|
||||
except StopIteration:
|
||||
return
|
||||
tocnode = nodes.section('')
|
||||
tocnode['classes'].append('toc')
|
||||
toctitle = nodes.section('')
|
||||
toctitle['classes'].append('toctitle')
|
||||
toctitle.append(nodes.title(text='Table Of Contents'))
|
||||
tocnode.append(toctitle)
|
||||
tocnode += doctree.document.settings.env.get_toc_for(docname)[0][1]
|
||||
title.parent.insert(title.parent.children.index(title), tocnode)
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('jinjafilters', jinja_filters, 0, (0, 0, 0))
|
||||
app.add_directive('jinjatests', jinja_tests, 0, (0, 0, 0))
|
||||
app.add_directive('jinjanodes', jinja_nodes, 0, (0, 0, 0))
|
||||
# uncomment for inline toc. links are broken unfortunately
|
||||
##app.connect('doctree-resolved', inject_toc)
|
@ -1,119 +0,0 @@
|
||||
\definecolor{TitleColor}{rgb}{0,0,0}
|
||||
\definecolor{InnerLinkColor}{rgb}{0,0,0}
|
||||
\definecolor{OuterLinkColor}{rgb}{0.8,0,0}
|
||||
|
||||
\renewcommand{\maketitle}{%
|
||||
\begin{titlepage}%
|
||||
\let\footnotesize\small
|
||||
\let\footnoterule\relax
|
||||
\ifsphinxpdfoutput
|
||||
\begingroup
|
||||
% This \def is required to deal with multi-line authors; it
|
||||
% changes \\ to ', ' (comma-space), making it pass muster for
|
||||
% generating document info in the PDF file.
|
||||
\def\\{, }
|
||||
\pdfinfo{
|
||||
/Author (\@author)
|
||||
/Title (\@title)
|
||||
}
|
||||
\endgroup
|
||||
\fi
|
||||
\begin{flushright}%
|
||||
%\sphinxlogo%
|
||||
{\center
|
||||
\vspace*{3cm}
|
||||
\includegraphics{logo.pdf}
|
||||
\vspace{3cm}
|
||||
\par
|
||||
{\rm\Huge \@title \par}%
|
||||
{\em\LARGE \py@release\releaseinfo \par}
|
||||
{\large
|
||||
\@date \par
|
||||
\py@authoraddress \par
|
||||
}}%
|
||||
\end{flushright}%\par
|
||||
\@thanks
|
||||
\end{titlepage}%
|
||||
\cleardoublepage%
|
||||
\setcounter{footnote}{0}%
|
||||
\let\thanks\relax\let\maketitle\relax
|
||||
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
|
||||
}
|
||||
|
||||
\fancypagestyle{normal}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[LE,RO]{{\thepage}}
|
||||
\fancyfoot[LO]{{\nouppercase{\rightmark}}}
|
||||
\fancyfoot[RE]{{\nouppercase{\leftmark}}}
|
||||
\fancyhead[LE,RO]{{ \@title, \py@release}}
|
||||
\renewcommand{\headrulewidth}{0.4pt}
|
||||
\renewcommand{\footrulewidth}{0.4pt}
|
||||
}
|
||||
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[LE,RO]{{\thepage}}
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\renewcommand{\footrulewidth}{0.4pt}
|
||||
}
|
||||
|
||||
\titleformat{\section}{\Large}%
|
||||
{\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor}
|
||||
\titleformat{\subsection}{\large}%
|
||||
{\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
|
||||
\titleformat{\subsubsection}{}%
|
||||
{\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
|
||||
\titleformat{\paragraph}{\large}%
|
||||
{\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor}
|
||||
|
||||
\ChNameVar{\raggedleft\normalsize}
|
||||
\ChNumVar{\raggedleft \bfseries\Large}
|
||||
\ChTitleVar{\raggedleft \rm\Huge}
|
||||
|
||||
\renewcommand\thepart{\@Roman\c@part}
|
||||
\renewcommand\part{%
|
||||
\pagestyle{plain}
|
||||
\if@noskipsec \leavevmode \fi
|
||||
\cleardoublepage
|
||||
\vspace*{6cm}%
|
||||
\@afterindentfalse
|
||||
\secdef\@part\@spart}
|
||||
|
||||
\def\@part[#1]#2{%
|
||||
\ifnum \c@secnumdepth >\m@ne
|
||||
\refstepcounter{part}%
|
||||
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
|
||||
\else
|
||||
\addcontentsline{toc}{part}{#1}%
|
||||
\fi
|
||||
{\parindent \z@ %\center
|
||||
\interlinepenalty \@M
|
||||
\normalfont
|
||||
\ifnum \c@secnumdepth >\m@ne
|
||||
\rm\Large \partname~\thepart
|
||||
\par\nobreak
|
||||
\fi
|
||||
\MakeUppercase{\rm\Huge #2}%
|
||||
\markboth{}{}\par}%
|
||||
\nobreak
|
||||
\vskip 8ex
|
||||
\@afterheading}
|
||||
\def\@spart#1{%
|
||||
{\parindent \z@ %\center
|
||||
\interlinepenalty \@M
|
||||
\normalfont
|
||||
\huge \bfseries #1\par}%
|
||||
\nobreak
|
||||
\vskip 3ex
|
||||
\@afterheading}
|
||||
|
||||
% use inconsolata font
|
||||
\usepackage{inconsolata}
|
||||
|
||||
% fix single quotes, for inconsolata. (does not work)
|
||||
%%\usepackage{textcomp}
|
||||
%%\begingroup
|
||||
%% \catcode`'=\active
|
||||
%% \g@addto@macro\@noligs{\let'\textsinglequote}
|
||||
%% \endgroup
|
||||
%%\endinput
|
@ -1,6 +0,0 @@
|
||||
:orphan:
|
||||
|
||||
Jinja2 Documentation
|
||||
====================
|
||||
|
||||
.. include:: contents.rst.inc
|
BIN
docs/logo.pdf
BIN
docs/logo.pdf
Binary file not shown.
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
4
docs/requirements.txt
Normal file
4
docs/requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Sphinx~=2.1.2
|
||||
Pallets-Sphinx-Themes~=1.2.0
|
||||
sphinxcontrib-log-cabinet~=1.0.1
|
||||
sphinx-issues~=1.2.0
|
@ -1355,9 +1355,11 @@ The general syntax is ``<do something> if <something is true> else <do
|
||||
something else>``.
|
||||
|
||||
The `else` part is optional. If not provided, the else block implicitly
|
||||
evaluates into an undefined object::
|
||||
evaluates into an undefined object:
|
||||
|
||||
{{ ('[%s]' % page.title) if page.title }}
|
||||
.. sourcecode:: jinja
|
||||
|
||||
{{ "[{}]".format(page.title) if page.title }}
|
||||
|
||||
|
||||
.. _python-methods:
|
||||
@ -1387,24 +1389,7 @@ you can do the following:
|
||||
List of Builtin Filters
|
||||
-----------------------
|
||||
|
||||
=================== =================== ================== ====================== ====================
|
||||
Built-in Filters Index
|
||||
==========================================================================================================
|
||||
:func:`abs` :func:`attr` :func:`batch` :func:`capitalize` :func:`center`
|
||||
:func:`default` :func:`dictsort` :func:`escape` :func:`filesizeformat` :func:`first`
|
||||
:func:`float` :func:`forceescape` :func:`format` :func:`groupby` :func:`indent`
|
||||
:func:`int` :func:`join` :func:`last` :func:`length` :func:`list`
|
||||
:func:`lower` :func:`map` :func:`max` :func:`min` :func:`pprint`
|
||||
:func:`random` :func:`reject` :func:`rejectattr` :func:`replace` :func:`reverse`
|
||||
:func:`round` :func:`safe` :func:`select` :func:`selectattr` :func:`slice`
|
||||
:func:`sort` :func:`string` :func:`striptags` :func:`sum` :func:`title`
|
||||
:func:`tojson` :func:`trim` :func:`truncate` :func:`unique` :func:`upper`
|
||||
:func:`urlencode` :func:`urlize` :func:`wordcount` :func:`wordwrap` :func:`xmlattr`
|
||||
=================== =================== ================== ====================== ====================
|
||||
|
||||
|
||||
|
||||
.. jinjafilters::
|
||||
.. jinja:filters:: jinja2.defaults.DEFAULT_FILTERS
|
||||
|
||||
|
||||
.. _builtin-tests:
|
||||
@ -1412,17 +1397,8 @@ Built-in Filters Index
|
||||
List of Builtin Tests
|
||||
---------------------
|
||||
|
||||
=================== ================== =================== ================ ================
|
||||
Built-in Test Index
|
||||
================================================================================================
|
||||
:func:`callable` :func:`defined` :func:`divisibleby` :func:`eq` :func:`escaped`
|
||||
:func:`even` :func:`ge` :func:`gt` :func:`in` :func:`iterable`
|
||||
:func:`le` :func:`lower` :func:`lt` :func:`mapping` :func:`ne`
|
||||
:func:`none` :func:`number` :func:`odd` :func:`sameas` :func:`sequence`
|
||||
:func:`string` :func:`undefined` .. .. ..
|
||||
=================== ================== =================== ================ ================
|
||||
.. jinja:tests:: jinja2.defaults.DEFAULT_TESTS
|
||||
|
||||
.. jinjatests::
|
||||
|
||||
.. _builtin-globals:
|
||||
|
||||
|
@ -296,9 +296,8 @@ class MemcachedBytecodeCache(BytecodeCache):
|
||||
|
||||
Libraries compatible with this class:
|
||||
|
||||
- `werkzeug <http://werkzeug.pocoo.org/>`_.contrib.cache
|
||||
- `python-memcached <https://www.tummy.com/Community/software/python-memcached/>`_
|
||||
- `cmemcache <http://gijsbert.org/cmemcache/>`_
|
||||
- `cachelib <https://github.com/pallets/cachelib>`_
|
||||
- `python-memcached <https://pypi.org/project/python-memcached/>`_
|
||||
|
||||
(Unfortunately the django cache interface is not compatible because it
|
||||
does not support storing binary data, only unicode. You can however pass
|
||||
|
@ -16,7 +16,7 @@ import types
|
||||
import operator
|
||||
from jinja2.environment import Environment
|
||||
from jinja2.exceptions import SecurityError
|
||||
from jinja2._compat import string_types, PY2, abc
|
||||
from jinja2._compat import string_types, PY2, abc, range_type
|
||||
from jinja2.utils import Markup
|
||||
|
||||
from markupsafe import EscapeFormatter
|
||||
@ -146,10 +146,14 @@ def safe_range(*args):
|
||||
"""A range that can't generate ranges with a length of more than
|
||||
MAX_RANGE items.
|
||||
"""
|
||||
rng = range(*args)
|
||||
rng = range_type(*args)
|
||||
|
||||
if len(rng) > MAX_RANGE:
|
||||
raise OverflowError('range too big, maximum size for range is %d' %
|
||||
MAX_RANGE)
|
||||
raise OverflowError(
|
||||
"Range too big. The sandbox blocks ranges larger than"
|
||||
" MAX_RANGE (%d)." % MAX_RANGE
|
||||
)
|
||||
|
||||
return rng
|
||||
|
||||
|
||||
|
@ -104,6 +104,15 @@ class TestExtendedAPI(object):
|
||||
t = env.from_string('{{ foo }}')
|
||||
assert t.render(foo='<foo>') == '<foo>'
|
||||
|
||||
def test_sandbox_max_range(self, env):
|
||||
from jinja2.sandbox import SandboxedEnvironment, MAX_RANGE
|
||||
|
||||
env = SandboxedEnvironment()
|
||||
t = env.from_string("{% for item in range(total) %}{{ item }}{% endfor %}")
|
||||
|
||||
with pytest.raises(OverflowError):
|
||||
t.render(total=MAX_RANGE + 1)
|
||||
|
||||
|
||||
@pytest.mark.api
|
||||
@pytest.mark.meta
|
||||
|
Loading…
Reference in New Issue
Block a user