• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python build.build函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_copying_media

    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, 'index.md'), 'w')
            f.write(dedent("""
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """))
            f.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_base.Config(schema=config_defaults.DEFAULT_SCHEMA)
            conf.load_dict({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            conf.validate()
            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:mbacho,项目名称:mkdocs,代码行数:41,代码来源:build_tests.py


示例17: main

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


示例18: test_copying_media

    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, "index.md"), "w")
            f.write(
                dedent(
                    """
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """
                )
            )
            f.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:jpush,项目名称:mkdocs,代码行数:39,代码来源:test.py


示例19: json_command

def json_command(clean, config_file, strict, site_dir):
    """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/")

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


示例20: 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

    # Perform the initial build
    config = load_config(options=options)
    build(config)

    # 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)
    server.serve_forever()

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python build.convert_markdown函数代码示例发布时间:2022-05-27
下一篇:
Python tasks.EventTracker类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap