def rst_nodes(self): """Render into RST nodes a thing shaped like a function, having a name and arguments. Fill in args, docstrings, and info fields from stored JSDoc output. """ try: obj = self._app._sphinxjs_analyzer.get_object( self._partial_path, self._renderer_type) except SuffixNotFound as exc: raise SphinxError( 'No documentation was found for object "%s" or any path ending with that.' % ''.join(exc.segments)) except SuffixAmbiguous as exc: raise SphinxError( 'More than one object matches the path suffix "%s". Candidate paths have these segments in front: %s' % (''.join(exc.segments), exc.next_possible_keys)) else: rst = self.rst(self._partial_path, obj, use_short_name='short-name' in self._options) # Parse the RST into docutils nodes with a fresh doc, and return # them. # # Not sure if passing the settings from the "real" doc is the right # thing to do here: doc = new_document( '%s:%s(%s)' % (obj.filename, obj.path, obj.line), settings=self._directive.state.document.settings) RstParser().parse(rst, doc) return doc.children return []
def _run(self, app): """Render a thing shaped like a function, having a name and arguments. Fill in args, docstrings, and info fields from stored JSDoc output. """ # Get the relevant documentation together: name = self._name() dotted_name = _namepath_to_dotted(name) if 'short-name' in self.options: dotted_name = dotted_name.split('.')[-1] doclet = app._sphinxjs_jsdoc_output.get(name) if doclet is None: app.warn( 'No JSDoc documentation for the longname "%s" was found.' % name) return [] # Render to RST using Jinja: env = Environment(loader=PackageLoader('sphinx_js', 'templates')) template = env.get_template(self._template) rst = template.render(**self._template_vars(dotted_name, doclet)) # Parse the RST into docutils nodes with a fresh doc, and return # them: # # Not sure if passing the settings from the "real" doc is the right # thing to do here: doc = new_document('dummy', settings=self.state.document.settings) RstParser().parse(rst, doc) return doc.children
def rst_nodes(self): """Render into RST nodes a thing shaped like a function, having a name and arguments. Fill in args, docstrings, and info fields from stored JSDoc output. """ try: # Get the relevant documentation together: doclet, full_path = self._app._sphinxjs_doclets_by_path.get_with_path(self._partial_path) except SuffixNotFound as exc: raise SphinxError('No JSDoc documentation was found for object "%s" or any path ending with that.' % ''.join(exc.segments)) except SuffixAmbiguous as exc: raise SphinxError('More than one JS object matches the path suffix "%s". Candidate paths have these segments in front: %s' % (''.join(exc.segments), exc.next_possible_keys)) else: rst = self.rst(self._partial_path, full_path, doclet, use_short_name='short-name' in self._options) # Parse the RST into docutils nodes with a fresh doc, and return # them. # # Not sure if passing the settings from the "real" doc is the right # thing to do here: meta = doclet['meta'] doc = new_document('%s:%s(%s)' % (meta['filename'], doclet['longname'], meta['lineno']), settings=self._directive.state.document.settings) RstParser().parse(rst, doc) return doc.children return []
def run(self): # Get the relevant documentation together: name = self._name() doclet = app._sphinxjs_jsdoc_output.get(name) if doclet is None: app.warn('No JSDoc documentation for the longname "%s" was found.' % name) return [] # Render to RST using Jinja: env = Environment(loader=PackageLoader('sphinx_js', 'templates')) template = env.get_template('function.rst') rst = template.render( name=name, params=self._formal_params(doclet), fields=self._fields(doclet), description=doclet.get('description', ''), content='\n'.join(self.content)) # Parse the RST into docutils nodes with a fresh doc, and return # them: # # Not sure if passing the settings from the "real" doc is the right # thing to do here: doc = new_document('dummy', settings=self.state.document.settings) RstParser().parse(rst, doc) return doc.children
def rst_nodes(self): """Render into RST nodes a thing shaped like a function, having a name and arguments. Fill in args, docstrings, and info fields from stored LUADoc output. """ pattern = self._partial_path lua_classes = [] # lookup for class for module in self._app._sphinxlua_modules: for cls in module.classes: if re.match(pattern, cls.name): lua_classes.append(cls) rst = self.rst(dict( name=self._partial_path, model=lua_classes, )) doc = new_document('%s' % self._partial_path, settings=self._directive.state.document.settings) RstParser().parse(rst, doc) return doc.children
def rst_nodes(self): """Render into RST nodes a thing shaped like a function, having a name and arguments. Fill in args, docstrings, and info fields from stored LUADoc output. """ lua_module = None # lookup for class for module in self._app._sphinxlua_modules: if module.name == self._partial_path: lua_module = module break if not lua_module: raise SphinxError( 'No LUADoc documentation was found for object "%s" or any path ending with that.' % self._partial_path) rst = self.rst(dict(name=self._partial_path, module=lua_module)) doc = new_document('%s' % self._partial_path, settings=self._directive.state.document.settings) RstParser().parse(rst, doc) return doc.children
def parse_rst(self, rst): """We produce a bunch of rst but directives are supposed to output docutils trees. This is a helper that converts the rst to docutils. """ settings = self.state.document.settings doc = new_document("", settings) RstParser().parse(rst, doc) return doc.children
def parse_(rst): document = new_document() parser = RstParser() parser.parse(rst, document) SphinxSmartQuotes(document, startnode=None).apply() for msg in list(document.findall(nodes.system_message)): if msg['level'] == 1: msg.replace_self([]) return document
def parse_(rst): document = utils.new_document(b'test data', settings) document['file'] = 'dummy' parser = RstParser() parser.parse(rst, document) for msg in document.traverse(nodes.system_message): if msg['level'] == 1: msg.replace_self([]) return document