当前位置: 首页>>代码示例>>Python>>正文


Python MooseDocs.yaml_load方法代码示例

本文整理汇总了Python中MooseDocs.yaml_load方法的典型用法代码示例。如果您正苦于以下问题:Python MooseDocs.yaml_load方法的具体用法?Python MooseDocs.yaml_load怎么用?Python MooseDocs.yaml_load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MooseDocs的用法示例。


在下文中一共展示了MooseDocs.yaml_load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_html

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
def generate_html(input, config_file):
  """
  Generates html from Moose flavored markdown.

  Args:
    input[str]: The *.md file to convert.
    config_file[str]: The *.yml configuration file.
  """
  # Load the config to extract MooseMarkdown settings
  #TODO: Make this more robust
  config = MooseDocs.yaml_load(config_file)
  md_config = config['markdown_extensions'][-1]['MooseDocs.extensions.MooseMarkdown']
  md_config['dot_ext'] = 'svg'

  # Convert markdown
  with open(input, 'r') as fid:
    md = fid.read()

  # Extract Jinja2 blocks
  settings = dict()
  def sub(match):
    settings[match.group(1).strip()] = eval(match.group(2))
    return ''
  md = re.sub(r'@\+\s*set\s+(.*?)=(.*?)\[email protected]', sub, md)

  moose = MooseDocs.extensions.MooseMarkdown(**md_config)
  parser = markdown.Markdown(extensions=[moose, 'markdown_include.include', 'admonition', 'mdx_math', 'toc', 'extra'])
  return parser.convert(md), settings
开发者ID:gnsteve,项目名称:moose,代码行数:30,代码来源:latex.py

示例2: generate

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
def generate(config_file='moosedocs.yml', pages='pages.yml', stubs=False, pages_stubs=False, **kwargs):
  """
  Generates MOOSE system and object markdown files from the source code.

  Args:
    config_file[str]: (Default: 'moosedocs.yml') The MooseMkDocs project configuration file.
  """

  # Configuration file
  if not os.path.exists(config_file):
    raise IOError("The supplied configuration file was not found: {}".format(config_file))

  # Read the configuration
  config = MooseDocs.yaml_load(config_file)
  config = config['markdown_extensions'][-1]['MooseDocs.extensions.MooseMarkdown']

  # Run the executable
  exe = config['executable']
  if not os.path.exists(exe):
    log.error('The executable does not exist: {}'.format(exe))
  else:
    log.debug("Executing {} to extract syntax.".format(exe))
    raw = utils.runExe(exe, '--yaml')
    yaml = utils.MooseYaml(raw)

  # Populate the syntax
  for key, value in config['locations'].iteritems():
    if 'hide' in value:
      value['hide'] += config.get('hide', [])
    else:
      value['hide'] = config.get('hide', [])
    syntax = MooseDocs.MooseApplicationSyntax(yaml, name=key, stubs=stubs,  pages_stubs=pages_stubs, pages=pages, **value)
    log.info("Checking documentation for '{}'.".format(key))
    syntax.check()
开发者ID:gnsteve,项目名称:moose,代码行数:36,代码来源:generate.py

示例3: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def __init__(self, markdown_instance=None, **kwargs):
        MooseMarkdownCommon.__init__(self, **kwargs)
        Preprocessor.__init__(self, markdown_instance)

        # Import the directly defined globals
        self._globals = kwargs.pop('globals', dict())

        # Add the defined globals from the supplied file(s)
        for filename in kwargs.pop('import'):
            self._globals.update(MooseDocs.yaml_load(os.path.join(MooseDocs.ROOT_DIR, filename)))
开发者ID:aeslaughter,项目名称:moose,代码行数:12,代码来源:global.py

示例4: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
  def __init__(self, markdown_instance=None, **kwargs):
    MooseCommonExtension.__init__(self, **kwargs)
    Pattern.__init__(self, self.RE, markdown_instance)

    # Load the yaml data containing package information
    self.package = MooseDocs.yaml_load("packages.yml")

    # The default settings
    self._settings = {'arch' : None,
             'return' : None}
开发者ID:gnsteve,项目名称:moose,代码行数:12,代码来源:MoosePackageParser.py

示例5: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def __init__(self, content=None, **kwargs):
        super(WebsiteBuilder, self).__init__(**kwargs)
        if (content is None) or (not os.path.isfile(content)):
            LOG.info("Using default content directory configuration "
                     "(i.e., --content does not include a valid filename).")
            content = dict(default=dict(base=os.path.join(os.getcwd(), 'content'),
                                        include=[os.path.join(os.getcwd(), 'content', '*')]))
        else:
            content = MooseDocs.yaml_load(content)

        self._content = content
开发者ID:aeslaughter,项目名称:moose,代码行数:13,代码来源:build.py

示例6: setUpClass

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def setUpClass(cls):
        """
    Create the markdown parser using the 'moosedocs.yml' configuration file.
    """

        cwd = os.getcwd()
        os.chdir(os.path.join(MooseDocs.MOOSE_DIR, "docs"))

        config = MooseDocs.yaml_load("moosedocs.yml")

        extensions, extension_configs = MooseDocs.commands.get_markdown_extensions(config)
        cls.parser = markdown.Markdown(extensions=extensions, extension_configs=extension_configs)
        os.chdir(cwd)
开发者ID:jwpeterson,项目名称:moose,代码行数:15,代码来源:testing.py

示例7: build

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
def build(config_file='moosedocs.yml', disable_threads=False, **kwargs):
  """
  The main build command.
  """

  # Load the YAML configuration file
  config = MooseDocs.yaml_load(config_file)
  config.update(kwargs)

  # Set the default arguments
  config.setdefault('docs_dir', os.getcwd())
  config.setdefault('site_dir', os.path.join('..', 'site'))
  config.setdefault('pages', 'pages.yml')
  config.setdefault('template', 'materialize.html')
  config.setdefault('template_arguments', dict())
  config.setdefault('extra_pages', [])

  # Load the site map
  sitemap = MooseDocs.yaml_load(config['pages'])

  # Create the markdown parser
  extensions, extension_configs = get_markdown_extensions(config)
  parser = markdown.Markdown(extensions=extensions, extension_configs=extension_configs)

  # Create object for storing pages to be generated
  builder = Builder(sitemap, parser, config['site_dir'], config['template'], **config['template_arguments'])

  # Build "extra" pages (i.e., the home page)
  if 'extra_pages' in config:
    for extra in config['extra_pages']:
      for name, kwargs in extra.iteritems():
        kwargs.setdefault('template_arguments', dict())
        builder.add(kwargs.pop('filename'), kwargs['template'], name=name, **kwargs['template_arguments'])

  # Create the html
  builder.build(use_threads=not disable_threads)
  return config, parser, builder
开发者ID:gnsteve,项目名称:moose,代码行数:39,代码来源:build.py

示例8: _configure

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def _configure(self):
        """
        Build the configuration options for included sub-directories.
        """

        # Read the moosedocs yml configuration file
        yml = MooseDocs.yaml_load(self._config_file)

        # Default settings
        defaults = yml.get('defaults', dict())
        defaults.setdefault('details', os.path.join(os.getcwd(), 'details'))
        defaults.setdefault('source', None)
        defaults.setdefault('install', os.path.join(os.getcwd(), 'content'))
        defaults.setdefault('repo', None)
        defaults.setdefault('doxygen', None)
        defaults.setdefault('hide', list())
        defaults.setdefault('links', dict())

        def update_config(config):
            """
            Helper for updating/creating local configuration dict.
            """

            # Apply defaults
            for key, value in defaults.iteritems():
                config.setdefault(key, value)

            # Append the hide data
            config['hide'] = set(config.get('hide', list()) + list(defaults['hide']))

            return config

        # Extract executable
        if 'app' not in yml:
            self._exe = utils.find_moose_executable(self._root)
        else:
            app = yml['app']
            if os.path.isdir(app):
                self._exe = utils.find_moose_executable(app)
            else:
                self._exe = app

        configs = []
        if 'include' in yml:
            for key, value in yml['include'].iteritems():
                log.debug('Configuring settings for including {}'.format(key))
                configs.append(update_config(value))
        return configs
开发者ID:Liuux,项目名称:moose,代码行数:50,代码来源:MooseApplicationDocGenerator.py

示例9: testContentFile

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def testContentFile(self):
        config = MooseDocs.yaml_load(os.path.join(MooseDocs.ROOT_DIR, 'docs', 'content.yml'))
        root = common.moose_docs_file_tree(config)

        node = self.finder(root, 'media/gitlab-logo.png')[0]
        self.assertEqual(node.filename, os.path.join(MooseDocs.ROOT_DIR, 'docs', 'content', 'media',
                                                     'gitlab-logo.png'))

        node0 = MooseMarkdown.find(root, 'utilities/moose_docs/index.md')[0]
        self.assertIsNotNone(node0)

        node1 = MooseMarkdown.find(root, 'utilities/moose_docs/moose_markdown/index.md')
        self.assertIsNotNone(node1)

        node2 = MooseMarkdown.find(root,
                                   'utilities/moose_docs/moose_markdown/extensions/include.md')
        self.assertIsNotNone(node2)
开发者ID:zachmprince,项目名称:moose,代码行数:19,代码来源:test_file_tree.py

示例10: _generate

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def _generate(self):
        """
        Generate the documentation.
        """

        # Setup the location
        log.info('Generating Documentation: {}'.format(self._config_file))

        # Parse the configuration file for the desired paths
        configs = self._configure()

        # Locate and run the MOOSE executable
        raw = utils.runExe(self._exe, '--yaml')
        ydata = utils.MooseYaml(raw)

        for config in configs:
            generator = MooseSubApplicationDocGenerator(ydata, config)
            generator.write()

        # Create the mkdocs.yml file
        # TODO: When mkdocs plugins API is up and running this should go away.

        def dumptree(node, level=0):
            for item in node:
                for key, value in item.iteritems():
                    if isinstance(value, list):
                        yield '{}- {}:'.format(' '*4*level, key)
                        for f in dumptree(value, level+1):
                            yield f
                    else:
                        yield '{}- {}: {}'.format(' '*4*(level), key, value)

        pages = MooseDocs.yaml_load('pages.yml')
        output = ['pages:']
        output += dumptree(pages, 1)
        shutil.copyfile('mkdocs.template.yml', 'mkdocs.yml')
        with open('mkdocs.yml', 'a') as fid:
            fid.write('\n'.join(output))
开发者ID:mll36,项目名称:moose,代码行数:40,代码来源:MooseApplicationDocGenerator.py

示例11: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
 def __init__(self, pages):
   self.pages = MooseDocs.yaml_load(pages)
   self.raw = yaml.dump(self.pages, default_flow_style=False)
开发者ID:gnsteve,项目名称:moose,代码行数:5,代码来源:MooseApplicationSyntax.py

示例12: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def __init__(self, markdown_instance=None, **kwargs):
        MooseMarkdownCommon.__init__(self, **kwargs)
        Pattern.__init__(self, self.RE, markdown_instance)

        # Load the yaml data containing package information
        self.package = MooseDocs.yaml_load(kwargs.pop('package_file'))
开发者ID:mangerij,项目名称:moose,代码行数:8,代码来源:devel.py

示例13: extendMarkdown

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import yaml_load [as 别名]
    def extendMarkdown(self, md, md_globals):
        """
        Builds the extensions for MOOSE flavored markdown.
        """

        # Strip description from config
        config = self.getConfigs()

        # Generate YAML data from application
        global cache
        exe = config['executable']
        if exe != cache['exe']:
            if not os.path.exists(exe):
                log.error('The executable does not exist: {}'.format(exe))
            else:
                log.debug("Executing {} to extract syntax.".format(exe))
                raw = utils.runExe(exe, '--yaml')
                cache['exe'] = exe
                cache['yaml'] = utils.MooseYaml(raw)

        # Populate the database for input file and children objects
        if not cache['input_files']:
            log.info('Building input and inheritance databases...')
            for key, path in config['links'].iteritems():
                cache['input_files'][key] =  MooseDocs.database.Database('.i', path, MooseDocs.database.items.InputFileItem, repo=config['repo'])
                cache['child_objects'][key] = MooseDocs.database.Database('.h', path, MooseDocs.database.items.ChildClassItem, repo=config['repo'])

        # Populate the syntax
        if not cache['syntax']:
            for key, value in config['locations'].iteritems():
                cache['syntax'][key] = MooseDocs.MooseApplicationSyntax(cache['yaml'], **value)

        # Populate the pages yaml
        if not cache['pages']:
            yml = MooseDocs.yaml_load(config['pages'])
            for match in re.finditer(r':(.*?\.md)', yaml.dump(yml, default_flow_style=False)):
                cache['pages'].append(match.group(1).strip())

        # Preprocessors
        md.preprocessors.add('moose_bibtex', MooseBibtex(markdown_instance=md, root=config['root']), '_end')
        md.preprocessors.add('moose_auto_link', MooseMarkdownLinkPreprocessor(markdown_instance=md, pages=cache['pages']), '_begin')
        if config['slides']:
            md.preprocessors.add('moose_slides', MooseSlidePreprocessor(markdown_instance=md), '_end')

        # Block processors
        md.parser.blockprocessors.add('diagrams', MooseDiagram(md.parser, graphviz=config['graphviz']), '_begin')
        md.parser.blockprocessors.add('slideshow', MooseCarousel(md.parser, root=config['root']), '_begin')
        md.parser.blockprocessors.add('css', MooseCSS(md.parser, root=config['root']), '_begin')

        # Inline Patterns
        object_markdown = MooseObjectSyntax(markdown_instance=md,
                                            yaml=cache['yaml'],
                                            syntax=cache['syntax'],
                                            input_files=cache['input_files'],
                                            child_objects=cache['child_objects'],
                                            repo=config['repo'],
                                            root=config['root'])
        system_markdown = MooseSystemSyntax(markdown_instance=md,
                                            yaml=cache['yaml'],
                                            syntax=cache['syntax'])
        md.inlinePatterns.add('moose_object_syntax', object_markdown, '_begin')
        md.inlinePatterns.add('moose_system_syntax', system_markdown, '_begin')

        md.inlinePatterns.add('moose_input_block', MooseInputBlock(markdown_instance=md, repo=config['repo'], root=config['root']), '<image_link')
        md.inlinePatterns.add('moose_cpp_method', MooseCppMethod(markdown_instance=md, make=config['make'], repo=config['repo'], root=config['root']), '<image_link')
        md.inlinePatterns.add('moose_text', MooseTextFile(markdown_instance=md, repo=config['repo'], root=config['root']), '<image_link')
        md.inlinePatterns.add('moose_image', MooseImageFile(markdown_instance=md, root=config['root']), '<image_link')
        md.inlinePatterns.add('moose_build_status', MooseBuildStatus(markdown_instance=md), '_begin')

        if config['package']:
            md.inlinePatterns.add('moose_package_parser', MoosePackageParser(markdown_instance=md), '_end')
开发者ID:garvct,项目名称:Moose,代码行数:73,代码来源:MooseMarkdown.py


注:本文中的MooseDocs.yaml_load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。