Exemple #1
0
def main(options):
    """./moosedocs check"""

    translator, config = common.load_config(options.config)

    # Extract the syntax root node
    syntax = None
    extension = None
    for ext in translator.extensions:
        extension = ext
        if isinstance(ext, MooseDocs.extensions.appsyntax.AppSyntaxExtension):
            syntax = ext.syntax
            break

    if syntax is None:
        msg = "Failed to locate AppSyntaxExtension for the given configuration."
        raise exceptions.MooseDocsException(msg)

    # Use config.yml "Check:groups" if groups not provided
    if (options.groups is None) and ('Check' in config) and ('groups' in config['Check']):
        options.groups = config['Check']['groups']
    elif options.groups is None:
        options.groups = [extension.apptype]

    # Dump the complete syntax for the application
    if options.dump:
        print syntax

    # Perform check for all the nodes
    for node in anytree.PreOrderIter(syntax):
        node.check(generate=options.generate,
                   update=options.update,
                   groups=options.groups,
                   locations=config['Content'])
Exemple #2
0
def main(options):
    """
    Main function for the build command.

    Inputs:
        options[argparse options]: Complete options from argparse, see MooseDocs/main.py
    """

    # Make sure "large_media" exists in MOOSE
    _init_large_media()

    # Create translator
    translator = common.load_config(options.config)
    translator.init(options.destination)

    # Dump page tree
    if options.dump:
        print translator.root

    # Clean
    if options.clean:
        shutil.rmtree(options.destination)

    # Perform build
    if options.files:
        for filename in options.files:
            node = translator.root.findall(filename)[0]
            node.build()
    else:
        translator.execute(options.num_threads)

    if options.serve:
        watcher = MooseDocsWatcher(translator, options)
        server = livereload.Server(watcher=watcher)
        server.serve(root=options.destination, port=options.port)
Exemple #3
0
def main(options):
    """./moosedocs check"""

    translator = common.load_config(options.config)

    # Extract the syntax root node
    syntax = None
    for ext in translator.extensions:
        if isinstance(ext, MooseDocs.extensions.appsyntax.AppSyntaxExtension):
            syntax = ext.syntax
            break

    if syntax is None:
        msg = "Failed to locate AppSyntaxExtension for the given configuration."
        raise exceptions.MooseDocsException(msg)

    # Dump the complete syntax for the application
    if options.dump:
        print syntax

    # Perform check for all the nodes
    for node in anytree.PreOrderIter(syntax):
        node.check(generate=options.generate,
                   update=options.update,
                   groups=options.groups)
Exemple #4
0
def main(options):
    """./moosedocs check"""

    translator, _ = common.load_config(options.config)
    check(translator,
          dump=options.dump,
          update=options.update,
          generate=options.generate,
          object_prefix=options.object_prefix,
          syntax_prefix=options.syntax_prefix)
Exemple #5
0
def main(options):
    """./moosedocs check"""

    translator, config = common.load_config(options.config)
    check(translator,
          config,
          groups=options.groups,
          dump=options.dump,
          update=options.update,
          generate=options.generate)
Exemple #6
0
def main(options):
    """./moosedocs check"""

    translator, _ = common.load_config(options.config)
    err = check(translator,
                dump=options.dump,
                update=options.update,
                generate=options.generate,
                object_prefix=options.object_prefix,
                syntax_prefix=options.syntax_prefix)
    return err
Exemple #7
0
def main(options):
    """
    Main function for the build command.

    Inputs:
        options[argparse options]: Complete options from argparse, see MooseDocs/main.py
    """

    # Make sure "large_media" exists in MOOSE
    _init_large_media()

    # Create translator
    translator, _ = common.load_config(options.config)
    if options.destination:
        translator.update(destination=mooseutils.eval_path(options.destination))
    translator.init()

    # Replace "home" with local server
    if options.serve:
        home = 'http://127.0.0.1:{}'.format(options.port)
        translator.renderer.update(home=home)
    elif options.home:
        translator.renderer.update(home=options.home)

    # Dump page tree
    if options.dump:
        print translator.root

    # Clean when --files is NOT used or when --clean is used with --files.
    if ((options.files == []) or (options.files != [] and options.clean)) \
       and os.path.exists(translator['destination']):
        log = logging.getLogger('MooseDocs.build')
        log.info("Cleaning destination %s", translator['destination'])
        shutil.rmtree(translator['destination'])

    # Perform check
    if options.check:
        check(translator)

    # Perform build
    if options.files:
        for filename in options.files:
            node = translator.root.findall(filename)[0]
            node.build()
    else:
        translator.execute(options.num_threads)

    if options.serve:
        watcher = MooseDocsWatcher(translator, options)
        server = livereload.Server(watcher=watcher)
        server.serve(root=translator['destination'], host=options.host, port=options.port)
Exemple #8
0
def main(options):
    """./moosedocs update"""

    # Load syntax
    translator, _ = common.load_config(options.config)
    root = None
    for ext in translator.extensions:
        if isinstance(ext, MooseDocs.extensions.appsyntax.AppSyntaxExtension):
            root = ext.syntax
            break

    for node in anytree.PreOrderIter(
            root, filter_=lambda n: isinstance(n, syntax.ObjectNode)):

        idx = node.source().find('/src/')
        old = os.path.join(node.source()[:idx], 'doc', 'content',
                           'documentation', 'systems',
                           node.fullpath.lstrip('/') + '.md')

        if not os.path.isfile(old):
            continue

        new = os.path.join(node.source()[:idx], 'doc', 'content', 'source',
                           node.markdown())
        loc = os.path.dirname(new)
        if not os.path.isdir(loc):
            os.makedirs(loc)
        cmd = ['git', 'mv', '--verbose', old, new]
        subprocess.call(cmd)

    func = lambda n: isinstance(n, syntax.SyntaxNode) and not n.is_root
    for node in anytree.PreOrderIter(root, filter_=func):
        action = anytree.search.findall(
            node, filter_=lambda n: isinstance(n, syntax.ActionNode))[0]
        idx = action.source().find('/src/')
        old = os.path.join(action.source()[:idx], 'doc', 'content',
                           'documentation', 'systems',
                           os.path.dirname(node.markdown()), 'index.md')

        if not os.path.isfile(old):
            continue

        new = os.path.join(action.source()[:idx], 'doc', 'content', 'syntax',
                           os.path.dirname(node.markdown()), 'index.md')

        loc = os.path.dirname(new)
        if not os.path.isdir(loc):
            os.makedirs(loc)
        cmd = ['git', 'mv', '--verbose', old, new]
        subprocess.call(cmd)
Exemple #9
0
def main(options):
    """
    Main function for the build command.

    Inputs:
        options[argparse options]: Complete options from argparse, see MooseDocs/main.py
    """

    # Make sure "large_media" exists in MOOSE
    _init_large_media()

    # Create translator
    translator, _ = common.load_config(options.config)
    translator.init(options.destination)

    # Replace "home" with local server
    if options.serve:
        home = 'http://127.0.0.1:{}'.format(options.port)
        translator.renderer.update(home=home)
    elif options.home:
        translator.renderer.update(home=options.home)

    # Dump page tree
    if options.dump:
        print translator.root

    # Clean
    if options.clean:
        shutil.rmtree(options.destination)

    # Perform check
    if options.check:
        check(translator)

    # Perform build
    if options.files:
        for filename in options.files:
            node = translator.root.findall(filename)[0]
            node.build()
    else:
        translator.execute(options.num_threads)

    if options.serve:
        watcher = MooseDocsWatcher(translator, options)
        server = livereload.Server(watcher=watcher)
        server.serve(root=options.destination, port=options.port)
Exemple #10
0
def main(options):
    """./moosedocs.py profile"""

    log = logging.getLogger(__name__)
    translator, _ = common.load_config(options.config)
    translator.init(options.destination)

    if options.tokenize:
        log.info('Profiling tokenization, this may take several minutes.')
        _run_profile(translator, _tokenize)

    if options.render:
        log.info('Performing tokenization...')
        _tokenize(translator)

        log.info('Profiling rendering, this may take several minutes.')
        _run_profile(translator, _render)
Exemple #11
0
    def test(self):
        config = os.path.join(MooseDocs.MOOSE_DIR, 'test', 'doc', 'config.yml')
        translator, root = common.load_config(config)
        translator.init(root)

        start = time.time()
        for node in anytree.search.findall(root, filter_=lambda n: isinstance(n, page.MarkdownNode)):
            ast = node.tokenize()
        end = time.time()
        print 'NO PICKLE:', end-start

        start = time.time()
        for node in anytree.search.findall(root, filter_=lambda n: isinstance(n, page.MarkdownNode)):
            ast = node.tokenize()
            do_c_pickle(ast, timer=False)
        end = time.time()
        print 'PICKLE:', end-start
Exemple #12
0
def main(options):
    """./moosedocs.py profile"""

    log = logging.getLogger(__name__)
    translator, _ = common.load_config(options.config)
    translator.init(options.destination)

    if options.tokenize:
        log.info('Profiling tokenization, this may take several minutes.')
        _run_profile(translator, _tokenize)

    if options.render:
        log.info('Performing tokenization...')
        _tokenize(translator)

        log.info('Profiling rendering, this may take several minutes.')
        _run_profile(translator, _render)
Exemple #13
0
    def test(self):

        config = os.path.join(MooseDocs.MOOSE_DIR, 'test', 'doc', 'config.yml')
        translator, root = common.load_config(config)
        translator.init(root)

        core = root.findall('/core.md')[0]

        start = time.time()
        core.tokenize(translator.reader)
        core.ast()
        stop = time.time()

        print '\n'
        print 'AST: ', stop - start

        self.assertTrue(os.path.exists(core._pickle))

        core._ast = None
        start = time.time()
        core.ast()
        stop = time.time()
        print 'AST (pickle): ', stop - start
Exemple #14
0
def main(options):
    """
    Main function for the build command.

    Inputs:
        options[argparse options]: Complete options from argparse, see MooseDocs/main.py
    """

    # Make sure "large_media" exists in MOOSE
    _init_large_media()

    # Setup executioner
    kwargs = dict()
    if options.executioner:
        kwargs['Executioner'] = {'type': options.executioner}

    # Create translator
    translator, _ = common.load_config(options.config, **kwargs)
    if options.destination:
        translator.update(
            destination=mooseutils.eval_path(options.destination))
    if options.profile:
        translator.executioner.update(profile=True)
    translator.init()

    # Disable slow extensions for --fast
    if options.fast:
        options.disable.append('appsyntax')
    # options.disable.append('navigation')

    # Disable extensions based on command line arguments
    if options.disable:
        for ext in translator.extensions:
            if ext.name in options.disable:  #pylint: disable=protected-access
                ext.setActive(False)

    # Replace "home" with local server
    if options.serve:
        for ext in translator.extensions:
            if 'home' in ext:
                ext.update(home='http://127.0.0.1:{}'.format(options.port),
                           set_initial=True)

    # Dump page tree
    if options.dump:
        print translator.root
        sys.exit()

    # Clean when --files is NOT used or when --clean is used with --files.
    if ((options.files == []) or (options.files != [] and options.clean)) \
       and os.path.exists(translator['destination']):
        log = logging.getLogger('MooseDocs.build')
        log.info("Cleaning destination %s", translator['destination'])
        shutil.rmtree(translator['destination'])

    # Perform check
    if options.check:
        check(translator)

    # Perform build
    if options.files:
        nodes = []
        for filename in options.files:
            nodes += translator.findPages(filename)
        translator.execute(options.num_threads, nodes)
    else:
        translator.execute(options.num_threads)

    if options.serve:
        watcher = MooseDocsWatcher(translator, options)
        server = livereload.Server(watcher=watcher)
        server.serve(root=translator['destination'],
                     host=options.host,
                     port=options.port)

    return 0
Exemple #15
0
def main(options):
    """
    Main function for the build command.

    Inputs:
        options[argparse options]: Complete options from argparse, see MooseDocs/main.py
    """

    # Make sure "large_media" exists in MOOSE
    _init_large_media()

    # Setup executioner
    kwargs = dict()
    if options.executioner:
        kwargs['Executioner'] = {'type':options.executioner}

    # Create translator
    translator, _ = common.load_config(options.config, **kwargs)
    if options.destination:
        translator.update(destination=mooseutils.eval_path(options.destination))
    if options.profile:
        translator.executioner.update(profile=True)
    translator.init()

    # Disable slow extensions for --fast
    if options.fast:
        options.disable.append('appsyntax')
        options.disable.append('navigation')

    # Disable extensions based on command line arguments
    if options.disable:
        for ext in translator.extensions:
            if ext.name in options.disable: #pylint: disable=protected-access
                ext.setActive(False)

    # Replace "home" with local server
    if options.serve:
        for ext in translator.extensions:
            if 'home' in ext:
                ext.update(home='http://127.0.0.1:{}'.format(options.port), set_initial=True)

    # Dump page tree
    if options.dump:
        for page in translator.content:
            print '{}: {}'.format(page.local, page.source)
        sys.exit()

    # Clean when --files is NOT used or when --clean is used with --files.
    if ((options.files == []) or (options.files != [] and options.clean)) \
       and os.path.exists(translator['destination']):
        log = logging.getLogger('MooseDocs.build')
        log.info("Cleaning destination %s", translator['destination'])
        shutil.rmtree(translator['destination'])

    # Perform check
    if options.check:
        check(translator)

    # Perform build
    if options.files:
        nodes = []
        for filename in options.files:
            nodes += translator.findPages(filename)
        translator.execute(options.num_threads, nodes)
    else:
        translator.execute(options.num_threads)

    if options.serve:
        watcher = MooseDocsWatcher(translator, options)
        server = livereload.Server(watcher=watcher)
        server.serve(root=translator['destination'], host=options.host, port=options.port)

    return 0
Exemple #16
0
 def setUp(self):
     command.CommandExtension.EXTENSION_COMMANDS.clear()
     config = os.path.join('..', 'config.yml')
     self.translator, _ = common.load_config(config)
     self.translator.init()