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

Python config.load_config函数代码示例

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

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



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

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


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


示例3: test_config_option

    def test_config_option(self):
        """
        Users can explicitly set the config file using the '--config' option.
        Allows users to specify a config other than the default `mkdocs.yml`.
        """
        expected_result = {
            'site_name': 'Example',
            'pages': [
                {'Introduction': 'index.md'}
            ],
        }
        file_contents = dedent("""
        site_name: Example
        pages:
        - ['index.md', 'Introduction']
        """)
        config_file = tempfile.NamedTemporaryFile('w', delete=False)
        try:
            config_file.write(ensure_utf(file_contents))
            config_file.flush()
            config_file.close()

            result = config.load_config(config_file=config_file.name)
            self.assertEqual(result['site_name'], expected_result['site_name'])
            self.assertEqual(result['pages'], expected_result['pages'])
        finally:
            os.remove(config_file.name)
开发者ID:geoconnections,项目名称:mkdocs,代码行数:27,代码来源:config_tests.py


示例4: test_config_option

    def test_config_option(self):
        """
        Users can explicitly set the config file using the '--config' option.
        Allows users to specify a config other than the default `mkdocs.yml`.
        """
        expected_result = {
            'site_name': 'Example',
            'pages': [
                {'Introduction': 'index.md'}
            ],
        }
        file_contents = dedent("""
        site_name: Example
        pages:
        - 'Introduction': 'index.md'
        """)
        with TemporaryDirectory() as temp_path:
            os.mkdir(os.path.join(temp_path, 'docs'))
            config_path = os.path.join(temp_path, 'mkdocs.yml')
            config_file = open(config_path, 'w')

            config_file.write(ensure_utf(file_contents))
            config_file.flush()
            config_file.close()

            result = config.load_config(config_file=config_file.name)
            self.assertEqual(result['site_name'], expected_result['site_name'])
            self.assertEqual(result['pages'], expected_result['pages'])
开发者ID:mkdocs,项目名称:mkdocs,代码行数:28,代码来源:config_tests.py


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


示例6: 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 deprecated and will be removed in a "
                "future MkDocs release. For details on updating: "
                "http://www.mkdocs.org/about/release-notes/")

    # Don't override config value if user did not specify --strict flag
    # Conveniently, load_config drops None values
    strict = strict or None

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


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


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


示例9: test_deploy_no_cname

    def test_deploy_no_cname(self, mock_isfile, mock_import, get_remote,
                             get_sha, is_repo):

        config = load_config(
            remote_branch='test',
        )
        gh_deploy.gh_deploy(config)
开发者ID:Blue-Design,项目名称:mkdocs,代码行数:7,代码来源:gh_deploy_tests.py


示例10: serve_command

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


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


示例12: buildTo

def buildTo(branch):
    print 'Building doc pages for: %s...' % (branch)
    branchCfg = config.load_config()
    if branchCfg['extra']['version'] != branch:
        updateConfigVersion(branch)
    sh.mkdocs('build', '--site-dir', 'site/%s' % (branch))
    if branchCfg['extra']['version'] != branch:
        sh.git('checkout', '--', 'mkdocs.yml')
开发者ID:bgiori,项目名称:incubator-mynewt-site,代码行数:8,代码来源:build.py


示例13: buildForTest

def buildForTest():
    print "Building site pages..."
    updateConfigVersion('develop')
    sh.rm('-rf', 'site')
    sh.mkdocs('build', '--clean')
    sh.git('checkout', '--', 'mkdocs.yml')

    cfg = config.load_config()
    for version in cfg['extra']['versions']:
        deployVersion(version)
开发者ID:apache,项目名称:incubator-mynewt-site,代码行数:10,代码来源:build.py


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


示例15: test_deploy_error

    def test_deploy_error(self, mock_log, mock_import):
        error_string = 'TestError123'
        mock_import.return_value = (False, error_string)

        config = load_config(
            remote_branch='test',
        )

        self.assertRaises(SystemExit, gh_deploy.gh_deploy, config)
        mock_log.error.assert_called_once_with('Failed to deploy to GitHub with error: \n%s',
                                               error_string)
开发者ID:Blue-Design,项目名称:mkdocs,代码行数:11,代码来源:gh_deploy_tests.py


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


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


示例18: main

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


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


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

    # 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python base.dedent函数代码示例发布时间:2022-05-27
下一篇:
Python build.convert_markdown函数代码示例发布时间: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