Ejemplo n.º 1
0
def main(cmd, args, options=None):
    """
    Build the documentation, and optionally start the devserver.
    """
    clean_site_dir = 'clean' in options
    if cmd == 'serve':
        config = load_config(options=options)
        serve(config, options=options)
    elif cmd == 'build':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
    elif cmd == 'json':
        config = load_config(options=options)
        build(config, dump_json=True, clean_site_dir=clean_site_dir)
    elif cmd == 'gh-deploy':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
        gh_deploy(config)
    elif cmd == 'new':
        new(args, options)
    else:
        config = load_config(options=options)
        event = events.CLI(config, cmd, args, options)
        event.broadcast()
        if not event.consumed:
            std = ['help', 'new', 'build', 'serve', 'gh-deply', 'json']
            cmds = '|'.join(std + list(events.CLI.commands))
            print('mkdocs [%s] {options}' % cmds)
Ejemplo n.º 2
0
def serve_command(dev_addr, config_file, strict, theme):
    """Run the builtin development server"""
    serve.serve(load_config(
        config_file=config_file,
        dev_addr=dev_addr,
        strict=strict,
        theme=theme,
    ))
Ejemplo n.º 3
0
def serve_command(dev_addr, config_file, strict, theme, livereload):
    """Run the builtin development server"""

    logging.getLogger('tornado').setLevel(logging.WARNING)

    serve.serve(
        config_file=config_file,
        dev_addr=dev_addr,
        strict=strict,
        theme=theme,
        livereload=livereload,
    )
Ejemplo n.º 4
0
def serve_command(dev_addr, config_file, strict, theme, livereload):
    """Run the builtin development server"""

    logging.getLogger('tornado').setLevel(logging.WARNING)

    serve.serve(
        config_file=config_file,
        dev_addr=dev_addr,
        strict=strict,
        theme=theme,
        livereload=livereload,
    )
Ejemplo n.º 5
0
def serve_command(dev_addr, config_file, strict, theme, livereload):
    """Run the builtin development server"""

    logging.getLogger('tornado').setLevel(logging.WARNING)

    try:
        serve.serve(
            config_file=config_file,
            dev_addr=dev_addr,
            strict=strict,
            theme=theme,
            livereload=livereload,
        )
    except (exceptions.ConfigurationError, socket.error) as e:
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
Ejemplo n.º 6
0
Archivo: cli.py Proyecto: ivanz/mkdocs
def serve_command(dev_addr, config_file, strict, theme, livereload):
    """Run the builtin development server"""

    logging.getLogger('tornado').setLevel(logging.WARNING)

    try:
        serve.serve(
            config_file=config_file,
            dev_addr=dev_addr,
            strict=strict,
            theme=theme,
            livereload=livereload,
        )
    except (exceptions.ConfigurationError, socket.error) as e:
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
Ejemplo n.º 7
0
def run_build(theme_name, output=None, config_file=None, quiet=False):
    """
    Given a theme name and output directory use the configuration
    for the MkDocs documentation and overwrite the site_dir and
    theme. If no output is provided, serve the documentation on
    each theme, one at a time.
    """

    should_serve = output is None
    options = {}

    if not serve:
        if not os.path.exists(output):
            os.makedirs(output)
        options['site_dir'] = os.path.join(output, theme_name)

    if config_file is None:
        config_file = open(MKDOCS_CONFIG, 'rb')

    if not quiet:
        print("Using config: {0}".format(config_file))

    cli.configure_logging()
    conf = config.load_config(config_file=config_file, theme=theme_name)

    if should_serve:
        if not quiet:
            print("Serving {0}".format(theme_name))
        try:
            serve.serve(conf)
        except KeyboardInterrupt:
            return
    else:
        if not quiet:
            print("Building {0}".format(theme_name))

        try:
            with capture_stdout() as out:
                build.build(conf)
                build.build(conf, dump_json=True)
        except Exception:
            print("Failed building {0}".format(theme_name), file=sys.stderr)
            raise

        if not quiet:
            print(''.join(out))
Ejemplo n.º 8
0
def run_build(theme_name, output=None, config_file=None, quiet=False):
    """
    Given a theme name and output directory use the configuration
    for the MkDocs documentation and overwrite the site_dir and
    theme. If no output is provided, serve the documentation on
    each theme, one at a time.
    """

    should_serve = output is None
    options = {}

    if not serve:
        if not os.path.exists(output):
            os.makedirs(output)
        options['site_dir'] = os.path.join(output, theme_name)

    if config_file is None:
        config_file = open(MKDOCS_CONFIG, 'rb')

    if not quiet:
        print("Using config: {0}".format(config_file))

    cli.configure_logging()
    conf = config.load_config(config_file=config_file, theme=theme_name)

    if should_serve:
        if not quiet:
            print("Serving {0}".format(theme_name))
        try:
            serve.serve(conf)
        except KeyboardInterrupt:
            return
    else:
        if not quiet:
            print("Building {0}".format(theme_name))

        try:
            with capture_stdout() as out:
                build.build(conf)
                build.build(conf, dump_json=True)
        except Exception:
            print("Failed building {0}".format(theme_name), file=sys.stderr)
            raise

        if not quiet:
            print(''.join(out))
Ejemplo n.º 9
0
def main(cmd, args, options=None):
    """
    Build the documentation, and optionally start the devserver.
    """
    if cmd == 'serve':
        config = load_config(options=options)
        serve(config, options=options)
    elif cmd == 'build':
        config = load_config(options=options)
        build(config)
    elif cmd == 'gh-deploy':
        config = load_config(options=options)
        build(config)
        gh_deploy(config)
    elif cmd == 'new':
        new(args, options)
    else:
        print('mkdocs [help|new|build|serve|gh-deploy] {options}')
Ejemplo n.º 10
0
def main(cmd, args, options=None):
    """
    Build the documentation, and optionally start the devserver.
    """
    if cmd == 'serve':
        config = load_config(options=options)
        serve(config, options=options)
    elif cmd == 'build':
        config = load_config(options=options)
        build(config)
    elif cmd == 'json':
        config = load_config(options=options)
        build(config, dump_json=True)
    elif cmd == 'gh-deploy':
        config = load_config(options=options)
        build(config)
        gh_deploy(config)
    elif cmd == 'new':
        new(args, options)
    else:
        print('mkdocs [help|new|build|serve|gh-deploy|json] {options}')
Ejemplo n.º 11
0
def main(cmd, args, options=None):
    """
    Build the documentation, and optionally start the devserver.
    """
    clean_site_dir = 'clean' in options
    if cmd == 'serve':
        config = load_config(options=options)
        serve(config, options=options)
    elif cmd == 'build':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
    elif cmd == 'json':
        config = load_config(options=options)
        build(config, dump_json=True, clean_site_dir=clean_site_dir)
    elif cmd == 'gh-deploy':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
        gh_deploy(config)
    elif cmd == 'new':
        new(args, options)
    else:
        print('mkdocs [help|new|build|serve|gh-deploy|json] {options}')
Ejemplo n.º 12
0
def main(cmd, args, options=None):
    """
    Build the documentation, and optionally start the devserver.
    """
    clean_site_dir = 'clean' in options
    if cmd == 'serve':
        config = load_config(options=options)
        serve(config, options=options)
    elif cmd == 'build':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
    elif cmd == 'json':
        config = load_config(options=options)
        build(config, dump_json=True, clean_site_dir=clean_site_dir)
    elif cmd == 'gh-deploy':
        config = load_config(options=options)
        build(config, clean_site_dir=clean_site_dir)
        gh_deploy(config)
    elif cmd == 'new':
        new(args, options)
    else:
        print('MkDocs (version {0})'.format(__version__))
        print('mkdocs [help|new|build|serve|gh-deploy|json] {options}')