You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: 🏗️ add interface for an umbrella extensions class (#156)
# Description
Related to some discussions like in #120 and #122 about how we handle
custom checks/extensions to the checks against the Data Package
standard.
Closes#152
Needs an in-depth review.
## Checklist
- [x] Formatted Markdown
- [x] Ran `just run-all`
---------
Co-authored-by: Signe Kirk Brødbæk <[email protected]>
Co-authored-by: martonvago <[email protected]>
Each extension class must implement its own `apply()` method that takes
200
+
the `datapackage.json` properties `dict` as input and outputs an `Issue`
201
+
list that contains the issues found by that extension.
202
+
203
+
#### {{< var wip >}} `RequiredCheck`
149
204
150
-
A sub-item of `Config`. Expresses a custom check.
205
+
A sub-item of `Extensions` that allows users to set specific properties
206
+
as required that are not required by the Data Package standard. See the
207
+
help documentation with `help(RequiredCheck)` for more details.
151
208
209
+
#### {{< var done >}} `CustomCheck`
210
+
211
+
A sub-item of `Extensions` that allows users to add an additional, custom
212
+
check that `check-datapackage` will run alongside the standard checks.
152
213
See the help documentation with `help(CustomCheck)` for more details.
153
214
154
215
### {{< var done >}} `Issue`
@@ -159,20 +220,61 @@ Package.
159
220
See the help documentation with
160
221
[`help(Issue)`](/docs/reference/Issue.qmd) for more details.
161
222
223
+
## {{< var planned >}} Configuration file
224
+
225
+
When we develop the CLI, we'll use a config file to store the settings
226
+
contained within the `Config` class. This file will be named `.cdp.toml`
227
+
and will be located in the same directory as the `datapackage.json`
228
+
file. This is an example of what that file could look like:
229
+
230
+
```toml
231
+
# The Data Package standard version to check against.
232
+
version = "v2"
233
+
234
+
# Whether to check properties that must *and should* be included.
235
+
strict = true
236
+
237
+
# Exclude all issues related to the "resources" property.
238
+
[[exclusions]]
239
+
jsonpath = "$.resources"
240
+
241
+
# Exclude all issues related to the "format" type in the schema.
242
+
[[exclusions]]
243
+
type = "format"
244
+
245
+
# Exclude issues that are both a "pattern" type and found in
246
+
# the "path" property of the "contributors" field.
247
+
[[exclusions]]
248
+
jsonpath = "$.contributors[*].path"
249
+
type = "pattern"
250
+
251
+
# Require that the "description" property is included in the Data Package.
252
+
[[extensions.required_checks]]
253
+
jsonpath = "$.description"
254
+
message = "This Data Package needs to include a 'description' property."
255
+
256
+
# A custom check to ensure that all resource names are lowercase.
257
+
[[extensions.custom_checks]]
258
+
jsonpath = "$.resources[*].name"
259
+
type = "name-lowercase"
260
+
message = "The value in the 'name' property of the 'resources' must be lowercase."
261
+
check = "lambda name: name.islower()"
262
+
```
263
+
162
264
## Flow
163
265
164
266
This is the potential flow of using `check-datapackage`:
165
267
166
268
```{mermaid}
167
269
%%| label: fig-interface-flow
168
270
%%| fig-cap: "Flow of functions and classes when using `check-datapackage`."
169
-
%%| fig-alt: "A flowchart showing the flow of using `check-datapackage`, starting with reading the datapackage.json and .cdp.yaml files, then checking the descriptor with the config, and finally explaining any issues found."
271
+
%%| fig-alt: "A flowchart showing the flow of using `check-datapackage`, starting with reading the `datapackage.json` and `.cdp.toml` files, then checking the descriptor with the config, and finally explaining any issues found."
0 commit comments