当前位置: 首页>>代码示例>>Python>>正文


Python build.build函数代码示例

本文整理汇总了Python中mkdocs.build.build函数的典型用法代码示例。如果您正苦于以下问题:Python build函数的具体用法?Python build怎么用?Python build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了build函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_copying_media

    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a markdown file, image, dot file and dot directory.
            open(os.path.join(docs_dir, 'index.md'), 'w').close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
开发者ID:itech001,项目名称:mkdocs,代码行数:27,代码来源:test.py

示例2: run_build

def run_build(theme_name, output, config_file, quiet):
    """
    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.
    """

    options = {
        'theme': theme_name,
    }

    if config_file is None:
        config_file = open(MKDOCS_CONFIG, 'rb')
        if not quiet:
            print("Using config: {0}".format(config_file.name))

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

    if not quiet:
        print("Building {0}".format(theme_name))

    try:
        conf = config.load_config(config_file=config_file, **options)
        config_file.close()
        build.build(conf)
        build.build(conf, dump_json=True)
    except Exception:
        print("Error building: {0}".format(theme_name), file=sys.stderr)
        raise
开发者ID:mbacho,项目名称:mkdocs,代码行数:32,代码来源:integration.py

示例3: build_command

def build_command(clean, config_file, strict, theme):
    """Build the MkDocs documentation"""
    build.build(load_config(
        config_file=config_file,
        strict=strict,
        theme=theme
    ), clean_site_dir=clean)
开发者ID:damienfaivre,项目名称:mkdocs,代码行数:7,代码来源:cli.py

示例4: on_any_event

 def on_any_event(self, event):
     if not isinstance(event, events.DirModifiedEvent):
         time.sleep(0.05)
         print 'Rebuilding documentation...',
         config = load_config(options=self.options)
         build(config, live_server=True)
         print ' done'
开发者ID:AlxxxlA,项目名称:mkdocs,代码行数:7,代码来源:serve.py

示例5: gh_deploy_command

def gh_deploy_command(config_file, clean):
    """Deply your documentation to GitHub Pages"""
    config = load_config(
        config_file=config_file
    )
    build.build(config, clean_site_dir=clean)
    gh_deploy.gh_deploy(config)
开发者ID:damienfaivre,项目名称:mkdocs,代码行数:7,代码来源:cli.py

示例6: gh_deploy_command

def gh_deploy_command(config_file, clean, message, remote_branch):
    """Deply your documentation to GitHub Pages"""
    config = load_config(
        config_file=config_file,
        remote_branch=remote_branch
    )
    build.build(config, clean_site_dir=clean)
    gh_deploy.gh_deploy(config, message=message)
开发者ID:AlexKasaku,项目名称:mkdocs,代码行数:8,代码来源:cli.py

示例7: builder

 def builder():
     log.info("Building documentation...")
     config = load_config(
         config_file=config_file,
         dev_addr=dev_addr,
         strict=strict,
         theme=theme,
     )
     config['site_dir'] = tempdir
     build(config, live_server=True)
     return config
开发者ID:Ohcanep,项目名称:mkdocs,代码行数:11,代码来源:serve.py

示例8: serve

def serve(config, options=None):
    """
    Start the devserver, and rebuild the docs whenever any changes take effect.
    """
    # Create a temporary build directory, and set some options to serve it
    tempdir = tempfile.mkdtemp()
    options['site_dir'] = tempdir

    # Only use user-friendly URLs when running the live server
    options['use_directory_urls'] = True

    # Perform the initial build
    config = load_config(options=options)
    build(config, live_server=True)

    # Note: We pass any command-line options through so that we
    #       can re-apply them if the config file is reloaded.
    event_handler = BuildEventHandler(options)
    config_event_handler = ConfigEventHandler(options)

    # We could have used `Observer()`, which can be faster, but
    # `PollingObserver()` works more universally.
    observer = PollingObserver()
    observer.schedule(event_handler, config['docs_dir'], recursive=True)
    for theme_dir in config['theme_dir']:
        if not os.path.exists(theme_dir):
            continue
        observer.schedule(event_handler, theme_dir, recursive=True)
    observer.schedule(config_event_handler, '.')
    observer.start()

    class TCPServer(socketserver.TCPServer):
        allow_reuse_address = True

    class DocsDirectoryHandler(FixedDirectoryHandler):
        base_dir = config['site_dir']

    host, port = config['dev_addr'].split(':', 1)
    server = TCPServer((host, int(port)), DocsDirectoryHandler)

    print('Running at: http://%s:%s/' % (host, port))
    print('Live reload enabled.')
    print('Hold ctrl+c to quit.')
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        print('Stopping server...')

    # Clean up
    observer.stop()
    observer.join()
    shutil.rmtree(tempdir)
    print('Quit complete')
开发者ID:createcoder,项目名称:mkdocs,代码行数:53,代码来源:serve.py

示例9: build_command

def build_command(clean, config_file, strict, theme, site_dir):
    """Build the MkDocs documentation"""
    try:
        build.build(load_config(
            config_file=config_file,
            strict=strict,
            theme=theme,
            site_dir=site_dir
        ), clean_site_dir=clean)
    except exceptions.ConfigurationError as e:
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
开发者ID:samhatfield,项目名称:mkdocs,代码行数:12,代码来源:cli.py

示例10: json_command

def json_command(clean, config_file, strict):
    """Build the MkDocs documentation to JSON files

    Rather than building your documentation to HTML pages, this
    outputs each page in a simple JSON format. This command is
    useful if you want to index your documentation in an external
    search engine.
    """
    build.build(load_config(
        config_file=config_file,
        strict=strict
    ), dump_json=True, clean_site_dir=clean)
开发者ID:damienfaivre,项目名称:mkdocs,代码行数:12,代码来源:cli.py

示例11: gh_deploy_command

def gh_deploy_command(config_file, clean, message, remote_branch):
    """Deply your documentation to GitHub Pages"""
    try:
        config = load_config(
            config_file=config_file,
            remote_branch=remote_branch
        )
        build.build(config, clean_site_dir=clean)
        gh_deploy.gh_deploy(config, message=message)
    except exceptions.ConfigurationError as e:
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
开发者ID:samhatfield,项目名称:mkdocs,代码行数:12,代码来源:cli.py

示例12: run_build

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))
开发者ID:AlexPerrot,项目名称:mkdocs,代码行数:46,代码来源:integration.py

示例13: json_command

def json_command(clean, config_file, strict):
    """Build the MkDocs documentation to JSON files

    Rather than building your documentation to HTML pages, this
    outputs each page in a simple JSON format. This command is
    useful if you want to index your documentation in an external
    search engine.
    """

    log.warning("The json command is deprcated and will be removed in a future "
                "MkDocs release. For details on updating: "
                "http://www.mkdocs.org/about/release-notes/")

    build.build(load_config(
        config_file=config_file,
        strict=strict
    ), dump_json=True, clean_site_dir=clean)
开发者ID:lalocespedes,项目名称:mkdocs,代码行数:17,代码来源:cli.py

示例14: _build

def _build(cfg, pathspec, tags, site_dir=None):

    c = {
        'extra': {
            'current_version': pathspec,
            'all_versions': tags,
        }
    }

    if site_dir is not None:
        c['site_dir'] = site_dir

    try:
        cfg.load_dict(c)
        build.build(cfg, clean_site_dir=True)
    except Exception:
        log.exception("Failed to build '%s'", pathspec)
开发者ID:d0ugal,项目名称:mkdocs-versioned,代码行数:17,代码来源:cli.py

示例15: serve

def serve(config, options=None):
    """
    Start the devserver, and rebuild the docs whenever any changes take effect.
    """
    # Create a temporary build directory, and set some options to serve it
    tempdir = tempfile.mkdtemp()
    options['site_dir'] = tempdir

    # Only use user-friendly URLs when running the live server
    options['use_directory_urls'] = True

    # Perform the initial build
    config = load_config(options=options)
    build(config, live_server=True)

    # Note: We pass any command-line options through so that we
    #       can re-apply them if the config file is reloaded.
    event_handler = BuildEventHandler(options)
    config_event_handler = ConfigEventHandler(options)
    observer = observers.Observer()
    observer.schedule(event_handler, config['docs_dir'], recursive=True)
    observer.schedule(event_handler, config['theme_dir'], recursive=True)
    observer.schedule(config_event_handler, '.')
    observer.start()

    class TCPServer(socketserver.TCPServer):
        allow_reuse_address = True

    class DocsDirectoryHandler(FixedDirectoryHandler):
        base_dir = config['site_dir']

    host, port = config['dev_addr'].split(':', 1)
    server = TCPServer((host, int(port)), DocsDirectoryHandler)

    print('Running at: http://%s:%s/' % (host, port))
    print('Live reload enabled.')
    print('Hold ctrl+c to quit.')
    server.serve_forever()

    # Clean up
    observer.stop()
    observer.join()
    shutil.rmtree(tempdir)
开发者ID:dnephin,项目名称:mkdocs,代码行数:43,代码来源:serve.py


注:本文中的mkdocs.build.build函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。