def createTokenHelper(key, parent, info, page, use_key_in_modal=False): match = PAGE_LINK_RE.search(info[key]) bookmark = match.group('bookmark')[1:] if match.group('bookmark') else u'' filename = match.group('filename') # The link is local (i.e., [#foo]), the heading will be gathered on render because it # could be after the current position. if (filename is None) and (bookmark != u''): return LocalLink(parent, bookmark=bookmark) elif filename is not None: return AutoLink(parent, page=filename, bookmark=bookmark) else: source = common.project_find(info[key]) if len(source) == 1: src = unicode(source[0]) content = common.fix_moose_header( common.read(os.path.join(MooseDocs.ROOT_DIR, src))) code = core.Code(None, language=common.get_language(src), content=content) local = src.replace(MooseDocs.ROOT_DIR, '') link = floats.create_modal_link(parent, content=code, title=local) if use_key_in_modal: tokens.String(link, content=os.path.basename(info[key])) return link return None
def createTokenHelper(key, parent, info, page, use_key_in_modal=False): match = PAGE_LINK_RE.search(info[key]) bookmark = match.group('bookmark')[1:] if match.group('bookmark') else u'' filename = match.group('filename') # The link is local (i.e., [#foo]), the heading will be gathered on render because it # could be after the current position. if (filename is None) and (bookmark != u''): return LocalLink(parent, bookmark=bookmark) elif filename is not None: return AutoLink(parent, page=filename, bookmark=bookmark) else: source = common.project_find(info[key]) if len(source) == 1: src = unicode(source[0]) content = common.fix_moose_header(common.read(os.path.join(MooseDocs.ROOT_DIR, src))) code = core.Code(None, language=common.get_language(src), content=content) local = src.replace(MooseDocs.ROOT_DIR, '') link = floats.create_modal_link(parent, content=code, title=local) if use_key_in_modal: tokens.String(link, content=os.path.basename(info[key])) return link return None
def createTokenFromSyntax(self, parent, info, page, obj): item = self.extension.database.get(obj.name, None) attr = getattr(item, self.SUBCOMMAND, None) if item and attr: self.createHeading(parent, page) ul = core.UnorderedList(parent, class_='moose-list-{}'.format(self.SUBCOMMAND)) for filename in attr: filename = unicode(filename) li = core.ListItem(ul) lang = common.get_language(filename) content = common.fix_moose_header(common.read(os.path.join(MooseDocs.ROOT_DIR, filename))) code = core.Code(None, language=lang, code=content) floats.create_modal_link(li, url=filename, content=code, title=filename, string=filename) return parent