def extractContent(filename, opts=dict()): """Helper for reading contents of a file in order to make assertions.""" settings = common.get_settings_as_dict(common.extractContentSettings()) settings.update(opts) content, _ = common.extractContent(common.read(MOOSE_DIR + '/' + filename), settings) return content
def createToken(self, parent, info, page): """ Build the tokens needed for displaying code listing. """ filename = common.check_filenames(info['subcommand']) flt = floats.create_float(parent, self.extension, self.reader, page, self.settings, token_type=Listing) # Create code token lang = self.settings.get('language') content = self.extractContent(filename) lang = lang if lang else common.get_language(filename) code = core.Code(flt, style="max-height:{};".format( self.settings['max-height']), content=content, language=lang) if flt is parent: code.attributes.update(**self.attributes) if flt is not parent: code.name = 'ListingCode' # Add bottom modal link = self.settings['link'] link = link if link is not None else self.extension['modal-link'] if link: rel_filename = os.path.relpath(filename, MooseDocs.ROOT_DIR) # Get the complete file content = common.read(filename) settings = common.get_settings_as_dict( common.extractContentSettings()) settings['strip-header'] = False content, _ = common.extractContent(content, settings) # Create modal for display the files a popup code = core.Code(None, language=lang, content=content) link = floats.create_modal_link( flt, url=unicode(rel_filename), content=code, title=unicode(filename), string=u'({})'.format(rel_filename)) link.name = 'ListingLink' link['data-tooltip'] = unicode(rel_filename) return parent
def createToken(self, parent, info, page): """ Build the tokens needed for displaying code listing. """ filename = common.check_filenames(info['subcommand']) flt = floats.create_float(parent, self.extension, self.reader, page, self.settings, token_type=Listing) # Create code token lang = self.settings.get('language') content = self.extractContent(filename) lang = lang if lang else common.get_language(filename) code = core.Code(flt, style="max-height:{};".format(self.settings['max-height']), content=content, language=lang) if flt is parent: code.attributes.update(**self.attributes) if flt is not parent: code.name = 'ListingCode' # Add bottom modal link = self.settings['link'] link = link if link is not None else self.extension['modal-link'] if link: rel_filename = os.path.relpath(filename, MooseDocs.ROOT_DIR) # Get the complete file content = common.read(filename) settings = common.get_settings_as_dict(common.extractContentSettings()) settings['strip-header'] = False content, _ = common.extractContent(content, settings) # Create modal for display the files a popup code = core.Code(None, language=lang, content=content) link = floats.create_modal_link(flt, url=unicode(rel_filename), content=code, title=unicode(filename), string=u'({})'.format(rel_filename)) link.name = 'ListingLink' link['data-tooltip'] = unicode(rel_filename) return parent