Exemplo n.º 1
0
def generate_html(md_file, config_file):
    """
    Generates html from Moose flavored markdown.

    Args:
      md_file[str]: The *.md file or text to convert.
      config_file[str]: The *.yml configuration file.
    """

    # Load the YAML configuration file
    config = MooseDocs.load_config(config_file)

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

    # Read and parse the markdown
    md, settings = MooseDocs.read_markdown(md_file)
    return parser.convert(md), settings
Exemplo n.º 2
0
    def setUpClass(cls):
        """
        Create the markdown parser using the 'moosedocs.yml' configuration file.
        """

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

        # Create the markdown object
        cwd = os.getcwd()
        os.chdir(os.path.join(MooseDocs.MOOSE_DIR, 'docs'))

        config = MooseDocs.load_config('moosedocs.yml')

        extensions, extension_configs = MooseDocs.get_markdown_extensions(
            config)
        cls.updateExtensionConfigs(extension_configs)
        cls.parser = markdown.Markdown(extensions=extensions,
                                       extension_configs=extension_configs)
        os.chdir(cwd)
Exemplo n.º 3
0
def build_site(config_file='moosedocs.yml',
               num_threads=multiprocessing.cpu_count(),
               **kwargs):
    """
    The main build command.
    """

    # Load the YAML configuration file
    config = MooseDocs.load_config(config_file, **kwargs)

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

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

    # Create the html
    builder.build(num_threads=num_threads)
    return config, parser, builder
Exemplo n.º 4
0
def generate(config_file='moosedocs.yml',
             generate=True,
             locations=None,
             **kwargs):
    """
    Generates MOOSE system and object markdown files from the source code.

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

    # Read the configuration
    config = MooseDocs.load_config(config_file)
    _, ext_config = MooseDocs.get_markdown_extensions(config)
    ext_config = ext_config['MooseDocs.extensions.MooseMarkdown']

    # 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 {} to extract syntax.".format(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 == None) or (key in locations):
                value['group'] = key
                syntax = MooseDocs.MooseApplicationSyntax(
                    yaml,
                    generate=generate,
                    install=ext_config['install'],
                    **value)
                log.info("Checking documentation for '{}'.".format(key))
                syntax.check()