def createToken(self, info, parent): #TODO: make root path a config item in extension location = os.path.join(MooseDocs.MOOSE_DIR, 'framework', 'doc', 'templates', 'sqa', self.settings['template']) if not os.path.exists(location): msg = "The template file does not exist: {}." raise exceptions.TokenizeException(msg, location) with codecs.open(location, 'r', encoding='utf-8') as fid: content = fid.read() # Replace key/value arguments template_args = info['inline'] if 'inline' in info else info['block'] _, key_values = common.match_settings(dict(), template_args) def sub(match): key = match.group('key') if key not in key_values: msg = "The template argument '{}' was not defined in the !sqa load command." raise exceptions.TokenizeException(msg, key) return key_values[key] content = re.sub(r'{{(?P<key>.*?)}}', sub, content) # Tokenize the template self.translator.reader.parse(parent, content) return parent
def createToken(self, info, parent): #TODO: make root path a config item in extension location = os.path.join(MooseDocs.ROOT_DIR, 'framework', 'doc', 'templates', 'sqa', self.settings['template']) if not os.path.exists(location): msg = "The template file does not exist: {}." raise exceptions.TokenizeException(msg, location) with codecs.open(location, 'r', encoding='utf-8') as fid: content = fid.read() # Replace key/value arguments template_args = info['inline'] if 'inline' in info else info['block'] _, key_values = common.match_settings(dict(), template_args) def sub(match): key = match.group('key') if key not in key_values: msg = "The template argument '{}' was not defined in the !sqa load command." raise exceptions.TokenizeException(msg, key) return key_values[key] content = re.sub(r'{{(?P<key>.*?)}}', sub, content) # Tokenize the template self.translator.reader.parse(parent, content) return parent
def postRead(self, content, page, meta): """Updates configuration items.""" if content: for match in command.BlockInlineCommand.RE.finditer(content): if match.group('command') == 'config': subcommand = match.group('subcommand') _, settings = common.match_settings(dict(), match.group('settings')) self.__configurations[page.uid][subcommand] = settings
def postRead(self, content, page, meta): """Updates configuration items.""" if content: for match in command.BlockInlineCommand.RE.finditer(content): if match.group('command') == 'config': subcommand = match.group('subcommand') _, settings = common.match_settings( dict(), match.group('settings')) self.__configurations[page.uid][subcommand] = settings
def createToken(self, parent, info, page): settings, t_args = common.match_settings(self.defaultSettings(), info['settings']) location = self.translator.findPage(settings['file']) self.extension.addDependency(location) content = common.read(location.source) content = self.extension.applyTemplateArguments(content, **t_args) self.reader.tokenize(parent, content, page, line=info.line) return parent
def createToken(self, parent, info, page): settings, template_args = common.match_settings( self.defaultSettings(), info['settings']) location = self.translator.findPage(settings['file']) self.extension.addDependency(location) with codecs.open(location.source, 'r', encoding='utf-8') as fid: content = fid.read() def sub(match): key = match.group('key') arg = template_args.get(key, None) if key is None: msg = "The template argument '{}' was not defined in the !sqa load command." raise exceptions.MooseDocsException(msg, key) return arg content = re.sub(r'{{(?P<key>.*?)}}', sub, content) self.reader.tokenize(parent, content, page, line=info.line) return parent
def createToken(self, info, parent): defaults = self.translator.renderer.getConfig() known, _ = common.match_settings(defaults, info['settings']) self.extension.local_config = known return parent
def createToken(self, info, parent): defaults = self.translator.renderer.getConfig() known, _ = common.match_settings(defaults, info['settings']) self.extension.local_config = known return parent