-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdodo.py
136 lines (115 loc) · 5.15 KB
/
dodo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from lattice import Lattice
from pathlib import Path
from doit.tools import create_folder
SOURCE_PATH = "lattice"
EXAMPLES_PATH = "examples"
BUILD_PATH = "build"
examples = []
for example_dir in sorted([str(dir_name) for dir_name in Path(EXAMPLES_PATH).iterdir()]):
example_dir_path = Path(example_dir)
example_name = example_dir_path.name
if example_dir_path.is_dir():
build_dir_path = Path(BUILD_PATH, example_name)
create_folder(build_dir_path)
examples.append(
Lattice(example_dir_path, build_dir_path, build_output_directory_name=None, build_validation=False)
)
BASE_META_SCHEMA_PATH = Path(SOURCE_PATH, "meta.schema.yaml")
CORE_SCHEMA_PATH = Path(SOURCE_PATH, "core.schema.yaml")
def task_generate_meta_schemas():
"""Generate JSON meta schemas"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"file_dep": [schema.path for schema in example.schemas]
+ [BASE_META_SCHEMA_PATH, CORE_SCHEMA_PATH, Path(SOURCE_PATH, "meta_schema.py")],
"targets": [schema.meta_schema_path for schema in example.schemas],
"actions": [(example.generate_meta_schemas, [])],
"clean": True,
}
def task_validate_schemas():
"""Validate the example schemas against the JSON meta schema"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"task_dep": [f"generate_meta_schemas:{name}"],
"file_dep": [schema.path for schema in example.schemas]
+ [schema.meta_schema_path for schema in example.schemas]
+ [BASE_META_SCHEMA_PATH, CORE_SCHEMA_PATH, Path(SOURCE_PATH, "meta_schema.py")],
"actions": [(example.validate_schemas, [])],
}
def task_generate_json_schemas():
"""Generate JSON schemas"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"task_dep": [f"validate_schemas:{name}"],
"file_dep": [schema.path for schema in example.schemas]
+ [schema.meta_schema_path for schema in example.schemas]
+ [CORE_SCHEMA_PATH, BASE_META_SCHEMA_PATH, Path(SOURCE_PATH, "schema_to_json.py")],
"targets": [schema.json_schema_path for schema in example.schemas],
"actions": [(example.generate_json_schemas, [])],
"clean": True,
}
def task_validate_example_files():
"""Validate example files against JSON schema"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"file_dep": [schema.json_schema_path for schema in example.schemas]
+ example.examples
+ [Path(SOURCE_PATH, "schema_to_json.py")],
"task_dep": [f"generate_json_schemas:{name}"],
"actions": [(example.validate_example_files, [])],
}
def task_generate_markdown():
"""Generate markdown documentation from templates"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"targets": [template.markdown_output_path for template in example.doc_templates],
"file_dep": [schema.path for schema in example.schemas]
+ [template.path for template in example.doc_templates]
+ [Path(SOURCE_PATH, "docs", "grid_table.py")],
"task_dep": [f"validate_schemas:{name}"],
"actions": [(example.generate_markdown_documents, [])],
"clean": True,
}
def task_generate_cpp_code():
"""Generate CPP headers and source for example schema."""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"task_dep": [f"validate_schemas:{name}"],
"file_dep": [schema.path for schema in example.cpp_schemas]
+ [schema.meta_schema_path for schema in example.schemas]
+ [CORE_SCHEMA_PATH, BASE_META_SCHEMA_PATH, Path(SOURCE_PATH, "header_entries.py")],
"targets": [schema.cpp_header_path for schema in example.cpp_schemas]
+ [schema.cpp_source_path for schema in example.cpp_schemas]
+ example.cpp_support_headers(),
"actions": [(example.generate_cpp_headers, [])],
"clean": True,
}
def task_generate_web_docs():
"""Generate markdown documentation from templates"""
for example in examples:
name = Path(example.root_directory).name
yield {
"name": name,
"task_dep": [f"validate_schemas:{name}", f"generate_json_schemas:{name}", f"validate_example_files:{name}"],
"file_dep": [schema.path for schema in example.schemas]
+ [template.path for template in example.doc_templates]
+ [Path(SOURCE_PATH, "docs", "mkdocs_web.py")],
"targets": [Path(example.web_docs_directory_path, "public")],
"actions": [(example.generate_web_documentation, [])],
"clean": True,
}
def task_test():
"""Run unit tests"""
return {"actions": ["pytest -v test"]}