Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
text = utils.unescape(text)
if typ == 'menuselection':
text = text.replace('-->', u'\u2192') # Here is the patch
spans = _amp_re.split(text)
node = nodes.literal(rawtext=rawtext)
for i, span in enumerate(spans):
span = span.replace('&&', '&')
if i == 0:
if len(span) > 0:
textnode = nodes.Text(span)
node += textnode
continue
accel_node = nodes.inline()
letter_node = nodes.Text(span[0])
accel_node += letter_node
accel_node['classes'].append('accelerator')
node += accel_node
textnode = nodes.Text(span[1:])
node += textnode
node['classes'].append(typ)
return [node], []
option_spec = {}
has_content = True
def run(self):
self.assert_has_content()
args = shlex.split(self.content[0].encode('ascii'))
text = subprocess.Popen(args,stdout=subprocess.PIPE).communicate()[0]
return [docutils.nodes.literal_block(text=text)]
rst.directives.register_directive('shell-block', ShellCommandDirective)
# doxygen links using breathe
parser_factory = breathe.DoxygenParserFactory()
matcher_factory = breathe.ItemMatcherFactory()
item_finder_factory_creator = breathe.DoxygenItemFinderFactoryCreator(parser_factory, matcher_factory)
index_parser = breathe.DoxygenIndexParser()
finder_factory = breathe.FinderFactory(index_parser, item_finder_factory_creator)
node_factory = breathe.NodeFactory(docutils.nodes,sphinx.addnodes)
renderer_factory_creator = breathe.DoxygenToRstRendererFactoryCreator(node_factory, parser_factory)
builder_factory = breathe.BuilderFactory(breathe.RstBuilder, renderer_factory_creator)
project_info_factory = breathe.ProjectInfoFactory()
directive_factory = breathe.DoxygenDirectiveFactory(builder_factory, finder_factory, matcher_factory, project_info_factory)
project_info_factory.update({'openrave':os.path.join(languagecode, 'xml')},'openrave')
rst.directives.register_directive("doxygenindex", directive_factory.create_index_directive_container())
rst.directives.register_directive("doxygenfunction", directive_factory.create_function_directive_container())
rst.directives.register_directive("doxygenstruct", directive_factory.create_struct_directive_container())
rst.directives.register_directive("doxygenenum",directive_factory.create_enum_directive_container())
rst.directives.register_directive("doxygentypedef",directive_factory.create_typedef_directive_container())
rst.directives.register_directive("doxygenclass",directive_factory.create_class_directive_container())
rst.languages.get_language('ja')
for source in glob('*.txt'):
dest = os.path.splitext(source)[0] + '.html'
""" Try and create a reference to a type on MSDN """
in_msdn = False
if name in MSDN_VALUE_TYPES:
name = MSDN_VALUE_TYPES[name]
in_msdn = True
if name.startswith('System.'):
in_msdn = True
if in_msdn:
link = name.split('<')[0]
link = MSDN_LINK_MAP.get(link, link.lower())
url = ''
if link.startswith('https://'):
url = link
else:
url = 'https://docs.microsoft.com/en-us/dotnet/api/' + link
node = nodes.reference(name, shorten_type(name))
node['refuri'] = url
node['reftitle'] = name
return node
return None
self.output = visitor.astext()
for attr in ('head_prefix', 'stylesheet', 'head', 'body_prefix',
'body_pre_docinfo', 'docinfo', 'body', 'fragment',
'body_suffix'):
setattr(self, attr, getattr(visitor, attr))
def assemble_parts(self):
writers.Writer.assemble_parts(self)
for part in ('title', 'subtitle', 'docinfo', 'body', 'header',
'footer', 'meta', 'stylesheet', 'fragment',
'html_prolog', 'html_head', 'html_title', 'html_subtitle',
'html_body'):
self.parts[part] = ''.join(getattr(self.visitor, part))
class HTMLTranslator(nodes.NodeVisitor):
"""
This HTML writer has been optimized to produce visually compact
lists (less vertical whitespace). HTML's mixed content models
allow list items to contain "<li><p>body elements</p></li>" or
"<li>just text</li>" or even "<li>text<p>and body
elements</p>combined</li>", each with different effects. It would
be best to stick with strict body elements in list items, but they
affect vertical spacing in browsers (although they really
shouldn't).
Here is an outline of the optimization:
- Check for and omit <p> tags in "simple" lists: list items
contain either a single paragraph, a nested simple list, or a
paragraph followed by a nested simple list. This means that</p>
Decode file/path string in a failsave manner if not already done.
"""
# see also http://article.gmane.org/gmane.text.docutils.user/2905
if isinstance(path, unicode):
return path
try:
path = path.decode(sys.getfilesystemencoding(), 'strict')
except AttributeError: # default value None has no decode method
return nodes.reprunicode(path)
except UnicodeDecodeError:
try:
path = path.decode('utf-8', 'strict')
except UnicodeDecodeError:
path = path.decode('ascii', 'replace')
return nodes.reprunicode(path)
valpara = nodes.paragraph()
valpara += nodes.emphasis('', 'Legal Values: ')
for thevalue, thename in v.val.values.iteritems():
valpara += nodes.literal('', "%s (%d) " % (str(thename), thevalue))
para += valpara
except TypeError, e:
pass # didn't convert to python, but okay. maybe v.val was boost::posix_time::ptime or something.
entry += nodes.paragraph('', v.doc)
return section
d['name'] = CellType.__name__
d['short_doc'] = getattr(CellType, 'short_doc','')
cell = nodes.section()
cell += nodes.title(text=CellType.__name__)
cell += content
top = nodes.topic()
cell += top
cell['ids'].append(CellType.__name__)
cell['names'].append(CellType.__name__)
para = nodes.title(text="Brief doc")
para += nodes.paragraph(text=d['short_doc'])
top += para
inst = CellType.inspect()
top += gettendril('Parameters', inst.params, True)
top += gettendril('Inputs', inst.inputs, False)
top += gettendril('Outputs', inst.outputs, False)
lines = lines[:iend]
# Remove the check suppression.
for j, line in enumerate(lines):
if "prob.setup(check=False" in line:
lines[j] = lines[j].replace('check=False, ', '')
lines[j] = lines[j].replace('check=False', '')
# prune whitespace down to match first line
while lines[0].startswith(' '):
lines = [line[4:] for line in lines]
text = '\n'.join(lines)
# RIGHT side = Current OpenMDAO
right_body = nodes.literal_block(text, text)
right_body['language'] = 'python'
right_body['classes'].append('rosetta_right')
doc_nodes.append(left_body)
doc_nodes.append(right_body)
return doc_nodes
fname = os.path.join(SOURCE_PATH, f"{page}.rst")
option_parser = docutils.frontend.OptionParser(
components=(docutils.parsers.rst.Parser,)
)
doc = docutils.utils.new_document("", option_parser.get_default_values())
with open(fname) as f:
data = f.read()
parser = docutils.parsers.rst.Parser()
# do not generate any warning when parsing the rst
with open(os.devnull, "a") as f:
doc.reporter.stream = f
parser.parse(data, doc)
section = next(
node for node in doc.children if isinstance(node, docutils.nodes.section)
)
title = next(
node for node in section.children if isinstance(node, docutils.nodes.title)
)
return title.astext()
elif data is None and show_empty:
data = ''
if isinstance(data, str):
if len(data) == 0 and not show_empty:
return []
data_node = nodes.inline(classes=['needs_data'])
data_node.append(nodes.Text(data, data))
data_container.append(data_node)
elif isinstance(data, list):
if len(data) == 0 and not show_empty:
return []
list_container = nodes.inline(classes=['needs_data_container'])
for index, element in enumerate(data):
if index > 0:
spacer = nodes.inline(classes=['needs_spacer'])
spacer += nodes.Text(', ', ', ')
list_container += spacer
inline = nodes.inline(classes=['needs_data'])
inline += nodes.Text(element, element)
list_container += inline
data_container += list_container
else:
data_container.append(nodes.Text(data, data))
return data_container