예제 #1
0
 def createToken(self, parent, info, page):
     suffix = self.settings['suffix']
     ul = core.UnorderedList(parent)
     for category in self.extension.get('categories'):
         fname = '{}_{}.md'.format(category, suffix)
         if not page.local.endswith(fname):
             autolink.AutoLink(core.ListItem(ul), page=u'sqa/{}'.format(fname),
                               optional=True, warning=True, class_='moose-sqa-dependency')
     return parent
예제 #2
0
    def createToken(self, parent, info, page):

        tree = dict()
        tree[(u'', )] = core.UnorderedList(parent, browser_default=False)

        location = self.settings['location']

        func = lambda p: p.local.startswith(location) and isinstance(
            p, pages.Source)
        nodes = self.translator.findPages(func)
        for node in nodes:
            key = tuple(
                node.local.strip(os.sep).replace(location,
                                                 '').split(os.sep))[:-1]
            for i in xrange(1, len(key) + 1):
                k = key[:i]
                if k not in tree:
                    col = Collapsible(tree[k[:-1]], summary=k[-1])
                    li = core.ListItem(col,
                                       class_='moose-source-item',
                                       tooltip=False)
                    tree[k] = core.UnorderedList(li, browser_default=False)

        for node in nodes:
            key = tuple(
                node.local.strip(os.sep).replace(location,
                                                 '').split(os.sep))[:-1]
            loc = node.relativeDestination(page)
            li = core.ListItem(tree[key])
            core.Link(li,
                      url=loc,
                      string=node.name,
                      class_='moose-source-item',
                      tooltip=False)

        return parent
예제 #3
0
파일: sqa.py 프로젝트: lszeng-hnu/moose
    def createToken(self, parent, info, page):
        suffix = self.settings['suffix']
        category = self.settings['category']
        if category == '_empty_':
            depends = self.extension.get('categories').keys()
        else:
            depends = self.extension.dependencies(category) or \
                self.extension.get('categories').keys()

        ul = core.UnorderedList(parent)
        for dep in depends:
            if dep != category:
                fname = '{}_{}.md'.format(dep, suffix)
                autolink.AutoLink(core.ListItem(ul), page='sqa/{}'.format(fname),
                                  optional=True, warning=True, class_='moose-sqa-dependency')
        return parent
예제 #4
0
    def createTokenFromSyntax(self, parent, info, page, obj):

        item = self.extension.database.get(obj.name, None)
        attr = getattr(item, self.SUBCOMMAND, None)
        if item and attr:
            self.createHeading(parent, page)
            ul = core.UnorderedList(parent, class_='moose-list-{}'.format(self.SUBCOMMAND))
            for filename in attr:
                filename = unicode(filename)
                li = core.ListItem(ul)
                lang = common.get_language(filename)
                content = common.fix_moose_header(common.read(os.path.join(MooseDocs.ROOT_DIR,
                                                                           filename)))
                code = core.Code(None, language=lang, code=content)
                floats.create_modal_link(li,
                                         url=filename,
                                         content=code,
                                         title=filename,
                                         string=filename)
        return parent