def run(self):
     ret = super(Latest, self).run()
     #extract the tocnode. We not want.
     #Could we even expand it to a full hierarchy here?
     tocnode = ret[0][0]
     tocatts = tocnode.non_default_attributes()
     latestnode = latest()
     for key, val in tocatts.iteritems():
         latestnode[key] = val
     wrappernode = nodes.compound(classes=['latest-wrapper'])
     wrappernode.append(latestnode)
     ret.append(wrappernode)
     return ret
 def run(self):
     ret = super(Latest, self).run()
     #extract the tocnode. We not want.
     #Could we even expand it to a full hierarchy here?
     tocnode = ret[0][0]
     tocatts = tocnode.non_default_attributes()
     latestnode = latest()
     for key, val in tocatts.iteritems():
         latestnode[key] = val
     wrappernode = nodes.compound(classes=['latest-wrapper'])
     wrappernode.append(latestnode)
     ret.append(wrappernode)
     return ret
Beispiel #3
0
 def run(self):
     env = self.state.document.settings.env
     suffix = env.config.source_suffix
     glob = 'glob' in self.options
             
     # (title, ref) pairs, where ref may only be a document
     # external links are forbidden, since we have no way of dating them
     # and title may be None if the document's title is to be used
     entries = []
     includefiles = []
     
     all_docnames = env.found_docs.copy()
     # don't add the currently visited file in catch-all patterns
     all_docnames.remove(env.docname)
     
     ret = []
     
     for entry in self.content:
         if not entry:
             continue
         if not glob:
             # look for explicit titles ("Some Title <document>")
             m = explicit_title_re.match(entry)
             if m:
                 ref = m.group(2)
                 title = m.group(1)
                 docname = ref
             else:
                 ref = docname = entry
                 title = None
             # remove suffixes (backwards compatibility)
             if docname.endswith(suffix):
                 docname = docname[:-len(suffix)]
             # absolutize filenames
             docname = docname_join(env.docname, docname)
             if url_re.match(ref) or ref == 'self':
                 entries.append((title, ref))
             elif docname not in env.found_docs:
                 ret.append(self.state.document.reporter.warning(
                     'toctree contains reference to nonexisting '
                     'document %r' % docname, line=self.lineno))
                 env.note_reread()
             else:
                 entries.append((title, docname))
                 includefiles.append(docname)
         else:
             patname = docname_join(env.docname, entry)
             docnames = patfilter(all_docnames, patname)
             for docname in docnames:
                 all_docnames.remove(docname) # don't include it again
                 entries.append((None, docname))
                 includefiles.append(docname)
             if not docnames:
                 ret.append(self.state.document.reporter.warning(
                     'latest list glob pattern %r didn\'t match any documents'
                     % entry, line=self.lineno))
     
     subnode = latest()
     subnode['parent'] = env.docname
     # entries contains all entries (self references, external links etc.)
     subnode['entries'] = entries
     # includefiles only entries that are documents
     subnode['includefiles'] = includefiles
     subnode['maxdepth'] = self.options.get('maxdepth', -1)
     subnode['glob'] = glob
     subnode['titlesonly'] = 'titlesonly' in self.options
     #what does this do?
     set_source_info(self, subnode)
     wrappernode = nodes.compound(classes=['feed-latest-wrapper'])
     wrappernode.append(subnode)
     ret.append(wrappernode)
     return ret
    def run(self):
        env = self.state.document.settings.env
        suffix = env.config.source_suffix
        glob = 'glob' in self.options

        # (title, ref) pairs, where ref may only be a document
        # external links are forbidden, since we have no way of dating them
        # and title may be None if the document's title is to be used
        entries = []
        includefiles = []

        all_docnames = env.found_docs.copy()
        # don't add the currently visited file in catch-all patterns
        all_docnames.remove(env.docname)

        ret = []

        for entry in self.content:
            if not entry:
                continue
            if not glob:
                # look for explicit titles ("Some Title <document>")
                m = explicit_title_re.match(entry)
                if m:
                    ref = m.group(2)
                    title = m.group(1)
                    docname = ref
                else:
                    ref = docname = entry
                    title = None
                # remove suffixes (backwards compatibility)
                if docname.endswith(suffix):
                    docname = docname[:-len(suffix)]
                # absolutize filenames
                docname = docname_join(env.docname, docname)
                if url_re.match(ref) or ref == 'self':
                    entries.append((title, ref))
                elif docname not in env.found_docs:
                    ret.append(
                        self.state.document.reporter.warning(
                            'toctree contains reference to nonexisting '
                            'document %r' % docname,
                            line=self.lineno))
                    env.note_reread()
                else:
                    entries.append((title, docname))
                    includefiles.append(docname)
            else:
                patname = docname_join(env.docname, entry)
                docnames = patfilter(all_docnames, patname)
                for docname in docnames:
                    all_docnames.remove(docname)  # don't include it again
                    entries.append((None, docname))
                    includefiles.append(docname)
                if not docnames:
                    ret.append(
                        self.state.document.reporter.warning(
                            'latest list glob pattern %r didn\'t match any documents'
                            % entry,
                            line=self.lineno))

        subnode = latest()
        subnode['parent'] = env.docname
        # entries contains all entries (self references, external links etc.)
        subnode['entries'] = entries
        # includefiles only entries that are documents
        subnode['includefiles'] = includefiles
        subnode['maxdepth'] = self.options.get('maxdepth', -1)
        subnode['glob'] = glob
        subnode['titlesonly'] = 'titlesonly' in self.options
        #what does this do?
        set_source_info(self, subnode)
        wrappernode = nodes.compound(classes=['feed-latest-wrapper'])
        wrappernode.append(subnode)
        ret.append(wrappernode)
        return ret