Generate toctree directive text.

        :param table_of_content_header:
        :param header_bar_char:
        :param header_line_length:
        :param maxdepth:
        :return:
491901
def toc_directive(self, maxdepth=1):
        
        articles_directive_content = TC.toc.render(
            maxdepth=maxdepth,
            article_list=self.sub_article_folders,
        )
        return articles_directive_content
909178
function genTree (toc, maxLevel) {
  var headlines = [];
  var last = {};

  toc.forEach(function (headline) {
    var level = headline.level || 1;
    var len = level - 1;

    if (level > maxLevel) { return }
    if (last[len]) {
      last[len].children = (last[len].children || []).concat(headline);
    } else {
      headlines.push(headline);
    }
    last[level] = headline;
  });

  return headlines
}
306410
def _iter_texts(self, tree):
        """"""
        skip = (
            not isinstance(tree, lxml.html.HtmlElement)  # comments, etc.
            or tree.tag in self.skipped_tags
        )
        if not skip:
            if tree.text:
                yield Text(tree.text, tree, 'text')
            for child in tree:
                for text in self._iter_texts(child):
                    yield text
        if tree.tail:
            yield Text(tree.tail, tree, 'tail')
1003815
def build_full_toctree(builder, docname, prune, collapse):
    
    env = builder.env
    doctree = env.get_doctree(env.config.master_doc)
    toctrees = []
    for toctreenode in doctree.traverse(addnodes.toctree):
        toctree = env.resolve_toctree(docname, builder, toctreenode,
                                      collapse=collapse,
                                      prune=prune,
                                      )
        toctrees.append(toctree)
    if not toctrees:
        return None
    result = toctrees[0]
    for toctree in toctrees[1:]:
        if toctree:
            result.extend(toctree.children)
    env.resolve_references(result, docname, builder)
    return result
636570
def _make_default_header(self):
        
        td_max = 0

        for idx, tr in enumerate(self._tr_nodes):
            td_count = len(tr.contents.filter_tags(matches=ftag('td')))
            if td_count > td_max:
                td_max = td_count

        self._log('creating default header (%d columns)' % td_max)
        return [ 'column%d' % n for n in range(0,td_max) ]
463132
function tree (toc, tpl) {
  if ( tpl === void 0 ) tpl = '';

  if (!toc || !toc.length) { return '' }

  toc.forEach(function (node) {
    tpl += "<li><a class=\"section-link\" href=\"" + (node.slug) + "\">" + (node.title) + "</a></li>";
    if (node.children) {
      tpl += "<li><ul class=\"children\">" + (tree(node.children)) + "</li></ul>";
    }
  });

  return tpl
}
269064
def _header_string(basis_dict):
    '''
    '''

    tw = textwrap.TextWrapper(initial_indent='', subsequent_indent=' ' * 20)

    header = '-' * 70 + '\n'
    header += ' Basis Set Exchange\n'
    header += ' Version ' + version() + '\n'
    header += ' ' + _main_url + '\n'
    header += '-' * 70 + '\n'
    header += '   Basis set: ' + basis_dict['name'] + '\n'
    header += tw.fill(' Description: ' + basis_dict['description']) + '\n'
    header += '        Role: ' + basis_dict['role'] + '\n'
    header += tw.fill('     Version: {}  ({})'.format(basis_dict['version'],
                                                      basis_dict['revision_description'])) + '\n'
    header += '-' * 70 + '\n'

    return header
860743
def _find_header_row(self):
        
        th_max = 0
        header_idx = 0
        for idx, tr in enumerate(self._tr_nodes):
            th_count = len(tr.contents.filter_tags(matches=ftag('th')))
            if th_count > th_max:
                th_max = th_count
                header_idx = idx

        if not th_max:
            return

        self._log('found header at row %d (%d <th> elements)' % \
                    (header_idx, th_max))

        header_row = self._tr_nodes.pop(header_idx)
        return header_row.contents.filter_tags(matches=ftag('th'))
728341
def _prepare_header_cells(self, table_header):
        

        cells = self.parser.find(table_header).find_children(
            'tr'
        ).find_children('th').list_results()
        for cell in cells:
            self.id_generator.generate_id(cell)

            cell.set_attribute('scope', 'col')
243977
def showRichText( self ):
        
        delegate = self.itemDelegate()
        if ( isinstance(delegate, XTreeWidgetDelegate) ):
            return delegate.showRichText()
        return None
360979
def to_markdown(self):
        
        out = self._get_header()
        out += "\n"

        for row in self.table:
            out += self._get_row(row)
            out += "\n"

        return out
773221
def dict_to_table(header, contents):
    
    def to_text(row):
        name, value = row
        m = max_col1_size + 1 - len(name)
        spacing = ' ' * m

        return ''.join([name, spacing, value])

    thead = tuple(str(col) for col in header)
    rows = []
    for name, value in contents.items():
        # code highlighting
        if value != '':
            if isinstance(value, str):
                value = "'{}'".format(value)
            value = ':py:`{}`'.format(value)
        rows.append((name, value))

    n = np.max([len(header[0])] +
               [len(col1) for col1, _ in rows])
    hborder = tuple('='*n for col in header)
    rows = [hborder, thead, hborder] + rows + [hborder]
    max_col1_size = np.max([len(col1) for col1, _ in rows])
    table = '\n'.join([to_text(row) for row in rows])
    return table
1185555
def _drawContents(self, currentRti=None):
        
        table = self.table
        table.setUpdatesEnabled(False)
        try:
            table.clearContents()
            verticalHeader = table.verticalHeader()
            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)

            if currentRti is None:
                return

            # Each column in the repo tree corresponds to a row in this detail pane.
            repoModel = self._repoTreeView.model()
            propNames = RepoTreeModel.HEADERS
            table.setRowCount(len(propNames))

            for row, propName in enumerate(propNames):
                nameItem = QtWidgets.QTableWidgetItem(propName)
                nameItem.setToolTip(propName)
                table.setItem(row, self.COL_PROP_NAME, nameItem)
                propValue = repoModel.itemData(currentRti, row)
                propItem = QtWidgets.QTableWidgetItem(propValue)
                propItem.setToolTip(propValue)
                table.setItem(row, self.COL_VALUE, propItem)
                table.resizeRowToContents(row)

            verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

        finally:
            table.setUpdatesEnabled(True)
1244424
def toc(self):
        
        from mistletoe.block_token import List
        def get_indent(level):
            if self.omit_title:
                level -= 1
            return ' ' * 4 * (level - 1)

        def build_list_item(heading):
            level, content = heading
            template = '{indent}- {content}\n'
            return template.format(indent=get_indent(level), content=content)

        return List([build_list_item(heading) for heading in self._headings])
339937
def to_html(self):
        
        table = '<table%s>\n' % self.html_attributes()
        if self.caption is not None:
            if isinstance(self.caption, MessageElement):
                caption = self.caption.to_html()
            else:
                caption = self.caption
            table += '<caption>%s</caption>\n' % caption
        if self.header:
            if isinstance(self.header, MessageElement):
                header = self.header.to_html()
            else:
                header = self.header
            table += '<thead>%s</thead>' % header
        table += '<tbody>\n'
        for row in self.rows:
            table += row.to_html()
        table += '</tbody>\n</table>\n'

        return table
803186
def menuTemplate( self ):
        
        xml = ElementTree.Element('menu')
        for i in range(self.uiMenuTREE.topLevelItemCount()):
            self.saveXml(xml, self.uiMenuTREE.topLevelItem(i))
        
        projex.text.xmlindent(xml)
        return ElementTree.tostring(xml)
482592
def get_toc(text):
    
    mkd.convert(text)
    toc = mkd.toc
    mkd.reset()
    return toc