def test_provided(self):

        option = config_options.Extras(utils.is_markdown_file)
        value = option.validate([])
        self.assertEqual([], value)

        option.post_validation({'extra_stuff': []}, 'extra_stuff')
Beispiel #2
0
    def test_talk(self):

        option = config_options.Extras(utils.is_markdown_file)

        tmp_dir = tempfile.mkdtemp()

        f1 = os.path.join(tmp_dir, 'file1.md')
        f2 = os.path.join(tmp_dir, 'file2.md')

        open(f1, 'a').close()

        # symlink isn't available on Python 2 on Windows.
        if hasattr(os, 'symlink'):
            os.symlink('/path/that/doesnt/exist', f2)

        files = list(option.walk_docs_dir(tmp_dir))

        self.assertEqual(['file1.md', ], files)
    def test_invalid(self):

        option = config_options.Extras(utils.is_html_file)
        self.assertRaises(config_options.ValidationError, option.validate, {})
    def test_empty(self):

        option = config_options.Extras(utils.is_template_file)
        value = option.validate(None)
        self.assertEqual(None, value)
Beispiel #5
0
    # A name to use for the link to the project source repo.
    # Default, If repo_url is unset then None, otherwise
    # "GitHub" or "Bitbucket" for known url or Hostname for unknown urls.
    ('repo_name', config_options.Type(utils.string_types)),

    # Specify a URI to the docs dir in the project source repo, relative to the
    # repo_url. When set, a link directly to the page in the source repo will
    # be added to the generated HTML. If repo_url is not set also, this option
    # is ignored.
    ('edit_uri', config_options.Type(utils.string_types)),

    # Specify which css or javascript files from the docs directory should be
    # additionally included in the site. Default, List of all .css and .js
    # files in the docs dir.
    ('extra_css', config_options.Extras(file_match=utils.is_css_file)),
    ('extra_javascript',
     config_options.Extras(file_match=utils.is_javascript_file)),

    # Similar to the above, but each template (HTML or XML) will be build with
    # Jinja2 and the global context.
    ('extra_templates', config_options.Extras()),

    # Determine if the site should include the nav and next/prev elements.
    # Default, True if the site has more than one page, False otherwise.
    ('include_nav', config_options.NumPages()),
    ('include_next_prev', config_options.NumPages()),

    # PyMarkdown extension names.
    ('markdown_extensions',
     config_options.MarkdownExtensions(
Beispiel #6
0
    # A name to use for the link to the project source repo.
    # Default, If repo_url is unset then None, otherwise
    # "GitHub", "Bitbucket" or "GitLab" for known url or Hostname
    # for unknown urls.
    ('repo_name', config_options.Type(utils.string_types)),

    # Specify a URI to the docs dir in the project source repo, relative to the
    # repo_url. When set, a link directly to the page in the source repo will
    # be added to the generated HTML. If repo_url is not set also, this option
    # is ignored.
    ('edit_uri', config_options.Type(utils.string_types)),

    # Specify which css or javascript files from the docs directory should be
    # additionally included in the site.
    ('extra_css', config_options.Extras(file_match=utils.is_css_file, default=[])),
    ('extra_javascript', config_options.Extras(
        file_match=utils.is_javascript_file, 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()),