Skip to content

Commit

Permalink
Unit test confirming all plugin hooks are documented
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 26, 2018
1 parent ba64cfb commit 3ac21c7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
import re

docs_path = Path(__file__).parent.parent / 'docs'
markdown = (docs_path / 'config.rst').open().read()
setting_heading_re = re.compile(r'(\w+)\n\-+\n')
setting_headings = set(setting_heading_re.findall(markdown))


def get_headings(filename, underline="-"):
markdown = (docs_path / filename).open().read()
heading_re = re.compile(r'(\S+)\n\{}+\n'.format(underline))
return set(heading_re.findall(markdown))


@pytest.mark.parametrize('config', app.CONFIG_OPTIONS)
def test_config_options_are_documented(config):
assert config.name in setting_headings
assert config.name in get_headings("config.rst")


@pytest.mark.parametrize('name,filename', (
Expand All @@ -35,3 +38,13 @@ def test_help_includes(name, filename):
# because it doesn't know that cli will be aliased to datasette
expected = expected.replace('Usage: datasette', 'Usage: cli')
assert expected == actual


@pytest.mark.parametrize('plugin', [
name for name in dir(app.pm.hook) if not name.startswith('_')
])
def test_plugin_hooks_are_documented(plugin):
headings = [
s.split("(")[0] for s in get_headings("plugins.rst", "~")
]
assert plugin in headings

0 comments on commit 3ac21c7

Please sign in to comment.