FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/lib/matplotlib/sphinxext/only_directives.py at master · flothesof/matplotlib · GitHub
flothesof
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
sphinxext
/
only_directives.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (54 loc) · 2.2 KB
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
sphinxext
/
only_directives.py
Copy path
File metadata and controls
68 lines (54 loc) · 2.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# A pair of directives for inserting content that will only appear in
# either html or latex.
#
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
from
matplotlib
.
externals
import
six
from
docutils
.
nodes
import
Body
,
Element
from
docutils
.
parsers
.
rst
import
directives
class
only_base
(
Body
,
Element
):
def
dont_traverse
(
self
,
*
args
,
**
kwargs
):
return
[]
class
html_only
(
only_base
):
pass
class
latex_only
(
only_base
):
pass
def
run
(
content
,
node_class
,
state
,
content_offset
):
text
=
'
\n
'
.
join
(
content
)
node
=
node_class
(
text
)
state
.
nested_parse
(
content
,
content_offset
,
node
)
return
[
node
]
def
html_only_directive
(
name
,
arguments
,
options
,
content
,
lineno
,
content_offset
,
block_text
,
state
,
state_machine
):
return
run
(
content
,
html_only
,
state
,
content_offset
)
def
latex_only_directive
(
name
,
arguments
,
options
,
content
,
lineno
,
content_offset
,
block_text
,
state
,
state_machine
):
return
run
(
content
,
latex_only
,
state
,
content_offset
)
def
builder_inited
(
app
):
if
app
.
builder
.
name
==
'html'
:
latex_only
.
traverse
=
only_base
.
dont_traverse
else
:
html_only
.
traverse
=
only_base
.
dont_traverse
def
setup
(
app
):
app
.
add_directive
(
'htmlonly'
,
html_only_directive
,
True
, (
0
,
0
,
0
))
app
.
add_directive
(
'latexonly'
,
latex_only_directive
,
True
, (
0
,
0
,
0
))
app
.
add_node
(
html_only
)
app
.
add_node
(
latex_only
)
# This will *really* never see the light of day As it turns out,
# this results in "broken" image nodes since they never get
# processed, so best not to do this.
# app.connect('builder-inited', builder_inited)
# Add visit/depart methods to HTML-Translator:
def
visit_perform
(
self
,
node
):
pass
def
depart_perform
(
self
,
node
):
pass
def
visit_ignore
(
self
,
node
):
node
.
children
=
[]
def
depart_ignore
(
self
,
node
):
node
.
children
=
[]
app
.
add_node
(
html_only
,
html
=
(
visit_perform
,
depart_perform
))
app
.
add_node
(
html_only
,
latex
=
(
visit_ignore
,
depart_ignore
))
app
.
add_node
(
latex_only
,
latex
=
(
visit_perform
,
depart_perform
))
app
.
add_node
(
latex_only
,
html
=
(
visit_ignore
,
depart_ignore
))
Back
|
FazBrowse Home
|
New Git URL