Esempio n. 1
0
    def _addList(self, parent, obj, actions, group, level):

        for child in obj.syntax(group=group):
            if child.removed:
                continue

            h = tokens.Heading(parent,
                               level=level,
                               string=unicode(child.fullpath.strip('/')))

            # TODO: systems prefix is needed to be unique, there must be a better way
            url = os.path.join('systems', child.markdown())
            a = autolink.AutoLink(h, url=url)
            materialicon.IconToken(a,
                                   icon=u'input',
                                   style="padding-left:10px;")

            SyntaxToken(parent,
                        syntax=child,
                        actions=actions,
                        objects=True,
                        subsystems=False,
                        groups=[group] if group else [],
                        level=level)
            self._addList(parent, child, actions, group, level + 1)
Esempio n. 2
0
    def createToken(self, info, parent):
        col = ColumnToken(parent,
                          width=self.settings['width'],
                          **self.attributes)

        icon = self.settings.get('icon', None)
        if icon:
            block = materialicon.IconBlockToken(col)
            h = tokens.Heading(block, level=2, class_='center brown-text')
            materialicon.IconToken(h, icon=unicode(icon))
            return block

        return col
Esempio n. 3
0
    def createMaterialize(self, parent, token, page):

        key = token.key
        func = lambda n: isinstance(n, SQADocumentItem) and (n.key == key)
        replacement = anytree.search.find(token.root, filter_=func, maxlevel=2)

        if replacement:

            self.renderer.render(parent, replacement, page)

            # Remove item so it doesn't render again
            replacement.parent = None
            for child in replacement:
                child.parent = None


#
        else:
            filename = page.local
            err = alert.AlertToken(None, brand=u'error')
            alert_title = alert.AlertTitle(
                err,
                brand=u'error',
                string=u'Missing Template Item "{}"'.format(key))
            alert_content = alert.AlertContent(err, brand=u'error')

            modal_content = tokens.Token(None)
            core.Paragraph(modal_content,
                           string=u"The document must include the \"{0}\" template item, this can "\
                           u"be included by add adding the following to the markdown " \
                           u"file ({1}):".format(key, filename))

            core.Code(modal_content,
                      code=u"!sqa! item key={0}\nInclude text (in MooseDocs format) " \
                      u"regarding the \"{0}\" template item here.\n" \
                      u"!sqa-end!".format(key))

            link = floats.create_modal_link(
                alert_title,
                title=u'Missing Template Item "{}"'.format(key),
                content=modal_content)
            materialicon.IconToken(link,
                                   icon=u'help_outline',
                                   class_=u'material-icons moose-help')

            for child in token.children:
                child.parent = alert_content

            self.renderer.render(parent, err, page)
Esempio n. 4
0
    def createMaterialize(self, token, parent):

        key = token.key
        func = lambda n: isinstance(n, SQADocumentItem) and (n.key == key)
        replacement = anytree.search.find(token.root, filter_=func, maxlevel=2)

        if replacement:

            if token.heading is not None:
                self.translator.renderer.process(parent, token.heading)

            self.translator.renderer.process(parent, replacement)

            # Remove item so it doesn't render again
            replacement.parent = None
            for child in replacement:
                child.parent = None


#
        else:
            filename = self.translator.current.local

            content = tokens.Token(None)
            self.translator.reader.parse(content,
                                         ERROR_CONTENT.format(key, filename))

            modal_title = tokens.String(
                None, content=u'Missing Template Item "{}"'.format(key))

            alert_title = tokens.Token(None)
            tokens.String(alert_title,
                          content=u'Missing Template Item "{}"'.format(key))
            h_token = floats.ModalLink(alert_title,
                                       url=unicode(filename),
                                       content=content,
                                       title=modal_title,
                                       class_='moose-help')
            materialicon.IconToken(h_token, icon=u'help_outline')

            err = alert.AlertToken(token.parent,
                                   brand=u'error',
                                   title=alert_title)
            for child in token.children:
                child.parent = err

            self.translator.renderer.process(parent, err)