def createToken(self, parent, info, page): item = TemplateItem(parent, key=self.settings['key']) group = MarkdownReader.INLINE if MarkdownReader.INLINE in info else MarkdownReader.BLOCK kwargs = self.extension.getConfig(page, 'args') content = mooseutils.apply_template_arguments(info[group], **kwargs) if content: self.reader.tokenize(item, content, page, line=info.line, group=group) return parent
def createToken(self, parent, info, page): settings, t_args = common.match_settings(self.defaultSettings(), info['settings']) location = self.translator.findPage(settings['file']) page['dependencies'].add(location.uid) kwargs = self.extension.getConfig(page, 'args') kwargs.update(t_args) content = common.read(location.source) content = mooseutils.apply_template_arguments(content, **kwargs) self.reader.tokenize(parent, content, page, line=info.line) return parent
def init_sqa_report(app, category): """Creates default SQA report configuration file.""" template = os.path.join(os.path.dirname(__file__), 'sqa_reports.yml.template') with open(template, 'r') as fid: content = fid.read() content = mooseutils.apply_template_arguments(content, category=category, app=app) filename = os.path.join(os.getcwd(), 'sqa_reports.yml') _write_file(filename, content)
def init_sqa_config(app, category): """Creates default file to load from MooseDocs configuration.""" template = os.path.join(os.path.dirname(__file__), 'sqa_app.yml.template') with open(template, 'r') as fid: content = fid.read() repo = mooseutils.git_repo(MooseDocs.ROOT_DIR) content = mooseutils.apply_template_arguments(content, repo=repo, category=category, app=app) filename = os.path.join(os.getcwd(), 'sqa_{}.yml'.format(category)) _write_file(filename, content)
def createToken(self, parent, info, page, settings): settings, t_args = common.match_settings(self.defaultSettings(), info['settings']) location = self.translator.findPage(settings['file']) page['dependencies'].add(location.uid) # It is possible to have nested load functions. This ensures that the arguments passed at the # top level over ride the ones lower down if parent.name == 'TemplateContent': kwargs = t_args kwargs.update(parent['kwargs']) else: kwargs = self.extension.getConfig(page, 'args') kwargs.update(t_args) token = TemplateContent(parent, kwargs=kwargs) content = common.read(location.source) content = mooseutils.apply_template_arguments(content, **kwargs) self.reader.tokenize(token, content, page, line=info.line) return parent
def _createStubPage(self, node): """Copy template content to expected document location.""" # Determine the correct markdown filename filename = node['_md_path'] if isinstance(node, moosesyntax.ObjectNodeBase): filename = os.path.join(self.working_dir, node['_md_path']) elif isinstance(node, moosesyntax.SyntaxNode): action = moosetree.find( node, lambda n: isinstance(n, moosesyntax.ActionNode)) filename = os.path.join(self.working_dir, os.path.dirname(node['_md_path']), 'index.md') # Determine the source template tname = None if isinstance(node, moosesyntax.SyntaxNode): tname = 'moose_system.md.template' elif isinstance(node, moosesyntax.MooseObjectNode): tname = 'moose_object.md.template' elif isinstance(node, moosesyntax.ActionNode): tname = 'moose_action.md.template' else: raise Exception("Unexpected syntax node type.") # Template file tname = os.path.join(os.path.dirname(__file__), '..', '..', 'framework', 'doc', 'content', 'templates', 'stubs', tname) # Read template and apply node content with open(tname, 'r') as fid: content = fid.read() content = mooseutils.apply_template_arguments(content, name=node.name, syntax=node.fullpath()) # Write the content to the desired destination self._writeFile(filename, content)