Пример #1
0
    def createMaterialize(self, token, parent):

        key = token.key

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

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

        elif token.use_default:
            for child in token.children:
                self.translator.renderer.process(parent, child)

        else:
            err = alert.AlertToken(
                token.parent,
                brand='error',
                title=u'Missing Template Item "{}"'.format(key))

            filename = token.root.page.source
            self.translator.reader.parse(err,
                                         ERROR_CONTENT.format(key, filename))

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

            self.translator.renderer.process(parent, err)
Пример #2
0
    def _createFieldError(self, parent, token, page, modal_flag):
        """Helper for creating error alert."""

        filename = page.local
        key = token['key']
        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')
        token.copyToToken(alert_content)

        if modal_flag:
            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,
                      content=u"!template! item key={0}\nInclude text (in MooseDocs format) " \
                      u"regarding the \"{0}\" template item here.\n" \
                      u"!template-end!".format(key))

            link = floats.create_modal_link(alert_title,
                                            title=u'Missing Template Item "{}"'.format(key),
                                            content=modal_content)
            materialicon.Icon(link, icon=u'help_outline',
                              class_='small',
                              style='float:right;color:white;margin-bottom:5px;')

        self.renderer.render(parent, err, page)
Пример #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)
Пример #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)
Пример #5
0
 def testAlertToken(self):
     token = alert.AlertToken(brand=u'warning')
     self.assertEqual(token.brand, u'warning')