def test_unknown_extension(self):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': ['unknown']
     }
     self.assertRaises(
         config_options.ValidationError,
         option.validate, config['markdown_extensions']
     )
 def test_invalid_dict_item(self, mockMd):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': [
             {'key1': 'value', 'key2': 'too many keys'}
         ]
     }
     self.assertRaises(
         config_options.ValidationError,
         option.validate, config['markdown_extensions']
     )
 def test_duplicates(self):
     option = config_options.MarkdownExtensions(builtins=['meta', 'toc'])
     config = {
         'markdown_extensions': ['meta', 'toc']
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['meta', 'toc'],
         'mdx_configs': {}
     }, config)
 def test_invalid_config_item(self, mockMd):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': [
             ['not a dict']
         ]
     }
     self.assertRaises(
         config_options.ValidationError,
         option.validate, config['markdown_extensions']
     )
 def test_none(self):
     option = config_options.MarkdownExtensions(default=[])
     config = {
         'markdown_extensions': None
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': [],
         'mdx_configs': {}
     }, config)
 def test_simple_list(self, mockMd):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': ['foo', 'bar']
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['foo', 'bar'],
         'mdx_configs': {}
     }, config)
 def test_builtins_config(self):
     option = config_options.MarkdownExtensions(builtins=['meta', 'toc'])
     config = {
         'markdown_extensions': [
             {'toc': {'permalink': True}}
         ]
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['meta', 'toc'],
         'mdx_configs': {'toc': {'permalink': True}}
     }, config)
 def test_configkey(self, mockMd):
     option = config_options.MarkdownExtensions(configkey='bar')
     config = {
         'markdown_extensions': [
             {'foo': {'foo_option': 'foo value'}}
         ]
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['foo'],
         'bar': {
             'foo': {'foo_option': 'foo value'}
         }
     }, config)
 def test_mixed_list(self, mockMd):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': [
             'foo',
             {'bar': {'bar_option': 'bar value'}}
         ]
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['foo', 'bar'],
         'mdx_configs': {
             'bar': {'bar_option': 'bar value'}
         }
     }, config)
 def test_list_dicts(self, mockMd):
     option = config_options.MarkdownExtensions()
     config = {
         'markdown_extensions': [
             {'foo': {'foo_option': 'foo value'}},
             {'bar': {'bar_option': 'bar value'}},
             {'baz': None}
         ]
     }
     config['markdown_extensions'] = option.validate(config['markdown_extensions'])
     option.post_validation(config, 'markdown_extensions')
     self.assertEqual({
         'markdown_extensions': ['foo', 'bar', 'baz'],
         'mdx_configs': {
             'foo': {'foo_option': 'foo value'},
             'bar': {'bar_option': 'bar value'}
         }
     }, config)
Example #11
0
    # Specify which css or javascript files from the docs directory should be
    # additionally included in the site.
    ('extra_css', config_options.Type(list, default=[])),
    ('extra_javascript', config_options.Type(list, default=[])),

    # Similar to the above, but each template (HTML or XML) will be build with
    # Jinja2 and the global context.
    ('extra_templates', config_options.Type(list, default=[])),

    # PyMarkdown extension names.
    (
        'markdown_extensions',
        config_options.MarkdownExtensions(
            builtins=['toc', 'tables', 'fenced_code'],
            configkey='mdx_configs',
            default=[],
        ),
    ),

    # PyMarkdown Extension Configs. For internal use only.
    ('mdx_configs', config_options.Private()),

    # enabling strict mode causes MkDocs to stop the build when a problem is
    # encountered rather than display an error.
    ('strict', config_options.Type(bool, default=False)),

    # the remote branch to commit to when using gh-deploy
    (
        'remote_branch',
        config_options.Type(
 def test_not_list(self, mockMd):
     option = config_options.MarkdownExtensions()
     self.assertRaises(config_options.ValidationError,
                       option.validate, 'not a list')