author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Mon, 12 Apr 2010 15:05:37 +0000 | |
branch | stable |
changeset 5214 | 3285b6e3b930 |
parent 4771 | e27d23f875c6 |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
0 | 1 |
"""rest publishing functions |
2 |
||
996 | 3 |
contains some functions and setup of docutils for cubicweb. Provides the |
4 |
following ReST directives: |
|
5 |
||
6 |
* `eid`, create link to entity in the repository by their eid |
|
7 |
||
8 |
* `card`, create link to card entity in the repository by their wikiid |
|
9 |
(proposing to create it when the refered card doesn't exist yet) |
|
10 |
||
11 |
* `winclude`, reference to a web documentation file (in wdoc/ directories) |
|
12 |
||
13 |
* `sourcecode` (if pygments is installed), source code colorization |
|
0 | 14 |
|
15 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4118
diff
changeset
|
16 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 17 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1643
diff
changeset
|
18 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 19 |
""" |
20 |
__docformat__ = "restructuredtext en" |
|
21 |
||
22 |
from cStringIO import StringIO |
|
23 |
from itertools import chain |
|
24 |
from logging import getLogger |
|
25 |
from os.path import join |
|
26 |
||
27 |
from docutils import statemachine, nodes, utils, io |
|
4771
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
28 |
from docutils.core import Publisher |
0 | 29 |
from docutils.parsers.rst import Parser, states, directives |
30 |
from docutils.parsers.rst.roles import register_canonical_role, set_classes |
|
31 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2311
diff
changeset
|
32 |
from logilab.mtconverter import ESC_UCAR_TABLE, ESC_CAR_TABLE, xml_escape |
0 | 33 |
|
2467
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
34 |
from cubicweb import UnknownEid |
704
0c2c8f0a6ded
new ext package for modules depending on an option third party package
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
35 |
from cubicweb.ext.html4zope import Writer |
0 | 36 |
|
37 |
# We provide our own parser as an attempt to get rid of |
|
38 |
# state machine reinstanciation |
|
39 |
||
40 |
import re |
|
41 |
# compile states.Body patterns |
|
42 |
for k, v in states.Body.patterns.items(): |
|
43 |
if isinstance(v, str): |
|
44 |
states.Body.patterns[k] = re.compile(v) |
|
45 |
||
46 |
# register ReStructured Text mimetype / extensions |
|
47 |
import mimetypes |
|
48 |
mimetypes.add_type('text/rest', '.rest') |
|
49 |
mimetypes.add_type('text/rest', '.rst') |
|
50 |
||
51 |
||
52 |
LOGGER = getLogger('cubicweb.rest') |
|
53 |
||
54 |
def eid_reference_role(role, rawtext, text, lineno, inliner, |
|
55 |
options={}, content=[]): |
|
56 |
try: |
|
57 |
try: |
|
58 |
eid_num, rest = text.split(u':', 1) |
|
59 |
except: |
|
60 |
eid_num, rest = text, '#'+text |
|
61 |
eid_num = int(eid_num) |
|
62 |
if eid_num < 0: |
|
63 |
raise ValueError |
|
64 |
except ValueError: |
|
65 |
msg = inliner.reporter.error( |
|
66 |
'EID number must be a positive number; "%s" is invalid.' |
|
67 |
% text, line=lineno) |
|
68 |
prb = inliner.problematic(rawtext, rawtext, msg) |
|
69 |
return [prb], [msg] |
|
70 |
# Base URL mainly used by inliner.pep_reference; so this is correct: |
|
71 |
context = inliner.document.settings.context |
|
2467
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
72 |
try: |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2680
diff
changeset
|
73 |
refedentity = context._cw.entity_from_eid(eid_num) |
2467
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
74 |
except UnknownEid: |
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
75 |
ref = '#' |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2680
diff
changeset
|
76 |
rest += u' ' + context._cw._('(UNEXISTANT EID)') |
2467
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
77 |
else: |
6983631f5d0d
don't fail on unknown eid, simply issue a warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
78 |
ref = refedentity.absolute_url() |
0 | 79 |
set_classes(options) |
80 |
return [nodes.reference(rawtext, utils.unescape(rest), refuri=ref, |
|
81 |
**options)], [] |
|
82 |
||
83 |
||
84 |
def winclude_directive(name, arguments, options, content, lineno, |
|
85 |
content_offset, block_text, state, state_machine): |
|
86 |
"""Include a reST file as part of the content of this reST file. |
|
87 |
||
88 |
same as standard include directive but using config.locate_doc_resource to |
|
89 |
get actual file to include. |
|
90 |
||
91 |
Most part of this implementation is copied from `include` directive defined |
|
92 |
in `docutils.parsers.rst.directives.misc` |
|
93 |
""" |
|
94 |
context = state.document.settings.context |
|
4769
5b878b02b67b
[rest] cleanup, avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
95 |
cw = context._cw |
0 | 96 |
source = state_machine.input_lines.source( |
97 |
lineno - state_machine.input_offset - 1) |
|
98 |
#source_dir = os.path.dirname(os.path.abspath(source)) |
|
99 |
fid = arguments[0] |
|
4769
5b878b02b67b
[rest] cleanup, avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
100 |
for lang in chain((cw.lang, cw.vreg.property_value('ui.language')), |
5b878b02b67b
[rest] cleanup, avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
101 |
cw.vreg.config.available_languages()): |
0 | 102 |
rid = '%s_%s.rst' % (fid, lang) |
4769
5b878b02b67b
[rest] cleanup, avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
103 |
resourcedir = cw.vreg.config.locate_doc_file(rid) |
0 | 104 |
if resourcedir: |
105 |
break |
|
106 |
else: |
|
107 |
severe = state_machine.reporter.severe( |
|
108 |
'Problems with "%s" directive path:\nno resource matching %s.' |
|
109 |
% (name, fid), |
|
110 |
nodes.literal_block(block_text, block_text), line=lineno) |
|
111 |
return [severe] |
|
112 |
path = join(resourcedir, rid) |
|
113 |
encoding = options.get('encoding', state.document.settings.input_encoding) |
|
114 |
try: |
|
115 |
state.document.settings.record_dependencies.add(path) |
|
116 |
include_file = io.FileInput( |
|
117 |
source_path=path, encoding=encoding, |
|
118 |
error_handler=state.document.settings.input_encoding_error_handler, |
|
119 |
handle_io_errors=None) |
|
120 |
except IOError, error: |
|
121 |
severe = state_machine.reporter.severe( |
|
122 |
'Problems with "%s" directive path:\n%s: %s.' |
|
123 |
% (name, error.__class__.__name__, error), |
|
124 |
nodes.literal_block(block_text, block_text), line=lineno) |
|
125 |
return [severe] |
|
126 |
try: |
|
127 |
include_text = include_file.read() |
|
128 |
except UnicodeError, error: |
|
129 |
severe = state_machine.reporter.severe( |
|
130 |
'Problem with "%s" directive:\n%s: %s' |
|
131 |
% (name, error.__class__.__name__, error), |
|
132 |
nodes.literal_block(block_text, block_text), line=lineno) |
|
133 |
return [severe] |
|
134 |
if options.has_key('literal'): |
|
135 |
literal_block = nodes.literal_block(include_text, include_text, |
|
136 |
source=path) |
|
137 |
literal_block.line = 1 |
|
138 |
return literal_block |
|
139 |
else: |
|
140 |
include_lines = statemachine.string2lines(include_text, |
|
141 |
convert_whitespace=1) |
|
142 |
state_machine.insert_input(include_lines, path) |
|
143 |
return [] |
|
144 |
||
145 |
winclude_directive.arguments = (1, 0, 1) |
|
146 |
winclude_directive.options = {'literal': directives.flag, |
|
147 |
'encoding': directives.encoding} |
|
148 |
||
996 | 149 |
try: |
150 |
from pygments import highlight |
|
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4483
diff
changeset
|
151 |
from pygments.lexers import get_lexer_by_name |
996 | 152 |
from pygments.formatters import HtmlFormatter |
153 |
except ImportError: |
|
4118
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
154 |
pygments_directive = None |
996 | 155 |
else: |
156 |
_PYGMENTS_FORMATTER = HtmlFormatter() |
|
157 |
||
158 |
def pygments_directive(name, arguments, options, content, lineno, |
|
159 |
content_offset, block_text, state, state_machine): |
|
160 |
try: |
|
161 |
lexer = get_lexer_by_name(arguments[0]) |
|
162 |
except ValueError: |
|
163 |
# no lexer found |
|
164 |
lexer = get_lexer_by_name('text') |
|
165 |
parsed = highlight(u'\n'.join(content), lexer, _PYGMENTS_FORMATTER) |
|
4483
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
166 |
# don't fail if no context set on the sourcecode directive |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
167 |
try: |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
168 |
context = state.document.settings.context |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
169 |
context._cw.add_css('pygments.css') |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
170 |
except AttributeError: |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
171 |
# used outside cubicweb |
918fd9931cb7
cleanup, don't fail if no context set on the sourcecode directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4334
diff
changeset
|
172 |
pass |
996 | 173 |
return [nodes.raw('', parsed, format='html')] |
1447
a1ca676294f0
don't use a singleton rest parser which may leads to concurrency bugs
sylvain.thenault@logilab.fr
parents:
1323
diff
changeset
|
174 |
|
996 | 175 |
pygments_directive.arguments = (1, 0, 1) |
176 |
pygments_directive.content = 1 |
|
177 |
||
178 |
||
0 | 179 |
class CubicWebReSTParser(Parser): |
180 |
"""The (customized) reStructuredText parser.""" |
|
181 |
||
182 |
def __init__(self): |
|
183 |
self.initial_state = 'Body' |
|
184 |
self.state_classes = states.state_classes |
|
185 |
self.inliner = states.Inliner() |
|
186 |
self.statemachine = states.RSTStateMachine( |
|
187 |
state_classes=self.state_classes, |
|
188 |
initial_state=self.initial_state, |
|
189 |
debug=0) |
|
190 |
||
191 |
def parse(self, inputstring, document): |
|
192 |
"""Parse `inputstring` and populate `document`, a document tree.""" |
|
193 |
self.setup_parse(inputstring, document) |
|
194 |
inputlines = statemachine.string2lines(inputstring, |
|
195 |
convert_whitespace=1) |
|
196 |
self.statemachine.run(inputlines, document, inliner=self.inliner) |
|
197 |
self.finish_parse() |
|
198 |
||
199 |
||
4771
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
200 |
# XXX docutils keep a ref on context, can't find a correct way to remove it |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
201 |
class CWReSTPublisher(Publisher): |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
202 |
def __init__(self, context, settings, **kwargs): |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
203 |
Publisher.__init__(self, **kwargs) |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
204 |
self.set_components('standalone', 'restructuredtext', 'pseudoxml') |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
205 |
self.process_programmatic_settings(None, settings, None) |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
206 |
self.settings.context = context |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
207 |
|
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
208 |
|
0 | 209 |
def rest_publish(context, data): |
210 |
"""publish a string formatted as ReStructured Text to HTML |
|
1447
a1ca676294f0
don't use a singleton rest parser which may leads to concurrency bugs
sylvain.thenault@logilab.fr
parents:
1323
diff
changeset
|
211 |
|
0 | 212 |
:type context: a cubicweb application object |
213 |
||
214 |
:type data: str |
|
215 |
:param data: some ReST text |
|
216 |
||
217 |
:rtype: unicode |
|
218 |
:return: |
|
219 |
the data formatted as HTML or the original data if an error occured |
|
220 |
""" |
|
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2680
diff
changeset
|
221 |
req = context._cw |
0 | 222 |
if isinstance(data, unicode): |
223 |
encoding = 'unicode' |
|
2311
f178182b1305
actually close #344401 by removing unprintable characters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
224 |
# remove unprintable characters unauthorized in xml |
f178182b1305
actually close #344401 by removing unprintable characters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
225 |
data = data.translate(ESC_UCAR_TABLE) |
0 | 226 |
else: |
227 |
encoding = req.encoding |
|
2311
f178182b1305
actually close #344401 by removing unprintable characters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
228 |
# remove unprintable characters unauthorized in xml |
f178182b1305
actually close #344401 by removing unprintable characters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
229 |
data = data.translate(ESC_CAR_TABLE) |
0 | 230 |
settings = {'input_encoding': encoding, 'output_encoding': 'unicode', |
4771
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
231 |
'warning_stream': StringIO(), |
0 | 232 |
# dunno what's the max, severe is 4, and we never want a crash |
233 |
# (though try/except may be a better option...) |
|
1447
a1ca676294f0
don't use a singleton rest parser which may leads to concurrency bugs
sylvain.thenault@logilab.fr
parents:
1323
diff
changeset
|
234 |
'halt_level': 10, |
0 | 235 |
} |
236 |
if context: |
|
237 |
if hasattr(req, 'url'): |
|
238 |
base_url = req.url() |
|
239 |
elif hasattr(context, 'absolute_url'): |
|
240 |
base_url = context.absolute_url() |
|
241 |
else: |
|
242 |
base_url = req.base_url() |
|
243 |
else: |
|
244 |
base_url = None |
|
245 |
try: |
|
4771
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
246 |
pub = CWReSTPublisher(context, settings, |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
247 |
parser=CubicWebReSTParser(), |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
248 |
writer=Writer(base_url=base_url), |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
249 |
source_class=io.StringInput, |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
250 |
destination_class=io.StringOutput) |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
251 |
pub.set_source(data) |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
252 |
pub.set_destination() |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
253 |
res = pub.publish(enable_exit_status=None) |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
254 |
# necessary for proper garbage collection, else a ref is kept somewhere in docutils... |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
255 |
del pub.settings.context |
e27d23f875c6
custom rest publisher instead of using rest_publish. Avoid to keep a ref on the latest context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4769
diff
changeset
|
256 |
return res |
0 | 257 |
except Exception: |
258 |
LOGGER.exception('error while publishing ReST text') |
|
259 |
if not isinstance(data, unicode): |
|
260 |
data = unicode(data, encoding, 'replace') |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2311
diff
changeset
|
261 |
return xml_escape(req._('error while publishing ReST text') |
0 | 262 |
+ '\n\n' + data) |
4118
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
263 |
|
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
264 |
|
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
265 |
_INITIALIZED = False |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
266 |
def cw_rest_init(): |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
267 |
global _INITIALIZED |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
268 |
if _INITIALIZED: |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
269 |
return |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
270 |
_INITIALIZED = True |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
271 |
register_canonical_role('eid', eid_reference_role) |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
272 |
directives.register_directive('winclude', winclude_directive) |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
273 |
if pygments_directive is not None: |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2680
diff
changeset
|
274 |
directives.register_directive('sourcecode', pygments_directive) |