Пример #1
0
  def extendMarkdown(self, md, md_globals):
    """
    Builds the extensions for MOOSE flavored markdown.
    """
    md.registerExtension(self)

    # Create a config object
    config = self.getConfigs()

    # Extract YAML
    exe_yaml = self.execute(config.pop('executable', None))

    # Generate YAML data from application
    # Populate the database for input file and children objects
    log.info('Creating input file and source code use database.')
    database = MooseDocs.MooseLinkDatabase(**config)

    # Populate the syntax
    self.syntax = dict()
    for key, value in config['locations'].iteritems():
      if 'hide' in value:
        value['hide'] += config['hide']
      else:
        value['hide'] = config['hide']
      self.syntax[key] = MooseDocs.MooseApplicationSyntax(exe_yaml, **value)

    # Preprocessors
    md.preprocessors.add('moose_bibtex', MooseBibtex(markdown_instance=md, **config), '_end')
    if config['slides']:
      md.preprocessors.add('moose_slides', MooseSlidePreprocessor(markdown_instance=md), '_end')

    # Block processors
    md.parser.blockprocessors.add('diagrams', MooseDiagram(md.parser, **config), '_begin')
    md.parser.blockprocessors.add('slideshow', MooseSlider(md.parser, **config), '_begin')
    md.parser.blockprocessors.add('css', MooseCSS(md.parser, **config), '_begin')

    # Inline Patterns
    object_markdown = MooseObjectSyntax(markdown_instance=md,
                                        yaml=exe_yaml,
                                        syntax=self.syntax,
                                        database=database,
                                        **config)
    md.inlinePatterns.add('moose_object_syntax', object_markdown, '_begin')

    system_markdown = MooseSystemSyntax(markdown_instance=md,
                                        yaml=exe_yaml,
                                        syntax=self.syntax,
                                        **config)
    md.inlinePatterns.add('moose_system_syntax', system_markdown, '_begin')

    md.inlinePatterns.add('moose_input_block', MooseInputBlock(markdown_instance=md, **config), '<image_link')
    md.inlinePatterns.add('moose_cpp_method', MooseCppMethod(markdown_instance=md, **config), '<image_link')
    md.inlinePatterns.add('moose_text', MooseTextFile(markdown_instance=md, **config), '<image_link')
    md.inlinePatterns.add('moose_image', MooseImageFile(markdown_instance=md, **config), '<image_link')
    md.inlinePatterns.add('moose_build_status', MooseBuildStatus(markdown_instance=md, **config), '_begin')
    if config['package']:
      md.inlinePatterns.add('moose_package_parser', MoosePackageParser(markdown_instance=md, **config), '_end')
Пример #2
0
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['hide']
        else:
            value['hide'] = config['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()
Пример #3
0
    def setUpClass(cls):

        # Read the moosedocs.yml configuration
        config = MooseDocs.load_config(
            os.path.join(MooseDocs.MOOSE_DIR, 'docs', 'moosedocs.yml'))
        options = config['markdown_extensions'][6][
            'MooseDocs.extensions.MooseMarkdown']

        # Extract the MOOSE YAML data
        exe = os.path.join(MooseDocs.MOOSE_DIR, 'modules', 'combined',
                           'combined-opt')
        raw = mooseutils.runExe(exe, '--yaml')
        cls._yaml = mooseutils.MooseYaml(raw)

        # Extract the 'framework' location options and build the syntax object
        framework = options['locations'][0]['framework']
        framework['group'] = 'framework'
        framework['install'] = options['install']
        framework['hide'] = ['/AuxKernels']  # use to test hide
        cls._syntax = MooseDocs.MooseApplicationSyntax(cls._yaml, **framework)
Пример #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()
Пример #5
0
    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 auto-link database
        if not cache['markdown_include']:
            log.info('Building markdown database for auto links.')
            loc = os.path.join(self.config['root'][0],
                               self.config['docs_dir'][0])
            cache['markdown_include'] = MooseDocs.database.Database(
                '.md', loc, MooseDocs.database.items.MarkdownIncludeItem)

        # 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)

        # Preprocessors
        md.preprocessors.add(
            'moose_auto_link',
            MooseMarkdownLinkPreprocessor(markdown_instance=md,
                                          database=cache['markdown_include']),
            '_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')
Пример #6
0
    def extendMarkdown(self, md, md_globals):
        """
        Builds the extensions for MOOSE flavored markdown.
        """
        md.registerExtension(self)

        # Create a config object
        config = self.getConfigs()

        # Extract YAML
        exe_yaml = self.execute()

        # Generate YAML data from application
        # Populate the database for input file and children objects
        log.debug('Creating input file and source code use database.')
        database = MooseDocs.MooseLinkDatabase(**config)

        # Populate the syntax
        self.syntax = collections.OrderedDict()
        for item in config['locations']:
            key = item.keys()[0]
            options = item.values()[0]
            options.setdefault('group', key)
            options.setdefault('name', key.replace('_', ' ').title())
            options.setdefault('install', config['install'])
            self.syntax[key] = MooseDocs.MooseApplicationSyntax(
                exe_yaml, **options)

        # Replace the InlineTreeprocessor with the MooseInlineProcessor, this allows
        # for an initialize() method to be called prior to the convert for re-setting state.
        md.treeprocessors['inline'] = MooseInlineProcessor(
            markdown_instance=md, **config)

        # Preprocessors
        md.preprocessors.add('moose_bibtex',
                             MooseBibtex(markdown_instance=md, **config),
                             '_end')
        if config['slides']:
            md.preprocessors.add('moose_slides',
                                 MooseSlidePreprocessor(markdown_instance=md),
                                 '_end')

        # Block processors
        md.parser.blockprocessors.add('diagrams',
                                      MooseDiagram(md.parser, **config),
                                      '_begin')
        md.parser.blockprocessors.add('slider',
                                      MooseSlider(md.parser,
                                                  **config), '_begin')
        md.parser.blockprocessors.add('css', MooseCSS(md.parser, **config),
                                      '_begin')

        # Inline Patterns
        params = MooseParameters(markdown_instance=md,
                                 syntax=self.syntax,
                                 **config)
        md.inlinePatterns.add('moose_parameters', params, '_begin')

        desc = MooseDescription(markdown_instance=md,
                                syntax=self.syntax,
                                **config)
        md.inlinePatterns.add('moose_description', desc, '_begin')

        object_markdown = MooseObjectSyntax(markdown_instance=md,
                                            syntax=self.syntax,
                                            database=database,
                                            **config)
        md.inlinePatterns.add('moose_object_syntax', object_markdown, '_begin')

        system_markdown = MooseActionSyntax(markdown_instance=md,
                                            syntax=self.syntax,
                                            **config)
        md.inlinePatterns.add('moose_system_syntax', system_markdown, '_begin')

        system_list = MooseActionList(markdown_instance=md,
                                      yaml=exe_yaml,
                                      syntax=self.syntax,
                                      **config)
        md.inlinePatterns.add('moose_system_list', system_list, '_begin')

        md.inlinePatterns.add('moose_input_block',
                              MooseInputBlock(markdown_instance=md, **config),
                              '_begin')
        md.inlinePatterns.add('moose_cpp_method',
                              MooseCppMethod(markdown_instance=md, **config),
                              '_begin')
        md.inlinePatterns.add('moose_text',
                              MooseTextFile(markdown_instance=md, **config),
                              '_begin')
        md.inlinePatterns.add('moose_image',
                              MooseImageFile(markdown_instance=md, **config),
                              '_begin')
        md.inlinePatterns.add('moose_figure',
                              MooseFigure(markdown_instance=md, **config),
                              '_begin')
        md.inlinePatterns.add(
            'moose_figure_reference',
            MooseFigureReference(markdown_instance=md, **config),
            '>moose_figure')
        md.inlinePatterns.add(
            'moose_equation_reference',
            MooseEquationReference(markdown_instance=md, **config),
            '<moose_figure_reference')
        md.inlinePatterns.add('moose_build_status',
                              MooseBuildStatus(markdown_instance=md, **config),
                              '_begin')
        if config['package']:
            md.inlinePatterns.add(
                'moose_package_parser',
                MoosePackageParser(markdown_instance=md, **config), '_end')
Пример #7
0
    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():
                if 'hide' in value:
                    value['hide'] += config['hide']
                else:
                    value['hide'] = config['hide']
                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
        bibtex = MooseBibtex(markdown_instance=md, root=config['root'])
        md.preprocessors.add('moose_bibtex', bibtex, '_end')

        links = MooseMarkdownLinkPreprocessor(markdown_instance=md,
                                              pages=cache['pages'])
        md.preprocessors.add('moose_auto_link', links, '_begin')

        if config['slides']:
            slides = MooseSlidePreprocessor(markdown_instance=md)
            md.preprocessors.add('moose_slides', slides, '_end')

        # Block processors
        diagrams = MooseDiagram(md.parser,
                                root=config['root'],
                                docs_dir=config['docs_dir'],
                                graphviz=config['graphviz'],
                                ext=config['dot_ext'])
        md.parser.blockprocessors.add('diagrams', diagrams, '_begin')

        carousel = MooseCarousel(md.parser,
                                 root=config['root'],
                                 docs_dir=config['docs_dir'])
        md.parser.blockprocessors.add('slideshow', carousel, '_begin')

        css = MooseCSS(md.parser,
                       root=config['root'],
                       docs_dir=config['docs_dir'])
        md.parser.blockprocessors.add('css', css, '_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'],
            docs_dir=config['docs_dir'])
        md.inlinePatterns.add('moose_object_syntax', object_markdown, '_begin')

        system_markdown = MooseSystemSyntax(markdown_instance=md,
                                            yaml=cache['yaml'],
                                            syntax=cache['syntax'],
                                            root=config['root'],
                                            docs_dir=config['docs_dir'])
        md.inlinePatterns.add('moose_system_syntax', system_markdown, '_begin')

        moose_input = MooseInputBlock(markdown_instance=md,
                                      root=config['root'],
                                      docs_dir=config['docs_dir'],
                                      repo=config['repo'])
        md.inlinePatterns.add('moose_input_block', moose_input, '<image_link')

        moose_cpp = MooseCppMethod(markdown_instance=md,
                                   root=config['root'],
                                   docs_dir=config['docs_dir'],
                                   make=config['make'],
                                   repo=config['repo'])
        md.inlinePatterns.add('moose_cpp_method', moose_cpp, '<image_link')

        moose_text = MooseTextFile(markdown_instance=md,
                                   root=config['root'],
                                   docs_dir=config['docs_dir'],
                                   repo=config['repo'])
        md.inlinePatterns.add('moose_text', moose_text, '<image_link')

        moose_image = MooseImageFile(markdown_instance=md,
                                     root=config['root'],
                                     docs_dir=config['docs_dir'])
        md.inlinePatterns.add('moose_image', moose_image, '<image_link')

        moose_status = MooseBuildStatus(markdown_instance=md,
                                        root=config['root'],
                                        docs_dir=config['docs_dir'])
        md.inlinePatterns.add('moose_build_status', moose_status, '_begin')

        if config['package']:
            package = MoosePackageParser(markdown_instance=md,
                                         root=config['root'],
                                         docs_dir=config['docs_dir'])
            md.inlinePatterns.add('moose_package_parser', package, '_end')