예제 #1
0
    def execute(self):
        """
        Execute the supplied MOOSE application and return the YAML.
        """

        cache = os.path.join(MooseDocs.TEMP_DIR, 'moosedocs.yaml')
        exe = self.getConfig('executable')

        if os.path.exists(cache) and (os.path.getmtime(cache) >= os.path.getmtime(exe)):
            with open(cache, 'r') as fid:
                LOG.debug('Reading MooseYaml Pickle: ' + cache)
                return mooseutils.MooseYaml(pickle.load(fid))

        elif not (exe or os.path.exists(exe)):
            LOG.critical('The executable does not exist: %s', exe)
            raise Exception('Critical Error')

        else:
            LOG.debug("Executing %s to extract syntax.", exe)
            try:
                raw = mooseutils.runExe(exe, '--yaml')
                with open(cache, 'w') as fid:
                    LOG.debug('Writing MooseYaml Pickle: ' + cache)
                    pickle.dump(raw, fid)
                return mooseutils.MooseYaml(raw)
            except:
                LOG.critical('Failed to read YAML file, MOOSE and modules are likely not compiled'
                             ' correctly.')
                raise
예제 #2
0
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
예제 #3
0
    def setUpClass(cls):

        # Read the configuration
        config = MooseDocs.load_config(
            os.path.join(MooseDocs.MOOSE_DIR, 'docs', 'website.yml'))
        options = config['MooseDocs.extensions.app_syntax']

        # 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 = MooseApplicationSyntax(cls._yaml, **framework)
예제 #4
0
    def execute(self):
        """
        Execute the supplied MOOSE application and return the YAML.
        """

        exe = self.getConfig('executable')
        if not (exe or os.path.exists(exe)):
            log.critical('The executable does not exist: {}'.format(exe))
            raise Exception('Critical Error')

        else:
            log.debug("Executing {} to extract syntax.".format(exe))
            try:
                raw = mooseutils.runExe(exe, '--yaml')
                return mooseutils.MooseYaml(raw)
            except:
                log.critical(
                    'Failed to read YAML file, MOOSE and modules are likely not compiled correctly.'
                )
                raise Exception('Critical Error')
예제 #5
0
파일: generate.py 프로젝트: lhhhu1990/lhhhu
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()