Example #1
0
    def _addRequirement(self, parent, req):
        item = SQARequirementMatrixItem(parent,
                                        label=unicode(req.label),
                                        satisfied=req.satisfied,
                                        id_=req.path)
        self.translator.reader.parse(item, req.text)

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

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

        p = tokens.Paragraph(item, 'p')
        tokens.String(p, content=u'Details: ')
        filename = u'{}/{}.md'.format(req.path, req.name)
        autolink.AutoShortcutLink(p, key=unicode(filename))
Example #2
0
    def _addRequirement(self, parent, req):
        item = SQARequirementMatrixItem(parent, label=unicode(req.label), id_=req.path)
        self.translator.reader.parse(item, req.text)

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

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

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

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

            if self.settings['link-issues'] and req.issues:
                p = tokens.Paragraph(item, 'p')
                tokens.String(p, content=u'Issues: ')
                for issue in req.issues:
                    url = u"https://github.com/idaholab/moose/issues/{}".format(issue[1:])
                    tokens.Link(p, url=url, string=unicode(issue))
Example #3
0
    def _addRequirement(self, parent, req, requirements):
        item = SQARequirementMatrixItem(parent,
                                        label=unicode(req.label),
                                        satisfied=req.satisfied,
                                        id_=req.path)
        self.translator.reader.parse(item, req.text)

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

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

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

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

            if self.settings['link-issues'] and req.issues:
                p = tokens.Paragraph(item, 'p')
                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:])
                    tokens.Link(p, url=url, string=unicode(issue))
                    tokens.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 = tokens.Paragraph(item, 'p')
                tokens.String(p,
                              content=u'Prerequisites: {}'.format(
                                  ' '.join(labels)))
Example #4
0
    def createTokenFromSyntax(self, info, parent, obj):

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

        else:
            p = tokens.Paragraph(parent)
            self.translator.reader.parse(p, unicode(obj.description), group=MooseDocs.INLINE)
            return parent
Example #5
0
    def createToken(self, info, parent):
        matrix = SQARequirementMatrix(parent)
        for req in self.extension.requirements:
            item = SQARequirementMatrixItem(matrix)
            self.translator.reader.parse(item, unicode(req.requirement))

            #TODO: Make option
            p = tokens.Paragraph(item, 'p')
            tokens.String(p, content=u'Specification: ')

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

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

            #TODO: Make option
            if req.design:
                p = tokens.Paragraph(item, 'p')
                tokens.String(p, content=u'Design: ')
                for design in req.design.split():
                    autolink.AutoShortcutLink(p, key=unicode(design))

            #TODO: Make option
            if req.issues:
                p = tokens.Paragraph(item, 'p')
                tokens.String(p, content=u'Issues: ')
                for issue in req.issues.split():
                    url = u"https://github.com/idaholab/moose/issues/{}".format(
                        issue[1:])
                    tokens.Link(p, url=url, string=unicode(issue))

        return parent
Example #6
0
 def testReinit(self):
     ast = tokens.Paragraph(None)
     comp = ParComponent()
     content = page.PageNodeBase(None)
     renderer = renderers.HTMLRenderer()
     translator = Translator(content, MarkdownReader(), renderer, [])
     translator.init('')
     renderer.add(tokens.Paragraph, comp)
     renderer.render(ast)
     renderer.render(ast)
     self.assertEqual(comp.count, 2)
Example #7
0
    def testErrors(self):
        renderer = renderers.Renderer()

        with self.assertRaises(exceptions.MooseDocsException) as e:
            renderer.add(tokens.Paragraph(), ParComponent())
        self.assertIn("The argument 'token'", e.exception.message)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            renderer.add(tokens.Paragraph, 'WRONG')
        self.assertIn("The argument 'component'", e.exception.message)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            renderer.add(tokens.Paragraph, ParComponent())
        self.assertIn("The Reader class of type", e.exception.message)
Example #8
0
    def testProcess(self):
        ast = tokens.Paragraph(None)
        tokens.String(ast, content=u'foo')

        renderer = renderers.HTMLRenderer()
        renderer.add(tokens.Paragraph, ParComponent())
        renderer.add(tokens.String, StringComponent())

        root = html.Tag(None, 'div')
        renderer.process(root, ast)

        self.assertIsInstance(root(0), html.Tag)
        self.assertEqual(root(0).name, 'p')
        self.assertIsInstance(root(0)(0), html.String)
        self.assertEqual(root(0)(0).content, u'foo')
Example #9
0
    def testRender(self):
        ast = tokens.Paragraph(None)
        tokens.String(ast, content=u'foo')
        content = page.PageNodeBase(None)
        renderer = renderers.HTMLRenderer()
        translator = Translator(content, MarkdownReader(), renderer, [])
        translator.init('')

        renderer.add(tokens.Paragraph, ParComponent())
        renderer.add(tokens.String, StringComponent())

        root = renderer.render(ast)
        self.assertIsInstance(root, html.Tag)
        self.assertEqual(root.name, 'body')
        self.assertIsInstance(root(0), html.Tag)
        self.assertEqual(root(0).name, 'p')
        self.assertIsInstance(root(0)(0), html.String)
        self.assertEqual(root(0)(0).content, u'foo')
Example #10
0
 def createToken(self, info, parent):  #pylint: disable=unused-argument
     return tokens.Paragraph(parent)
Example #11
0
 def testParagraph(self):
     tokens.Paragraph()