Ejemplo n.º 1
0
    def _addRequirement(self, parent, info, page, req):
        item = SQARequirementMatrixItem(parent, requirement=req)
        self.reader.tokenize(item,
                             req.text,
                             page,
                             MooseDocs.INLINE,
                             info.line,
                             report=False)
        for token in anytree.PreOrderIter(item):
            if token.name == 'ErrorToken':
                msg = common.report_error(
                    "Failed to tokenize SQA requirement.", req.filename,
                    req.text_line, req.text, token['traceback'],
                    u'SQA TOKENIZE ERROR')
                LOG.critical(msg)

        p = core.Paragraph(item)
        tokens.String(p, content=u'Specification: ')

        with codecs.open(req.filename, encoding='utf-8') as fid:
            content = fid.read()
            floats.create_modal_link(p,
                                     string=u"{}:{}".format(
                                         req.path, req.name),
                                     content=core.Code(None,
                                                       language=u'text',
                                                       content=content),
                                     title=unicode(req.filename))

        p = core.Paragraph(item)
        tokens.String(p, content=u'Details: ')
        filename = u'{}/{}.md'.format(req.path, req.name)
        autolink.AutoLink(p, page=unicode(filename))
Ejemplo n.º 2
0
    def _addRequirement(self, parent, info, page, req):
        reqname = "{}:{}".format(req.path, req.name) if req.path != '.' else req.name
        item = SQARequirementMatrixItem(parent, label=req.label, reqname=reqname)
        self.reader.tokenize(item, req.text, page, MooseDocs.INLINE, info.line, report=False)
        for token in anytree.PreOrderIter(item):
            if token.name == 'ErrorToken':
                msg = common.report_error("Failed to tokenize SQA requirement.",
                                          req.filename,
                                          req.text_line,
                                          req.text,
                                          token['traceback'],
                                          'SQA TOKENIZE ERROR')
                LOG.critical(msg)

        p = core.Paragraph(item)
        tokens.String(p, content='Specification: ')

        content = common.read(req.filename)
        floats.create_modal_link(p,
                                 string=reqname,
                                 content=core.Code(None, language='text', content=content),
                                 title=str(req.filename))

        p = core.Paragraph(item)
        tokens.String(p, content='Documentation: ')
        filename = getattr(req, info['subcommand'])
        autolink.AutoLink(p, page=str(filename))
Ejemplo n.º 3
0
    def _addRequirement(self, parent, info, page, req, requirements):
        item = SQARequirementMatrixItem(parent,
                                        label=unicode(req.label),
                                        satisfied=req.satisfied,
                                        id_=req.path)
        self.reader.tokenize(item, req.text, page)

        if self.settings['link']:
            if self.settings['link-spec']:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Specification: ')

                with codecs.open(req.filename, encoding='utf-8') as fid:
                    content = fid.read()

                floats.create_modal_link(
                    p,
                    url=u"#",
                    title=tokens.String(None, content=unicode(req.filename)),
                    content=core.Code(None, language=u'text', code=content),
                    string=u"{}:{}".format(req.path, req.name),
                    tooltip=False)

            if self.settings['link-design'] and req.design:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Design: ')
                for design in req.design:
                    autolink.AutoLink(p, page=unicode(design))

            if self.settings['link-issues'] and req.issues:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Issues: ')
                for issue in req.issues:
                    if issue.startswith('#'):
                        url = u"https://github.com/idaholab/moose/issues/{}".format(
                            issue[1:])
                    else:
                        url = u"https://github.com/idaholab/moose/commit/{}".format(
                            issue[1:])
                    core.Link(p, url=url, string=unicode(issue))
                    core.Space(p)

            if self.settings['link-prerequisites'] and req.prerequisites:
                labels = []
                for prereq in req.prerequisites:
                    for other in requirements:
                        if other.name == prereq:
                            labels.append(other.label)

                p = core.Paragraph(item)
                tokens.String(p,
                              content=u'Prerequisites: {}'.format(
                                  ' '.join(labels)))
Ejemplo n.º 4
0
    def createTokenFromSyntax(self, parent, info, page, obj):

        if obj.description is None:
            msg = "The class description is missing for %s, it can be added using the " \
                  "'addClassDescription' method from within the objects validParams function."
            if not obj.hidden:
                LOG.warning(msg, obj.fullpath)
            core.Paragraph(parent, string=unicode(info[0]), class_='moose-error')
            return parent

        else:
            p = core.Paragraph(parent)
            self.reader.tokenize(p, unicode(obj.description), page, MooseDocs.INLINE)
            return parent
Ejemplo n.º 5
0
 def createToken(self, parent, info, page):
     if info.pattern not in ('InlineCommand', 'OldInlineCommand',
                             'OlderInlineCommand'):
         core.Paragraph(parent)
     return Icon(parent,
                 icon=info['subcommand'],
                 faicon=self.settings['faicon'])
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
    def _addRequirement(self, parent, info, page, req):
        item = SQARequirementMatrixItem(parent,
                                        label=unicode(req.label),
                                        satisfied=req.satisfied,
                                        id_=req.path)
        self.reader.tokenize(item, req.text, page, line=info.line)

        p = core.Paragraph(item)
        tokens.String(p, content=u'Specification: ')

        with codecs.open(req.filename, encoding='utf-8') as fid:
            content = fid.read()
            floats.create_modal_link(
                p,
                tooltip=False,
                url=u"#",
                string=u"{}:{}".format(req.path, req.name),
                title=tokens.String(None, content=unicode(req.filename)),
                content=core.Code(None, language=u'text', code=content))

        p = core.Paragraph(item)
        tokens.String(p, content=u'Details: ')
        filename = u'{}/{}.md'.format(req.path, req.name)
        autolink.AutoLink(p, page=unicode(filename))
Ejemplo n.º 9
0
    def _addRequirement(self, parent, info, page, req, requirements):
        item = SQARequirementMatrixItem(parent,
                                        label=unicode(req.label),
                                        satisfied=req.satisfied,
                                        id_=req.path)

        self.reader.tokenize(item,
                             req.text,
                             page,
                             MooseDocs.INLINE,
                             info.line,
                             report=False)
        for token in anytree.PreOrderIter(item):
            if token.name == 'ErrorToken':
                msg = common.report_error(
                    "Failed to tokenize SQA requirement.", req.filename,
                    req.text_line, req.text, token['traceback'],
                    u'SQA TOKENIZE ERROR')
                LOG.critical(msg)

        if self.settings['link']:
            if self.settings['link-spec']:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Specification: ')

                with codecs.open(req.filename, encoding='utf-8') as fid:
                    content = fid.read()

                floats.create_modal_link(p,
                                         title=req.filename,
                                         content=core.Code(None,
                                                           language=u'text',
                                                           content=content),
                                         string=u"{}:{}".format(
                                             req.path, req.name))

            if self.settings['link-design'] and req.design:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Design: ')
                for design in req.design:
                    autolink.AutoLink(p, page=unicode(design))

            if self.settings['link-issues'] and req.issues:
                p = core.Paragraph(item)
                tokens.String(p, content=u'Issue(s): ')
                for issue in req.issues:
                    if issue.startswith('#'):
                        url = u"https://github.com/idaholab/moose/issues/{}".format(
                            issue[1:])
                    else:
                        url = u"https://github.com/idaholab/moose/commit/{}".format(
                            issue[1:])
                    core.Link(p, url=url, string=unicode(issue))
                    core.Space(p)

            if self.settings['link-prerequisites'] and req.prerequisites:
                labels = []
                for prereq in req.prerequisites:
                    for other in requirements:
                        if other.name == prereq:
                            labels.append(other.label)

                p = core.Paragraph(item)
                tokens.String(p,
                              content=u'Prerequisites: {}'.format(
                                  ' '.join(labels)))