コード例 #1
0
 def test_custom_dir_only(self):
     custom = tempfile.mkdtemp()
     theme = Theme(name=None, custom_dir=custom)
     self.assertEqual(
         theme.dirs,
         [custom, mkdocs_templates_dir],
     )
コード例 #2
0
 def test_inherited_theme(self):
     m = mock.Mock(side_effect=[
         {
             'extends': 'readthedocs',
             'static_templates': ['child.html']
         },
         {
             'static_templates': ['parent.html']
         },
     ], )
     with mock.patch('mkdocs.utils.yaml_load', m) as m:
         theme = Theme(name='mkdocs')
         self.assertEqual(m.call_count, 2)
         self.assertEqual(
             theme.dirs,
             [
                 os.path.join(theme_dir, 'mkdocs'),
                 os.path.join(theme_dir, 'readthedocs'),
                 mkdocs_templates_dir,
             ],
         )
         self.assertEqual(
             theme.static_templates,
             {
                 'sitemap.xml',
                 'child.html',
                 'parent.html',
             },
         )
コード例 #3
0
 def test_simple_theme(self):
     theme = Theme(name='mkdocs')
     self.assertEqual(
         theme.dirs,
         [os.path.join(theme_dir, 'mkdocs'), mkdocs_templates_dir],
     )
     self.assertEqual(theme.static_templates, {'404.html', 'sitemap.xml'})
     self.assertEqual(
         get_vars(theme),
         {
             'include_search_page': False,
             'search_index_only': False,
             'highlightjs': True,
             'hljs_style': 'github',
             'hljs_languages': [],
             'navigation_depth': 2,
             'nav_style': 'primary',
             'shortcuts': {
                 'help': 191,
                 'next': 78,
                 'previous': 80,
                 'search': 83
             },
         },
     )
コード例 #4
0
 def test_vars(self):
     theme = Theme(name='mkdocs', foo='bar', baz=True)
     self.assertEqual(theme['foo'], 'bar')
     self.assertEqual(theme['baz'], True)
     self.assertTrue('new' not in theme)
     self.assertRaises(KeyError, lambda t, k: t[k], theme, 'new')
     theme['new'] = 42
     self.assertTrue('new' in theme)
     self.assertEqual(theme['new'], 42)
コード例 #5
0
 def test_custom_dir(self):
     custom = tempfile.mkdtemp()
     theme = Theme(name='mkdocs', custom_dir=custom)
     self.assertEqual(
         theme.dirs,
         [
             custom,
             os.path.join(theme_dir, 'mkdocs'),
             mkdocs_templates_dir,
         ],
     )
コード例 #6
0
 def test_no_theme_config(self, m):
     theme = Theme(name='mkdocs')
     self.assertEqual(m.call_count, 1)
     self.assertEqual(theme.static_templates, {'sitemap.xml'})
コード例 #7
0
 def static_templates(self):
     theme = Theme(name='mkdocs', static_templates='foo.html')
     self.assertEqual(
         theme.static_templates,
         {'404.html', 'sitemap.xml', 'foo.html'},
     )