|
19 | 19 | 'contents': [{'kind': 'auto', 'name': 'Builder', 'members': []},
|
20 | 20 | 'Builder.from_quarto_config', 'Builder.build', 'Builder.write_index', 'Builder.write_doc_pages', 'Builder.write_sidebar', 'Builder.create_inventory']
|
21 | 21 | },
|
22 |
| - {'title': 'Inventory links', 'desc': 'Inventory files map a functions name to its corresponding url in your docs.\nThese functions allow you to create and transform inventory files.\n', |
23 |
| - 'contents': ['create_inventory', 'convert_inventory'] |
24 |
| - }, |
25 |
| - {'title': 'Data models: structural', |
26 |
| - 'desc': 'Classes for specifying the broad structure your docs.\n', |
27 |
| - 'contents': [{'kind': 'page', |
28 |
| - 'path': 'layouts-structure', |
29 |
| - 'flatten': True, |
30 |
| - 'contents': ['layout.Layout', 'layout.Section', 'layout.Page', 'layout.ContentElement']}] |
31 |
| - }, |
32 |
| - {'title': 'Data models: docable', 'desc': 'Classes representing python objects to be rendered.\n', |
33 |
| - 'contents': [{'kind': 'page', |
34 |
| - 'path': 'layouts-docable', |
35 |
| - 'flatten': True, |
36 |
| - 'contents': [{'name': 'layout.Doc', 'members': []}, 'layout.DocFunction', 'layout.DocAttribute', 'layout.DocModule', 'layout.DocClass', 'layout.Link', 'layout.Item', 'layout.ChoicesChildren']}] |
37 |
| - }, |
38 |
| - {'title': 'Data models: docstring patches', |
39 |
| - 'desc': 'Most of the classes for representing python objects live\nin [](`griffe.dataclasses`) or [](`griffe.docstrings.dataclasses`).\nHowever, the `quartodoc.ast` module has a number of custom classes to fill\nin support for some important docstring sections.\n', |
40 |
| - 'contents': ['ast.DocstringSectionSeeAlso', 'ast.DocstringSectionNotes', 'ast.DocstringSectionWarnings', 'ast.ExampleCode', 'ast.ExampleText'] |
41 |
| - } |
42 | 22 | ]
|
43 | 23 |
|
| 24 | +@pytest.fixture |
| 25 | +def sections(): |
| 26 | + return copy.deepcopy(EXAMPLE_SECTIONS) |
44 | 27 |
|
| 28 | +def test_valid_yaml(sections): |
| 29 | + Builder(sections=sections, package='quartodoc') |
45 | 30 |
|
46 |
| -def test_valid_yaml(): |
47 |
| - Builder(sections=EXAMPLE_SECTIONS, package='quartodoc') |
48 |
| - |
49 |
| -def test_missing_title(): |
50 |
| - sections = copy.deepcopy(EXAMPLE_SECTIONS) |
| 31 | +def test_missing_title(sections): |
51 | 32 | del sections[0]['title']
|
52 | 33 | with pytest.raises(ValueError) as e:
|
53 | 34 | Builder(sections=sections, package='quartodoc')
|
54 | 35 | assert '- Missing field `title` for element 0 in the list for `sections`' in str(e.value)
|
55 | 36 |
|
56 |
| - |
57 |
| -def test_missing_desc(): |
| 37 | +def test_missing_desc(sections): |
58 | 38 | sections = copy.deepcopy(EXAMPLE_SECTIONS)
|
59 | 39 | del sections[2]['desc']
|
60 | 40 | with pytest.raises(ValueError) as e:
|
61 | 41 | Builder(sections=sections, package='quartodoc')
|
62 | 42 | assert '- Missing field `desc` for element 2 in the list for `sections`' in str(e.value)
|
63 | 43 |
|
64 |
| -def test_missing_name_contents_1(): |
65 |
| - sections = copy.deepcopy(EXAMPLE_SECTIONS) |
| 44 | +def test_missing_name_contents_1(sections): |
66 | 45 | del sections[2]['contents'][0]['name']
|
67 | 46 | with pytest.raises(ValueError) as e:
|
68 | 47 | Builder(sections=sections, package='quartodoc')
|
69 | 48 | assert '- Missing field `name` for element 0 in the list for `contents` located in element 2 in the list for `sections`' in str(e.value)
|
70 | 49 |
|
71 |
| -def test_missing_name_contents_2(): |
72 |
| - sections = copy.deepcopy(EXAMPLE_SECTIONS) |
| 50 | +def test_missing_name_contents_2(sections): |
73 | 51 | del sections[1]['contents'][0]['name']
|
74 | 52 | with pytest.raises(ValueError) as e:
|
75 | 53 | Builder(sections=sections, package='quartodoc')
|
76 | 54 | assert '- Missing field `name` for element 0 in the list for `contents` located in element 1 in the list for `sections`' in str(e.value)
|
77 | 55 |
|
78 |
| -def test_misplaced_kindpage(): |
79 |
| - sections = copy.deepcopy(EXAMPLE_SECTIONS) |
| 56 | +def test_misplaced_kindpage(sections): |
80 | 57 | sections[0]['kind'] = 'page'
|
81 | 58 | with pytest.raises(ValueError) as e:
|
82 | 59 | Builder(sections=sections, package='quartodoc')
|
|
0 commit comments