def _warn_node(self, msg, node): """Do not warn on external images.""" if not msg.startswith('nonlocal image URI found:'): try: self._warnfunc(msg, '{0}:{1}'.format(get_source_line(node))) except Exception: pass
def _supress_nonlocal_image_and_citation_not_referenced( self, msg, node, **kwargs): if not msg.startswith("nonlocal image URI found:"): if not msg.startswith("Citation") and msg.endswith( "is not referenced."): self._warnfunc(msg, "%s:%s" % get_source_line(node))
def filter(self, record): # type: ignore # type: (SphinxWarningLogRecord) -> bool if isinstance(record, logging.LogRecord): record.__class__ = SphinxWarningLogRecord # force subclassing to handle location location = getattr(record, 'location', None) if isinstance(location, tuple): docname, lineno = location if docname and lineno: record.location = '%s:%s' % (self.app.env.doc2path(docname), lineno) elif docname: record.location = '%s' % self.app.env.doc2path(docname) else: record.location = None elif isinstance(location, nodes.Node): (source, line) = get_source_line(location) if source and line: record.location = "%s:%s" % (source, line) elif source: record.location = "%s:" % source elif line: record.location = "<unknown>:%s" % line else: record.location = None elif location and ':' not in location: record.location = '%s' % self.app.env.doc2path(location) return True
def apply(self, **kwargs) -> None: for node in self.document.traverse(addnodes.index): for i, entries in enumerate(node['entries']): if len(entries) == 4: source, line = get_source_line(node) warnings.warn('An old styled index node found: %r at (%s:%s)' % (node, source, line), RemovedInSphinx40Warning) node['entries'][i] = entries + (None,)
def apply(self): for node in self.document.traverse(addnodes.index): for entries in node['entries']: if len(entries) == 4: source, line = get_source_line(node) warnings.warn('An old styled index node found: %r at (%s:%s)' % (node, source, line), RemovedInSphinx40Warning) entries.extend([None])
def apply(self, **kwargs): # type: (Any) -> None for node in self.document.traverse(addnodes.index): for i, entries in enumerate(node['entries']): if len(entries) == 4: source, line = get_source_line(node) warnings.warn('An old styled index node found: %r at (%s:%s)' % (node, source, line), RemovedInSphinx40Warning) node['entries'][i] = entries + (None,)
def _warn_node(self, msg, node): """ Mute warnings that are like ``WARNING: nonlocal image URI found: https://img. ...`` Solution was found by googling, copied it from SO: http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format """ if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def get_node_location(node: Node) -> str: (source, line) = get_source_line(node) if source and line: return "%s:%s" % (source, line) elif source: return "%s:" % source elif line: return "<unknown>:%s" % line else: return None
def _warn_node(self, msg, node, **kwargs): skip = False print "Hello world!" if msg.startswith('nonlocal image URI found:'): skip = True if "directive 'table' is already registered" in msg: skip = True if not skip: self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs)
def get_node_location(node): # type: (nodes.Node) -> str (source, line) = get_source_line(node) if source and line: return "%s:%s" % (source, line) elif source: return "%s:" % source elif line: return "<unknown>:%s" % line else: return None
def get_node_location(node: Node) -> Optional[str]: (source, line) = get_source_line(node) if source: source = abspath(source) if source and line: return "%s:%s" % (source, line) elif source: return "%s:" % source elif line: return "<unknown>:%s" % line else: return None
def visit_image(self, node): dprint() self.flush_state() if 'uri' in node.attributes: source = node.attributes['uri'] if not source.startswith('http:'): if not source.startswith(os.sep): docsource, line = utils.get_source_line(node) if docsource: dirname = self.builder.env.srcdir if dirname: source = '%s%s%s' % ( dirname, os.sep, source, ) if not self.check_file_exists(source): self.document.reporter.warning( 'Cannot find image file %s.' % (source, )) return else: return if source in self.image_dict: spec = self.image_dict[source] else: self.image_count += 1 filename = os.path.split(source)[1] destination = 'Pictures/1%08x%s' % ( self.image_count, filename, ) if source.startswith('http:'): try: imgfile = urllib2.urlopen(source) content = imgfile.read() imgfile.close() imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False) imgfile2.write(content) imgfile2.close() imgfilename = imgfile2.name source = imgfilename except urllib2.HTTPError, e: self.document.reporter.warning("Can't open image url %s." % (source, )) spec = ( source, destination, ) else:
def get_location(node, app): """ Given a docutils node and a sphinx application, return a string representation of the source location of this node. Usually, this will be of the form "path/to/file:linenumber". Two special values can be emitted, "<external>" for paths which are not contained in this source tree (e.g. docstrings included from other modules) or "<unknown>", inidcating that the sphinx application cannot locate the original source file (usually because an extension has injected text into the sphinx parsing engine). """ source, line = get_source_line(node) if source: # 'source' can have the form '/some/path:docstring of some.api' but the # colons are forbidden on windows, but on posix just passes through. path, *post = source.partition(':') post = ''.join(post) # We locate references relative to the parent of the doc # directory, which for matplotlib, will be the root of the # matplotlib repo. When matplotlib is not an editable install # weird things will happen, but we can't totally recover from # that. basepath = Path(app.srcdir).parent.resolve() fullpath = Path(path).resolve() try: path = fullpath.relative_to(basepath) except ValueError: # Sometimes docs directly contain e.g. docstrings # from installed modules, and we record those as # <external> so as to be independent of where the # module was installed path = Path("<external>") / fullpath.name # Ensure that all reported paths are POSIX so that docs # on windows result in the same warnings in the JSON file. path = path.as_posix() else: path = "<unknown>" post = '' if not line: line = "" return f"{path}{post}:{line}"
def run(self): env = self.state.document.settings.env node = ItemLink('') node['sources'] = [] node['targets'] = [] node['type'] = None if 'sources' in self.options: node['sources'] = self.options['sources'].split() else: report_warning( env, 'sources argument required for item-link directive', env.docname, self.lineno) return [] if 'targets' in self.options: node['targets'] = self.options['targets'].split() else: report_warning( env, 'targets argument required for item-link directive', env.docname, self.lineno) return [] if 'type' in self.options: node['type'] = self.options['type'] else: report_warning(env, 'type argument required for item-link directive', env.docname, self.lineno) return [] # Processing of the item-link items. They get added as additional relationships # to the existing items. Should be done before converting anything to docutils. for source in node['sources']: for target in node['targets']: try: env.traceability_collection.add_relation( source, node['type'], target) except TraceabilityException as err: docname, lineno = get_source_line(node) report_warning(env, err, docname, lineno) # The ItemLink node has no final representation, so is removed from the tree return [node]
def make_internal_item_ref(app, node, fromdocname, item_id, caption=True): """ Creates a reference node for an item, embedded in a paragraph. Reference text adds also a caption if it exists. """ env = app.builder.env item_info = env.traceability_collection.get_item(item_id) p_node = nodes.paragraph() # Only create link when target item exists, warn otherwise (in html and terminal) if item_info.is_placeholder(): docname, lineno = get_source_line(node) report_warning( env, 'Traceability: cannot link to %s, item is not defined' % item_id, docname, lineno) txt = nodes.Text('%s not defined, broken link' % item_id) p_node.append(txt) else: if item_info.caption != '' and caption: caption = ' : ' + item_info.caption else: caption = '' newnode = nodes.reference('', '') innernode = nodes.emphasis(item_id + caption, item_id + caption) newnode['refdocname'] = item_info.docname try: newnode['refuri'] = app.builder.get_relative_uri( fromdocname, item_info.docname) newnode['refuri'] += '#' + item_id except NoUri: # ignore if no URI can be determined, e.g. for LaTeX output :( pass newnode.append(innernode) p_node += newnode return p_node
def apply(self): # type: () -> None for node in self.document.traverse(addnodes.pending_xref): if node.get('reftype') == 'doc' and node.get('refdomain') is None: source, line = get_source_line(node) if source and line: location = "%s:%s" % (source, line) elif source: location = "%s:" % source elif line: location = "<unknown>:%s" % line else: location = None message = ('Invalid pendig_xref node detected. ' ':doc: reference should have refdomain=std attribute.') if location: warnings.warn("%s: %s" % (location, message), RemovedInSphinx20Warning) else: warnings.warn(message, RemovedInSphinx20Warning) node['refdomain'] = 'std'
def node_warning(self, env, msg, node): from sphinx.util import logging logger = logging.getLogger(__name__) logger.warning(msg, location=get_source_line(node))
def _warn_node(self, msg, node): """Do not warn on external images.""" if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def warn_node(self, msg, node, **kwargs): # type: (unicode, nodes.Node, Any) -> None """Like :meth:`warn`, but with source information taken from *node*.""" self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs)
def process_item_nodes(app, doctree, fromdocname): """ This function should be triggered upon ``doctree-resolved event`` Replace all ItemList nodes with a list of the collected items. Augment each item with a backlink to the original location. """ env = app.builder.env if sphinx_version < '1.6.0': try: env.traceability_collection.self_test(fromdocname) except TraceabilityException as err: report_warning(env, err, fromdocname) except MultipleTraceabilityExceptions as errs: for err in errs.iter(): report_warning(env, err, err.get_document()) # Processing of the item-link items. for node in doctree.traverse(ItemLink): # The ItemLink node has no final representation, so is removed from the tree node.replace_self([]) # Item matrix: # Create table with related items, printing their target references. # Only source and target items matching respective regexp shall be included for node in doctree.traverse(ItemMatrix): showcaptions = not node['nocaptions'] source_ids = env.traceability_collection.get_items(node['source']) target_ids = env.traceability_collection.get_items(node['target']) top_node = create_top_node(node['title']) table = nodes.table() tgroup = nodes.tgroup() left_colspec = nodes.colspec(colwidth=5) right_colspec = nodes.colspec(colwidth=5) tgroup += [left_colspec, right_colspec] tgroup += nodes.thead( '', nodes.row( '', nodes.entry('', nodes.paragraph('', node['sourcetitle'])), nodes.entry('', nodes.paragraph('', node['targettitle'])))) tbody = nodes.tbody() tgroup += tbody table += tgroup relationships = node['type'] if not relationships: relationships = env.traceability_collection.iter_relations() count_total = 0 count_covered = 0 for source_id in source_ids: source_item = env.traceability_collection.get_item(source_id) count_total += 1 covered = False row = nodes.row() left = nodes.entry() left += make_internal_item_ref(app, node, fromdocname, source_id, showcaptions) right = nodes.entry() for relationship in relationships: if REGEXP_EXTERNAL_RELATIONSHIP.search(relationship): for target_id in source_item.iter_targets(relationship): right += make_external_item_ref( app, target_id, relationship) covered = True for target_id in target_ids: if env.traceability_collection.are_related( source_id, relationships, target_id): right += make_internal_item_ref(app, node, fromdocname, target_id, showcaptions) covered = True if covered: count_covered += 1 row += left row += right tbody += row try: percentage = int(100 * count_covered / count_total) except ZeroDivisionError: percentage = 0 disp = 'Statistics: {cover} out of {total} covered: {pct}%'.format( cover=count_covered, total=count_total, pct=percentage) if node['stats']: p_node = nodes.paragraph() txt = nodes.Text(disp) p_node += txt top_node += p_node top_node += table node.replace_self(top_node) # Item attribute matrix: # Create table with items, printing their attribute values. for node in doctree.traverse(ItemAttributesMatrix): docname, lineno = get_source_line(node) showcaptions = not node['nocaptions'] item_ids = env.traceability_collection.get_items( node['filter'], sortattributes=node['sort'], reverse=node['reverse']) top_node = create_top_node(node['title']) table = nodes.table() tgroup = nodes.tgroup() colspecs = [nodes.colspec(colwidth=5)] hrow = nodes.row('', nodes.entry('', nodes.paragraph('', ''))) for attr in node['attributes']: colspecs.append(nodes.colspec(colwidth=5)) p_node = nodes.paragraph() if attr in app.config.traceability_attribute_to_string: attrstr = app.config.traceability_attribute_to_string[attr] else: report_warning( env, 'Traceability: attribute {attr} cannot be translated to string' .format(attr=attr), docname, lineno) attrstr = attr p_node += nodes.Text(attrstr) hrow.append(nodes.entry('', p_node)) tgroup += colspecs tgroup += nodes.thead('', hrow) tbody = nodes.tbody() for item_id in item_ids: item = env.traceability_collection.get_item(item_id) row = nodes.row() cell = nodes.entry() cell += make_internal_item_ref(app, node, fromdocname, item_id, showcaptions) row += cell for attr in node['attributes']: cell = nodes.entry() p_node = nodes.paragraph() txt = item.get_attribute(attr) p_node += nodes.Text(txt) cell += p_node row += cell tbody += row tgroup += tbody table += tgroup top_node += table node.replace_self(top_node) # Item 2D matrix: # Create table with related items, printing their target references. # Only source and target items matching respective regexp shall be included for node in doctree.traverse(Item2DMatrix): source_ids = env.traceability_collection.get_items(node['source']) target_ids = env.traceability_collection.get_items(node['target']) top_node = create_top_node(node['title']) table = nodes.table() tgroup = nodes.tgroup() colspecs = [nodes.colspec(colwidth=5)] hrow = nodes.row('', nodes.entry('', nodes.paragraph('', ''))) for source_id in source_ids: colspecs.append(nodes.colspec(colwidth=5)) src_cell = make_internal_item_ref(app, node, fromdocname, source_id, False) hrow.append(nodes.entry('', src_cell)) tgroup += colspecs tgroup += nodes.thead('', hrow) tbody = nodes.tbody() for target_id in target_ids: row = nodes.row() tgt_cell = nodes.entry() tgt_cell += make_internal_item_ref(app, node, fromdocname, target_id, False) row += tgt_cell for source_id in source_ids: cell = nodes.entry() p_node = nodes.paragraph() if env.traceability_collection.are_related( source_id, node['type'], target_id): txt = node['hit'] else: txt = node['miss'] p_node += nodes.Text(txt) cell += p_node row += cell tbody += row tgroup += tbody table += tgroup top_node += table node.replace_self(top_node) # Item list: # Create list with target references. Only items matching list regexp # shall be included for node in doctree.traverse(ItemList): item_ids = env.traceability_collection.get_items( node['filter'], node['attributes']) showcaptions = not node['nocaptions'] top_node = create_top_node(node['title']) ul_node = nodes.bullet_list() for i in item_ids: bullet_list_item = nodes.list_item() p_node = nodes.paragraph() p_node.append( make_internal_item_ref(app, node, fromdocname, i, showcaptions)) bullet_list_item.append(p_node) ul_node.append(bullet_list_item) top_node += ul_node node.replace_self(top_node) # Item tree: # Create list with target references. Only items matching list regexp # shall be included for node in doctree.traverse(ItemTree): top_item_ids = env.traceability_collection.get_items(node['top']) showcaptions = not node['nocaptions'] top_node = create_top_node(node['title']) ul_node = nodes.bullet_list() ul_node.set_class('bonsai') for i in top_item_ids: if is_item_top_level(env, i, node['top'], node['top_relation_filter']): ul_node.append( generate_bullet_list_tree(app, env, node, fromdocname, i, showcaptions)) top_node += ul_node node.replace_self(top_node) # Resolve item cross references (from ``item`` role) for node in doctree.traverse(PendingItemXref): # Create a dummy reference to be used if target reference fails new_node = make_refnode(app.builder, fromdocname, fromdocname, 'ITEM_NOT_FOUND', node[0].deepcopy(), node['reftarget'] + '??') # If target exists, try to create the reference item_info = env.traceability_collection.get_item(node['reftarget']) if item_info: if item_info.is_placeholder(): docname, lineno = get_source_line(node) report_warning( env, 'Traceability: cannot link to %s, item is not defined' % item_info.get_id(), docname, lineno) else: try: new_node = make_refnode(app.builder, fromdocname, item_info.docname, item_info.node['refid'], node[0].deepcopy(), node['reftarget']) except NoUri: # ignore if no URI can be determined, e.g. for LaTeX output :( pass else: docname, lineno = get_source_line(node) report_warning( env, 'Traceability: item %s not found' % node['reftarget'], docname, lineno) node.replace_self(new_node) # Item: replace item nodes, with admonition, list of relationships for node in doctree.traverse(Item): docname, lineno = get_source_line(node) currentitem = env.traceability_collection.get_item(node['id']) showcaptions = not node['nocaptions'] header = currentitem.get_id() if currentitem.caption: header += ' : ' + currentitem.caption top_node = create_top_node(header) par_node = nodes.paragraph() dl_node = nodes.definition_list() if app.config.traceability_render_attributes_per_item: if currentitem.iter_attributes(): li_node = nodes.definition_list_item() dt_node = nodes.term() txt = nodes.Text('Attributes') dt_node.append(txt) li_node.append(dt_node) for attr in currentitem.iter_attributes(): dd_node = nodes.definition() p_node = nodes.paragraph() if attr in app.config.traceability_attribute_to_string: attrstr = app.config.traceability_attribute_to_string[ attr] else: report_warning( env, 'Traceability: attribute {attr} cannot be translated to string' .format(attr=attr), docname, lineno) attrstr = attr txt = nodes.Text('{attr}: {value}'.format( attr=attrstr, value=currentitem.get_attribute(attr))) p_node.append(txt) dd_node.append(p_node) li_node.append(dd_node) dl_node.append(li_node) if app.config.traceability_render_relationship_per_item: for rel in env.traceability_collection.iter_relations(): tgts = currentitem.iter_targets(rel) if tgts: li_node = nodes.definition_list_item() dt_node = nodes.term() if rel in app.config.traceability_relationship_to_string: relstr = app.config.traceability_relationship_to_string[ rel] else: report_warning( env, 'Traceability: relation {rel} cannot be translated to string' .format(rel=rel), docname, lineno) relstr = rel txt = nodes.Text(relstr) dt_node.append(txt) li_node.append(dt_node) for tgt in tgts: dd_node = nodes.definition() p_node = nodes.paragraph() if REGEXP_EXTERNAL_RELATIONSHIP.search(rel): link = make_external_item_ref(app, tgt, rel) else: link = make_internal_item_ref( app, node, fromdocname, tgt, showcaptions) p_node.append(link) dd_node.append(p_node) li_node.append(dd_node) dl_node.append(li_node) par_node.append(dl_node) top_node.append(par_node) # Note: content should be displayed during read of RST file, as it contains other RST objects node.replace_self(top_node)
def _warn_node(self, msg, node): # Do not bother me with non local images thanks if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, **kwargs): if 'nonlocal image URI found' not in msg: self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node): """Monkey patch non-local image warning""" if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node): if not msg.startswith('nonlocal image URI'): self._warnfunc(msg, '{}:{}'.format(*get_source_line(node)))
def _warn_node(self, msg, node, **kw): """ Monkey patch to ignore specific errors """ if not msg.startswith(('py:obj reference target not found', 'nonlocal image URI found')): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, *args, **kwargs): if not msg.startswith('nonlocal image URI found:'): # pylint: disable=protected-access self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, **kwargs): if msg.startswith('nonlocal image URI found:'): return self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, *args, **kwargs): """Do not warn on external images.""" if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, **kwargs): if not (msg.startswith('nonlocal image URI found:') or 'Unexpected indentation' in msg or 'Definition list ends without a blank line' in msg or 'document isn\'t included in any toctree' in msg): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def process_item_nodes(app, doctree, fromdocname): """ This function should be triggered upon ``doctree-resolved event`` Replace all ItemList nodes with a list of the collected items. Augment each item with a backlink to the original location. """ env = app.builder.env all_item_ids = sorted(env.traceability_all_items, key=naturalsortkey) # Item matrix: # Create table with related items, printing their target references. # Only source and target items matching respective regexp shall be included for node in doctree.traverse(ItemMatrix): table = nodes.table() tgroup = nodes.tgroup() left_colspec = nodes.colspec(colwidth=5) right_colspec = nodes.colspec(colwidth=5) tgroup += [left_colspec, right_colspec] tgroup += nodes.thead( '', nodes.row('', nodes.entry('', nodes.paragraph('', 'Source')), nodes.entry('', nodes.paragraph('', 'Target')))) tbody = nodes.tbody() tgroup += tbody table += tgroup for source_id in all_item_ids: source_item = env.traceability_all_items[source_id] # placeholders don't end up in any item-matrix (less duplicate warnings for missing items) if source_item['placeholder'] is True: continue if re.match(node['source'], source_id): row = nodes.row() left = nodes.entry() left += make_internal_item_ref(app, node, fromdocname, source_id) right = nodes.entry() for relationship in node['type']: if REGEXP_EXTERNAL_RELATIONSHIP.search(relationship): for target_id in source_item[relationship]: right += make_external_item_ref( app, target_id, relationship) for target_id in all_item_ids: target_item = env.traceability_all_items[target_id] # placeholders don't end up in any item-matrix (less duplicate warnings for missing items) if target_item['placeholder'] is True: continue if (re.match(node['target'], target_id) and are_related( env, source_id, target_id, node['type'])): right += make_internal_item_ref( app, node, fromdocname, target_id) row += left row += right tbody += row node.replace_self(table) # Item list: # Create list with target references. Only items matching list regexp # shall be included for node in doctree.traverse(ItemList): ul_node = nodes.bullet_list() for i in all_item_ids: # placeholders don't end up in any item-list (less duplicate warnings for missing items) if env.traceability_all_items[i]['placeholder'] is True: continue if re.match(node['filter'], i): bullet_list_item = nodes.list_item() p_node = nodes.paragraph() p_node.append(make_internal_item_ref(app, node, fromdocname, i)) bullet_list_item.append(p_node) ul_node.append(bullet_list_item) node.replace_self(ul_node) # Item tree: # Create list with target references. Only items matching list regexp # shall be included for node in doctree.traverse(ItemTree): ul_node = nodes.bullet_list() ul_node.set_class('bonsai') for i in all_item_ids: # placeholders don't end up in any item-tree (less duplicate warnings for missing items) if env.traceability_all_items[i]['placeholder'] is True: continue if re.match(node['top'], i): if is_item_top_level(env, i, node['top'], node['top_relation_filter']): ul_node.append( generate_bullet_list_tree(app, env, node, fromdocname, i)) node.replace_self(ul_node) # Resolve item cross references (from ``item`` role) for node in doctree.traverse(PendingItemXref): # Create a dummy reference to be used if target reference fails new_node = make_refnode(app.builder, fromdocname, fromdocname, 'ITEM_NOT_FOUND', node[0].deepcopy(), node['reftarget'] + '??') # If target exists, try to create the reference if node['reftarget'] in env.traceability_all_items: item_info = env.traceability_all_items[node['reftarget']] if item_info['placeholder'] is True: report_warning( env, 'Traceability: cannot link to %s, item is not defined' % item_info['id'], fromdocname, get_source_line(node)) else: try: new_node = make_refnode(app.builder, fromdocname, item_info['docname'], item_info['target']['refid'], node[0].deepcopy(), node['reftarget']) except NoUri: # ignore if no URI can be determined, e.g. for LaTeX output :( pass else: report_warning( env, 'Traceability: item %s not found' % node['reftarget'], fromdocname, get_source_line(node)) node.replace_self(new_node) # Item: replace item nodes, with admonition, list of relationships for node in doctree.traverse(Item): currentitem = env.traceability_all_items[node['id']] cont = nodes.container() admon = nodes.admonition() title = nodes.title() header = currentitem['id'] if currentitem['caption']: header += ' : ' + currentitem['caption'] txt = nodes.Text(header) title.append(txt) admon.append(title) cont.append(admon) if app.config.traceability_render_relationship_per_item: par_node = nodes.paragraph() dl_node = nodes.definition_list() for rel in sorted(list(env.relationships.keys())): if rel in currentitem and currentitem[rel]: li_node = nodes.definition_list_item() dt_node = nodes.term() if rel in app.config.traceability_relationship_to_string: relstr = app.config.traceability_relationship_to_string[ rel] else: continue txt = nodes.Text(relstr) dt_node.append(txt) li_node.append(dt_node) for tgt in currentitem[rel]: dd_node = nodes.definition() p_node = nodes.paragraph() if REGEXP_EXTERNAL_RELATIONSHIP.search(rel): link = make_external_item_ref(app, tgt, rel) else: link = make_internal_item_ref( app, node, fromdocname, tgt, True) p_node.append(link) dd_node.append(p_node) li_node.append(dd_node) dl_node.append(li_node) par_node.append(dl_node) cont.append(par_node) ## Note: content should be displayed during read of RST file, as it contains other RST objects node.replace_self(cont)
def _supress_nonlocal_image_warn(self, msg, node, **kwargs): if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs)
def _supress_nonlocal_image_warn(self, msg, node): from docutils.utils import get_source_line if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def get_node_line(node): # This returns source, line. Pick just the line. return get_source_line(node)[1]
def _warn_node(self, msg, node, **kwargs): if not msg.startswith("nonlocal image URI found:"): self._warnfunc(msg, "%s:%s" % get_source_line(node))
def _supress_nonlocal_image_warn(self, msg, node, **kwargs): from docutils.utils import get_source_line if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '{0!s}:{1!s}'.format(*get_source_line(node)))
def _warn_node(self, msg, node): """Do not warn on external images.""" if not msg.startswith("nonlocal image URI found:"): self._warnfunc(msg, "%s:%s" % get_source_line(node))
def _supress_nonlocal_image_warn(self, msg, node, **kwargs): if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '{:s}:{:s}'.format(get_source_line(node), **kwargs))
def _warn_node(self, msg, node): if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node): if not msg.startswith('nonlocal image URI found:') or "paypal" not in msg: self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _supress_nonlocal_image_warn(self, msg, node): if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def _warn_node(self, msg, node, **kwargs): if not msg.startswith("nonlocal image URI found:"): self._warnfunc(msg, "%s:%s" % get_source_line(node), **kwargs)
def _warn_node(self, msg, node, *args, **kwargs): if not msg.startswith('nonlocal image URI found:'): self._warnfunc(msg, '%s:%s' % get_source_line(node))
def warn_node(self, msg, node, **kwargs): """Like :meth:`warn`, but with source information taken from *node*.""" self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs)