Esempio n. 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/'
        ])
Esempio n. 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'])
Esempio n. 3
0
File: test.py Progetto: 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"])
Esempio n. 4
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], ['Api guide', 'About'])
        self.assertEqual([p.title for p in pages],
                         ['Home', 'Running', 'Notes', 'License'])
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 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/'
        ])
Esempio n. 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'])
Esempio n. 9
0
 def _test():
     return nav._generate_site_navigation((bad_page, ), None)
Esempio n. 10
0
 def _test():
     return nav._generate_site_navigation((bad_page, ), None)
Esempio n. 11
0
 def _test():
     return nav._generate_site_navigation(
         load_config(pages=[
             bad_page,
         ]), None)
Esempio n. 12
0
 def _test():
     return nav._generate_site_navigation(load_config(pages=[bad_page, ]), None)