docs: def process_item_nodes(app, doctree, fromdocname):
      """
      This function should be triggered upon ``doctree-resolved event``
  
      Replace all item_list nodes with a list of the collected items.
      Augment each item with a backlink to the original location.
  
      """
      env = app.builder.env
  
      all_items = 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(item_matrix):
          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_item in all_items:
              if re.match(node['source'], source_item):
                  row = nodes.row()
                  left = nodes.entry()
                  left += make_item_ref(app, env, fromdocname,
                                        env.traceability_all_items[source_item])
                  right = nodes.entry()
                  for target_item in all_items:
                      if (re.match(node['target'], target_item) and
                              are_related(
                                  env, source_item, target_item, node['type'])):
                          right += make_item_ref(
                              app, env, fromdocname,
                              env.traceability_all_items[target_item])
                  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(item_list):
          content = nodes.bullet_list()
          for item in all_items:
              if re.match(node['filter'], item):
                  bullet_list_item = nodes.list_item()
                  paragraph = nodes.paragraph()
                  paragraph.append(
                      make_item_ref(app, env, fromdocname,
                                    env.traceability_all_items[item]))
                  bullet_list_item.append(paragraph)
                  content.append(bullet_list_item)
  
          node.replace_self(content)
  
      # Resolve item cross references (from ``item`` role)
      for node in doctree.traverse(pending_item_xref):
          # 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']]
              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:
              env.warn_node(
                  'Traceability: item %s not found' % node['reftarget'], node)
  
          node.replace_self(new_node)