Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-mako
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-mako
Commits
e579e03f
Commit
e579e03f
authored
13 years ago
by
Mike Bayer
Browse files
Options
Downloads
Patches
Plain Diff
update sphinx rendering to use built in jinja rendering for .js/.css files
parent
afbfaf92
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/build/builder/builders.py
+11
-16
11 additions, 16 deletions
doc/build/builder/builders.py
with
11 additions
and
16 deletions
doc/build/builder/builders.py
+
11
−
16
View file @
e579e03f
from
sphinx.application
import
TemplateBridge
from
sphinx.builders.html
import
StandaloneHTMLBuilder
from
sphinx.highlighting
import
PygmentsBridge
from
sphinx.jinja2glue
import
BuiltinTemplateLoader
from
pygments
import
highlight
from
pygments.lexer
import
RegexLexer
,
bygroups
,
using
from
pygments.token
import
*
...
...
@@ -14,14 +15,17 @@ from mako.ext.pygmentplugin import MakoLexer
class
MakoBridge
(
TemplateBridge
):
def
init
(
self
,
builder
,
*
args
,
**
kw
):
self
.
jinja2_fallback
=
BuiltinTemplateLoader
()
self
.
jinja2_fallback
.
init
(
builder
,
*
args
,
**
kw
)
self
.
layout
=
builder
.
config
.
html_context
.
get
(
'
mako_layout
'
,
'
html
'
)
self
.
lookup
=
TemplateLookup
(
directories
=
builder
.
config
.
templates_path
,
imports
=
[
"
from builder import util
"
]
)
def
render
(
self
,
template
,
context
):
template
=
template
.
replace
(
"
.html
"
,
"
.mako
"
)
context
[
'
prevtopic
'
]
=
context
.
pop
(
'
prev
'
,
None
)
...
...
@@ -30,21 +34,12 @@ class MakoBridge(TemplateBridge):
# sphinx 1.0b2 doesn't seem to be providing _ for some reason...
context
.
setdefault
(
'
_
'
,
lambda
x
:
x
)
return
self
.
lookup
.
get_template
(
template
).
render_unicode
(
**
context
)
def
render_string
(
self
,
template
,
context
):
context
[
'
prevtopic
'
]
=
context
.
pop
(
'
prev
'
,
None
)
context
[
'
nexttopic
'
]
=
context
.
pop
(
'
next
'
,
None
)
context
[
'
mako_layout
'
]
=
self
.
layout
==
'
html
'
and
'
static_base.mako
'
or
'
site_base.mako
'
# sphinx 1.0b2 doesn't seem to be providing _ for some reason...
context
.
setdefault
(
'
_
'
,
lambda
x
:
x
)
return
Template
(
template
,
lookup
=
self
.
lookup
,
format_exceptions
=
True
,
imports
=
[
"
from builder import util
"
]
).
render_unicode
(
**
context
)
# this is used for .js, .css etc. and we don't have
# local copies of that stuff here so use the jinja render.
return
self
.
jinja2_fallback
.
render_string
(
template
,
context
)
class
StripDocTestFilter
(
Filter
):
def
filter
(
self
,
lexer
,
stream
):
for
ttype
,
value
in
stream
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment