Example #1
0
    def testSpace(self):
        token = tokens.Space()
        self.assertEqual(token.content, ' ')
        self.assertEqual(token.count, 1)
        self.assertEqual(token.recursive, True) # tests token inheritance

        token = tokens.Space(count=42)
        self.assertEqual(token.content, ' ')
        self.assertEqual(token.count, 42)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            token = tokens.Space(count='not int')
        gold = "The supplied property 'count' must be of type 'int', but 'str' was provided."
        self.assertEqual(e.exception.message, gold)
Example #2
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 #3
0
    def testBreak(self):
        token = tokens.Break()
        self.assertEqual(token.content, '\n')
        self.assertEqual(token.count, 1)

        token = tokens.Break(count=42)
        self.assertEqual(token.content, '\n')
        self.assertEqual(token.count, 42)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            token = tokens.Space(count='not int')
        gold = "The supplied property 'count' must be of type 'int', but 'str' was provided."
        self.assertEqual(e.exception.message, gold)
Example #4
0
 def createToken(self, info, parent):
     tokens.Space(parent, count=len(info['space']))
     return parent