當前位置: 首頁>>代碼示例>>Python>>正文


Python MooseDocs類代碼示例

本文整理匯總了Python中MooseDocs的典型用法代碼示例。如果您正苦於以下問題:Python MooseDocs類的具體用法?Python MooseDocs怎麽用?Python MooseDocs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MooseDocs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check

def check(config_file=None, locations=None, generate=None):
    """
    Performs checks and optionally generates stub pages for missing documentation.
    """
    # Read the configuration
    app_ext = 'MooseDocs.extensions.app_syntax'
    config = MooseDocs.load_config(config_file)
    if app_ext not in config:
        mooseutils.MooseException("The 'check' utility requires the 'app_syntax' extension.")
    ext_config = config[app_ext]

    # Run the executable
    exe = MooseDocs.abspath(ext_config['executable'])
    if not os.path.exists(exe):
        raise IOError('The executable does not exist: {}'.format(exe))
    else:
        LOG.debug("Executing %s to extract syntax.", exe)
        raw = mooseutils.runExe(exe, '--yaml')
        yaml = mooseutils.MooseYaml(raw)

    # Populate the syntax
    for loc in ext_config['locations']:
        for key, value in loc.iteritems():
            if (locations is None) or (key in locations):
                value['group'] = key
                syntax = common.MooseApplicationSyntax(yaml, generate=generate,
                                                       install=ext_config['install'], **value)
                LOG.info("Checking documentation for '%s'.", key)
                syntax.check()

    return None
開發者ID:mangerij,項目名稱:moose,代碼行數:31,代碼來源:check.py

示例2: generate_html

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,代碼行數:28,代碼來源:latex.py

示例3: setUpClass

    def setUpClass(cls):
        """
        Create the markdown parser using the configuration file.
        """
        super(MarkdownTestCase, cls).setUpClass()

        # Setup logging
        cls._stream = StringIO.StringIO()
        cls._formatter = init_logging(stream=cls._stream)

        # Define the local directory
        cls._path = os.path.abspath(os.path.dirname(inspect.getfile(cls)))

        # Read the YAML configurations
        config = MooseMarkdown.getDefaultExtensions()
        config.update(MooseDocs.load_config(os.path.join(MooseDocs.MOOSE_DIR, 'docs', cls.CONFIG)))

        # Update extension list
        if cls.EXTENSIONS:
            for key in config:
                if key not in cls.EXTENSIONS:
                    config.pop(key)

        cls.updateExtensions(config)
        cls.parser = MooseMarkdown(config, default=False)
開發者ID:aeslaughter,項目名稱:moose,代碼行數:25,代碼來源:testing.py

示例4: generate

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,代碼行數:34,代碼來源:generate.py

示例5: setUpClass

 def setUpClass(cls):
     """
     Create link database.
     """
     config = MooseDocs.load_config(os.path.join(MooseDocs.MOOSE_DIR, 'docs', 'website.yml'))
     options = config['MooseDocs.extensions.app_syntax']
     cls.database = MooseLinkDatabase(repo=options['repo'], links=options['links'])
開發者ID:aeslaughter,項目名稱:moose,代碼行數:7,代碼來源:test_link_database.py

示例6: presentation

def presentation(config_file=None, md_file=None, serve=None, port=None, host=None, template=None,
                 **template_args):
    """
    MOOSE markdown presentation blaster.
    """

    # The markdown file is provided via the command line, thus it is provided relative to the
    # current working directory. The internals of MooseDocs are setup to always work from the
    # repository root directory (i.e., MooseDocs.ROOT_DIR), thus the path of this file must be
    # converted to be relative to MooseDocs.ROOT_DIR.
    md_file = os.path.relpath(os.path.abspath(md_file), MooseDocs.ROOT_DIR)

    # Create the markdown parser
    config = MooseDocs.load_config(config_file, template=template, template_args=template_args)
    parser = MooseMarkdown(config)

    # Build the html
    builder = PresentationBuilder(md_file=md_file, parser=parser)
    builder.init()
    builder.build(num_threads=1)

    if serve:
        server = livereload.Server()
        server.watch(os.path.join(MooseDocs.ROOT_DIR, md_file),
                     lambda: builder.build(num_threads=1))
        server.serve(root=builder.rootDirectory(), host=host, port=port, restart_delay=0)

    return 0
開發者ID:zachmprince,項目名稱:moose,代碼行數:28,代碼來源:presentation.py

示例7: __init__

    def __init__(self, **kwargs):
        super(AppSyntaxExtension, self).__init__(**kwargs)

        # Storage for the MooseLinkDatabase object
        self.syntax = None

        # Create the absolute path to the executable
        self.setConfig('executable', MooseDocs.abspath(self.getConfig('executable')))
開發者ID:mangerij,項目名稱:moose,代碼行數:8,代碼來源:app_syntax.py

示例8: _getSlideID

 def _getSlideID(section):
     """
     Helper for getting slide name
     """
     match = re.search(r'#+\s*(.*?)\s*\n', section)
     if match:
         return MooseDocs.html_id(match.group(1))
     return None
開發者ID:aeslaughter,項目名稱:moose,代碼行數:8,代碼來源:presentation.py

示例9: _updateSyntax

    def _updateSyntax(self, path, objects, actions):
        """
        A helper for populating the syntax/filename/markdown databases. (private)

        Args:
          path[str]: A valid source directory to inspect.
        """
        reg_re = r'(?<!\:)register(?!RecoverableData|edError)\w+?\((?P<key>\w+)\);'
        reg_named_re = r'registerNamed\w+?\((?P<class>\w+),\s*"(?P<key>\w+)"\);'
        action_re = r'(registerActionSyntax|registerSyntax|registerSyntaxTask)\("(?P<action>\w+)"' \
                    r'\s*,\s*"(?P<key>.*?)\"[,\);]'

        # Walk the directory, looking for files with the supplied extension.
        for root, _, files in os.walk(MooseDocs.abspath(path), topdown=False):
            for filename in files:
                fullfile = os.path.join(root, filename)

                # Inspect source files
                if filename.endswith('.C') or filename.endswith('.h'):
                    fid = open(fullfile, 'r')
                    content = fid.read()
                    fid.close()

                    # Update class to source definition map
                    if filename.endswith('.h'):
                        for match in re.finditer(r'class\s*(?P<class>\w+)\b[^;]', content):
                            key = match.group('class')
                            self._filenames[key] = [fullfile]
                            src = fullfile.replace('/include/', '/src/')[:-2] + '.C'
                            if os.path.exists(src) and (src not in self._filenames[key]):
                                self._filenames[key].append(src)

                    # Map of registered objects
                    for match in re.finditer(reg_re, content):
                        key = match.group('key')
                        objects[key] = key

                    # Map of named registered objects
                    for match in re.finditer(reg_named_re, content):
                        name = match.group('class')
                        key = match.group('key')
                        objects[key] = name

                    # Action syntax map
                    for match in re.finditer(action_re, content):
                        key = match.group('key')
                        action = match.group('action')
                        actions[key].add(action)

        for root, _, files in os.walk(path, topdown=False):
            for filename in files:
                fullfile = os.path.join(root, filename)

                # Inspect source files
                name, ext = os.path.splitext(filename)
                if (ext == '.C') and (name in self._filenames):
                    self._filenames[name].append(fullfile)
開發者ID:mangerij,項目名稱:moose,代碼行數:57,代碼來源:MooseApplicationSyntax.py

示例10: __init__

    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,代碼行數:10,代碼來源:global.py

示例11: __init__

  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,代碼行數:10,代碼來源:MoosePackageParser.py

示例12: __init__

    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,代碼行數:11,代碼來源:build.py

示例13: latex

def latex(config_file=None, output=None, md_file=None, **kwargs):
    """
    Command for converting markdown file to latex.
    """

    # Load the YAML configuration file
    config = MooseDocs.load_config(config_file, **kwargs)
    parser = MooseDocs.MooseMarkdown(extensions=config.keys(), extension_configs=config)

    site_dir, _ = os.path.splitext(md_file)
    root = LatexBuilder(output, name='', markdown=md_file, parser=parser, site_dir=site_dir)
    root.build()
    return None
開發者ID:mangerij,項目名稱:moose,代碼行數:13,代碼來源:latex.py

示例14: setUpClass

    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,代碼行數:13,代碼來源:testing.py

示例15: build

def build(config_file='moosedocs.yml', live_server=False, pages='pages.yml', page_keys=[], clean_site_dir=False, **kwargs):
    """
    Build the documentation using mkdocs build command.

    Args:
        config_file[str]: (Default: 'mkdocs.yml') The configure file to pass to mkdocs.
    """
    pages = MooseDocs.load_pages(pages, keys=page_keys)
    config = mkdocs.config.load_config(config_file, pages=pages, **kwargs)
    update_extra()
    mkdocs.commands.build.build(config)
    mkdocs.utils.copy_media_files(config['docs_dir'], config['site_dir'])
    return config
開發者ID:garvct,項目名稱:Moose,代碼行數:13,代碼來源:build.py


注:本文中的MooseDocs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。