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

Python base.load_config函数代码示例

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

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



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

示例1: test_not_use_directory_urls

 def test_not_use_directory_urls(self):
     md_text = 'An [internal link](internal.md) to another document.'
     expected = '<p>An <a href="internal/index.html">internal link</a> to another document.</p>'
     config = load_config(pages=['index.md', 'internal.md'], use_directory_urls=False)
     page, nav = build_page(None, 'index.md', config, md_text)
     page.render(config, nav)
     self.assertEqual(page.content.strip(), expected.strip())
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:7,代码来源:build_tests.py


示例2: test_get_files_exclude_readme_with_index

 def test_get_files_exclude_readme_with_index(self, tdir):
     config = load_config(docs_dir=tdir)
     files = get_files(config)
     expected = ['index.md', 'foo.md']
     self.assertIsInstance(files, Files)
     self.assertEqual(len(files), len(expected))
     self.assertEqual([f.src_path for f in files], expected)
开发者ID:mkdocs,项目名称:mkdocs,代码行数:7,代码来源:file_tests.py


示例3: test_populate_page_dirty_modified

 def test_populate_page_dirty_modified(self, site_dir):
     cfg = load_config(site_dir=site_dir)
     file = File('testing.md', cfg['docs_dir'], cfg['site_dir'], cfg['use_directory_urls'])
     page = Page('Foo', file, cfg)
     build._populate_page(page, cfg, Files([file]), dirty=True)
     self.assertTrue(page.markdown.startswith('# Welcome to MkDocs'))
     self.assertTrue(page.content.startswith('<h1 id="welcome-to-mkdocs">Welcome to MkDocs</h1>'))
开发者ID:mkdocs,项目名称:mkdocs,代码行数:7,代码来源:build_tests.py


示例4: test_copying_media

    def test_copying_media(self):
        with TemporaryDirectory() as docs_dir, TemporaryDirectory() as site_dir:
            # Create a non-empty markdown file, image, html file, 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, 'example.html'), '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()

            cfg = load_config(docs_dir=docs_dir, site_dir=site_dir)
            build.build(cfg)

            # 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.assertTrue(os.path.isfile(os.path.join(site_dir, 'example.html')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
开发者ID:jimporter,项目名称:mkdocs,代码行数:31,代码来源:build_tests.py


示例5: test_deploy_ignore_version

    def test_deploy_ignore_version(self, mock_import, check_version, get_remote, get_sha, is_repo):

        config = load_config(
            remote_branch='test',
        )
        gh_deploy.gh_deploy(config, ignore_version=True)
        check_version.assert_not_called()
开发者ID:likaiguo,项目名称:mkdocs,代码行数:7,代码来源:gh_deploy_tests.py


示例6: test_ignore_external_link

 def test_ignore_external_link(self):
     md_text = 'An [external link](http://example.com/external.md).'
     expected = '<p>An <a href="http://example.com/external.md">external link</a>.</p>'
     config = load_config(pages=[{'Home': 'index.md'}])
     page, nav = build_page(None, 'index.md', config, md_text)
     page.render(config, nav)
     self.assertEqual(page.content.strip(), expected.strip())
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:7,代码来源:build_tests.py


示例7: test_BOM

    def test_BOM(self):
        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create an UTF-8 Encoded file with BOM (as Micorsoft editors do). See #1186.
            f = io.open(os.path.join(docs_dir, 'index.md'), 'w', encoding='utf-8-sig')
            f.write('# An UTF-8 encoded file with a BOM')
            f.close()

            cfg = load_config(
                docs_dir=docs_dir,
                site_dir=site_dir
            )
            build.build(cfg)

            # Verify that the file was generated properly.
            # If the BOM is not removed, Markdown will return:
            # `<p>\ufeff# An UTF-8 encoded file with a BOM</p>`.
            f = io.open(os.path.join(site_dir, 'index.html'), 'r', encoding='utf-8')
            output = f.read()
            f.close()
            self.assertTrue(
                '<h1 id="an-utf-8-encoded-file-with-a-bom">An UTF-8 encoded file with a BOM</h1>' in output
            )

        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:28,代码来源:build_tests.py


示例8: test_convert_multiple_internal_links

 def test_convert_multiple_internal_links(self):
     md_text = '[First link](first.md) [second link](second.md).'
     expected = '<p><a href="first/">First link</a> <a href="second/">second link</a>.</p>'
     config = load_config(pages=['index.md', 'first.md', 'second.md'])
     page, nav = build_page(None, 'index.md', config, md_text)
     page.render(config, nav)
     self.assertEqual(page.content.strip(), expected.strip())
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:7,代码来源:build_tests.py


示例9: test_edit_uri_query_string

    def test_edit_uri_query_string(self):

        pages = [
            'index.md',
            'internal.md',
            'sub/internal.md',
            'sub1/sub2/internal.md',
        ]

        # Ensure query strings are supported
        repo_url = 'http://example.com'
        edit_uri = '?query=edit/master/docs/'

        site_navigation = nav.SiteNavigation(load_config(
            pages=pages,
            repo_url=repo_url,
            edit_uri=edit_uri,
            site_dir='site',
            site_url='',
            use_directory_urls=True
        ))

        expected_results = (
            repo_url + edit_uri + pages[0],
            repo_url + edit_uri + pages[1],
            repo_url + edit_uri + pages[2],
            repo_url + edit_uri + pages[3],
        )

        for idx, page in enumerate(site_navigation.walk_pages()):
            self.assertEqual(page.edit_url, expected_results[idx])
开发者ID:jimporter,项目名称:mkdocs,代码行数:31,代码来源:nav_tests.py


示例10: test_strict_mode_valid

    def test_strict_mode_valid(self):
        pages = [
            'index.md',
            'internal.md',
            'sub/internal.md',
        ]

        md_text = "[test](internal.md)"

        config = load_config(pages=pages, strict=False)
        page, nav = build_page(None, 'index.md', config, md_text)
        page.render(config, nav)

        config = load_config(pages=pages, strict=True)
        page, nav = build_page(None, 'index.md', config, md_text)
        page.render(config, nav)
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:16,代码来源:build_tests.py


示例11: test_indented_toc

 def test_indented_toc(self):
     pages = [
         {'Home': 'index.md'},
         {'API Guide': [
             {'Running': 'api-guide/running.md'},
             {'Testing': 'api-guide/testing.md'},
             {'Debugging': 'api-guide/debugging.md'},
         ]},
         {'About': [
             {'Release notes': 'about/release-notes.md'},
             {'License': 'about/license.md'}
         ]}
     ]
     expected = dedent("""
     Home - /
     API Guide
         Running - /api-guide/running/
         Testing - /api-guide/testing/
         Debugging - /api-guide/debugging/
     About
         Release notes - /about/release-notes/
         License - /about/license/
     """)
     site_navigation = nav.SiteNavigation(load_config(pages=pages))
     self.assertEqual(str(site_navigation).strip(), expected)
     self.assertEqual(len(site_navigation.nav_items), 3)
     self.assertEqual(len(site_navigation.pages), 6)
开发者ID:jimporter,项目名称:mkdocs,代码行数:27,代码来源:nav_tests.py


示例12: test_edit_uri_sub_dir_missing_slash

    def test_edit_uri_sub_dir_missing_slash(self):

        pages = [
            'index.md',
            'internal.md',
            'sub/internal.md',
            'sub1/sub2/internal.md',
        ]

        # Basic test
        repo_url = 'http://example.com/foo'
        edit_uri = 'edit/master/docs'

        site_navigation = nav.SiteNavigation(load_config(
            pages=pages,
            repo_url=repo_url,
            edit_uri=edit_uri,
            site_dir='site',
            site_url='',
            use_directory_urls=True
        ))

        expected_results = (
            repo_url + '/' + edit_uri + '/' + pages[0],
            repo_url + '/' + edit_uri + '/' + pages[1],
            repo_url + '/' + edit_uri + '/' + pages[2],
            repo_url + '/' + edit_uri + '/' + pages[3],
        )

        for idx, page in enumerate(site_navigation.walk_pages()):
            self.assertEqual(page.edit_url, expected_results[idx])
开发者ID:jimporter,项目名称:mkdocs,代码行数:31,代码来源:nav_tests.py


示例13: test_force_abs_urls_with_base

    def test_force_abs_urls_with_base(self):
        """
        Verify force absolute URLs
        """

        pages = [
            'index.md',
            'api-guide/running.md',
            'about/notes.md',
            'about/sub/license.md',
        ]

        url_context = nav.URLContext()
        url_context.force_abs_urls = True
        url_context.base_path = '/foo/'
        nav_items, pages = nav._generate_site_navigation(load_config(pages=pages), url_context)

        self.assertEqual([n.title for n in nav_items],
                         ['Home', 'Running', 'Notes', 'License'])
        self.assertEqual([n.url for n in nav_items], [
            '/foo/',
            '/foo/api-guide/running/',
            '/foo/about/notes/',
            '/foo/about/sub/license/'
        ])
开发者ID:jimporter,项目名称:mkdocs,代码行数:25,代码来源:nav_tests.py


示例14: test_generate_site_navigation

    def test_generate_site_navigation(self):
        """
        Verify inferring page titles based on the filename
        """

        pages = [
            'index.md',
            'api-guide/running.md',
            'about/notes.md',
            'about/sub/license.md',
        ]

        url_context = nav.URLContext()
        nav_items, pages = nav._generate_site_navigation(load_config(pages=pages), url_context)

        self.assertEqual([n.title for n in nav_items],
                         ['Home', 'Running', 'Notes', 'License'])
        self.assertEqual([n.url for n in nav_items], [
            '.',
            'api-guide/running/',
            'about/notes/',
            'about/sub/license/'
        ])
        self.assertEqual([p.title for p in pages],
                         ['Home', 'Running', 'Notes', 'License'])
开发者ID:jimporter,项目名称:mkdocs,代码行数:25,代码来源:nav_tests.py


示例15: test_base_url

 def test_base_url(self):
     pages = [
         'index.md'
     ]
     site_navigation = nav.SiteNavigation(load_config(pages=pages, use_directory_urls=False))
     base_url = site_navigation.url_context.make_relative('/')
     self.assertEqual(base_url, '.')
开发者ID:jimporter,项目名称:mkdocs,代码行数:7,代码来源:nav_tests.py


示例16: test_copy_theme_files

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

                # Heading 1

                This is some text.
            """))
            f.close()

            cfg = load_config(docs_dir=docs_dir, site_dir=site_dir)
            build.build(cfg)

            # Verify only theme media are copied, not templates or Python files.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isdir(os.path.join(site_dir, 'js')))
            self.assertTrue(os.path.isdir(os.path.join(site_dir, 'css')))
            self.assertTrue(os.path.isdir(os.path.join(site_dir, 'img')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '__init__.py')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '__init__.pyc')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, 'base.html')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, 'content.html')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, 'nav.html')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
开发者ID:marcelstoer,项目名称:mkdocs,代码行数:31,代码来源:build_tests.py


示例17: test_edit_uri_sub_dir_missing_slash_windows

    def test_edit_uri_sub_dir_missing_slash_windows(self):

        pages = [
            'index.md',
            'internal.md',
            'sub\\internal.md',
            'sub1\\sub2\\internal.md',
        ]

        # Ensure the '/' is added to the repo_url and edit_uri
        repo_url = 'http://example.com/foo'
        edit_uri = 'edit/master/docs'

        site_navigation = nav.SiteNavigation(load_config(
            pages=pages,
            repo_url=repo_url,
            edit_uri=edit_uri,
            site_dir='site',
            site_url='',
            use_directory_urls=True
        ))

        expected_results = (
            repo_url + '/' + edit_uri + '/' + pages[0],
            repo_url + '/' + edit_uri + '/' + pages[1],
            repo_url + '/' + edit_uri + '/' + pages[2].replace('\\', '/'),
            repo_url + '/' + edit_uri + '/' + pages[3].replace('\\', '/'),
        )

        for idx, page in enumerate(site_navigation.walk_pages()):
            self.assertEqual(page.edit_url, expected_results[idx])
开发者ID:jimporter,项目名称:mkdocs,代码行数:31,代码来源:nav_tests.py


示例18: test_create_media_urls

    def test_create_media_urls(self):

        expected_results = {
            'https://media.cdn.org/jq.js': [
                'https://media.cdn.org/jq.js',
                'https://media.cdn.org/jq.js',
                'https://media.cdn.org/jq.js'
            ],
            'http://media.cdn.org/jquery.js': [
                'http://media.cdn.org/jquery.js',
                'http://media.cdn.org/jquery.js',
                'http://media.cdn.org/jquery.js'
            ],
            '//media.cdn.org/jquery.js': [
                '//media.cdn.org/jquery.js',
                '//media.cdn.org/jquery.js',
                '//media.cdn.org/jquery.js'
            ],
            'media.cdn.org/jquery.js': [
                'media.cdn.org/jquery.js',
                'media.cdn.org/jquery.js',
                '../media.cdn.org/jquery.js'
            ],
            'local/file/jquery.js': [
                'local/file/jquery.js',
                'local/file/jquery.js',
                '../local/file/jquery.js'
            ],
            'local\\windows\\file\\jquery.js': [
                'local/windows/file/jquery.js',
                'local/windows/file/jquery.js',
                '../local/windows/file/jquery.js'
            ],
            'image.png': [
                'image.png',
                'image.png',
                '../image.png'
            ],
            'style.css?v=20180308c': [
                'style.css?v=20180308c',
                'style.css?v=20180308c',
                '../style.css?v=20180308c'
            ],
            '#some_id': [
                '#some_id',
                '#some_id',
                '#some_id'
            ]
        }

        cfg = load_config(use_directory_urls=False)
        pages = [
            Page('Home', File('index.md',  cfg['docs_dir'], cfg['site_dir'], cfg['use_directory_urls']), cfg),
            Page('About', File('about.md',  cfg['docs_dir'], cfg['site_dir'], cfg['use_directory_urls']), cfg),
            Page('FooBar', File('foo/bar.md',  cfg['docs_dir'], cfg['site_dir'], cfg['use_directory_urls']), cfg)
        ]

        for i, page in enumerate(pages):
            urls = utils.create_media_urls(expected_results.keys(), page)
            self.assertEqual([v[i] for v in expected_results.values()], urls)
开发者ID:mkdocs,项目名称:mkdocs,代码行数:60,代码来源:utils_tests.py


示例19: test_edit_uri_fragment_windows

    def test_edit_uri_fragment_windows(self):

        pages = [
            'index.md',
            'internal.md',
            'sub\\internal.md',
            'sub1\\sub2\\internal.md',
        ]

        # Ensure fragment strings are supported
        repo_url = 'http://example.com'
        edit_uri = '#fragment/edit/master/docs/'

        site_navigation = nav.SiteNavigation(load_config(
            pages=pages,
            repo_url=repo_url,
            edit_uri=edit_uri,
            site_dir='site',
            site_url='',
            use_directory_urls=True
        ))

        expected_results = (
            repo_url + edit_uri + pages[0],
            repo_url + edit_uri + pages[1],
            repo_url + edit_uri + pages[2].replace('\\', '/'),
            repo_url + edit_uri + pages[3].replace('\\', '/'),
        )

        for idx, page in enumerate(site_navigation.walk_pages()):
            self.assertEqual(page.edit_url, expected_results[idx])
开发者ID:jimporter,项目名称:mkdocs,代码行数:31,代码来源:nav_tests.py


示例20: 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:likaiguo,项目名称:mkdocs,代码行数:7,代码来源:gh_deploy_tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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