示例#1
0
    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(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/'
        ])
示例#2
0
    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(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'])
示例#3
0
文件: test.py 项目: jpush/mkdocs
    def test_generate_site_navigation_windows(self):
        """
        Verify inferring page titles based on the filename with a windows path
        """
        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(pages, url_context)

        self.assertEqual([n.title for n in nav_items], ["Home", "Api guide", "About"])
        self.assertEqual([p.title for p in pages], ["Home", "Running", "Notes", "License"])
示例#4
0
文件: test.py 项目: dieg0vb/mkdocs
    def test_generate_site_navigation_windows(self):
        """
        Verify inferring page titles based on the filename with a windows path
        """
        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(pages, url_context)

        self.assertEqual([n.title for n in nav_items], ['Api guide', 'About'])
        self.assertEqual([p.title for p in pages],
                         ['Home', 'Running', 'Notes', 'License'])
示例#5
0
    def test_generate_site_navigation_windows(self):
        """
        Verify inferring page titles based on the filename with a windows path
        """
        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(pages, url_context)

        self.assertEqual([n.title for n in nav_items],
                         ['Home', 'Api guide', 'About'])
        self.assertEqual([p.title for p in pages],
                         ['Home', 'Running', 'Notes', 'License'])
示例#6
0
    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(pages, url_context)

        self.assertEqual([n.title for n in nav_items],
                         ['Home', 'Running', 'Notes', 'License'])
        self.assertEqual([p.title for p in pages],
                         ['Home', 'Running', 'Notes', 'License'])
示例#7
0
    def test_force_abs_urls(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
        nav_items, pages = nav._generate_site_navigation(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/'
        ])
示例#8
0
    def test_generate_site_navigation_windows(self):
        """
        Verify inferring page titles based on the filename with a windows path
        """
        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'])
示例#9
0
 def _test():
     return nav._generate_site_navigation((bad_page, ), None)
示例#10
0
 def _test():
     return nav._generate_site_navigation((bad_page, ), None)
示例#11
0
 def _test():
     return nav._generate_site_navigation(
         load_config(pages=[
             bad_page,
         ]), None)
示例#12
0
 def _test():
     return nav._generate_site_navigation(load_config(pages=[bad_page, ]), None)