def testLink(self): with self.assertRaises(exceptions.MooseDocsException) as e: token = tokens.Link() self.assertIn("The property 'url' is required.", e.exception.message) token = tokens.Link(url=u'foo') self.assertEqual(token.url, 'foo') token.url = u'bar' self.assertEqual(token.url, 'bar') with self.assertRaises(exceptions.MooseDocsException) as e: token.url = 42 gold = "The supplied property 'url' must be of type 'unicode', but 'int' was provided." self.assertEqual(e.exception.message, gold)
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))
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)))
def createToken(self, info, parent): arch = self.settings['arch'] packages = self.extension.get('moose_packages', dict()) if arch not in packages: msg = "The supplied value for the 'arch' settings, {}, was not found." raise exceptions.TokenizeException(msg, arch) href = os.path.join(self.extension.get('link'), packages[arch]) tokens.Link(parent, url=unicode(href), string=unicode(packages[arch])) return parent
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
def createToken(self, info, parent): return tokens.Link(parent, url=info['url'], **self.attributes)