Skip to content

Commit 8325859

Browse files
authored
Lint schema titles, descriptions, and comments (#60)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent f99e02f commit 8325859

25 files changed

Lines changed: 158 additions & 114 deletions

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ all: common test
2525
common:
2626
$(JSONSCHEMA) metaschema schemas meta --verbose
2727
$(JSONSCHEMA) lint schemas meta --verbose
28+
$(JSONSCHEMA) validate meta/schemas-root.json --verbose $(SCHEMAS)
2829
$(JSONSCHEMA) validate meta/schemas.json --verbose $(SCHEMAS)
2930
$(JSONSCHEMA) validate meta/test.json --verbose $(TESTS)
3031
$(SHELLCHECK) scripts/*.sh

generate/xbrl/utr/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def create_unit_schema_entry(unit):
4949
symbol = unit.get(f"{UTR_NS}symbol", "")
5050
status = unit.get(f"{UTR_NS}status", "")
5151

52+
if definition.endswith('.'):
53+
definition = definition[:-1]
54+
55+
definition = re.sub(r'\s{2,}', ' ', definition)
56+
5257
entry = {
5358
"const": unit_id,
5459
"title": unit_name,

meta/schemas-root.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"anyOf": [
5+
{
6+
"properties": {
7+
"examples": {
8+
"type": "array",
9+
"minItems": 1
10+
},
11+
"const": true
12+
}
13+
},
14+
{
15+
"properties": {
16+
"examples": {
17+
"type": "array",
18+
"minItems": 3
19+
},
20+
"const": false
21+
}
22+
}
23+
],
24+
"required": [
25+
"x-license",
26+
"title",
27+
"description",
28+
"examples",
29+
"x-links",
30+
"$schema"
31+
],
32+
"properties": {
33+
"$schema": {
34+
"const": "https://json-schema.org/draft/2020-12/schema"
35+
},
36+
"$comment": {
37+
"not": {
38+
"$ref": "../schemas/ietf/uri/uri-reference.json"
39+
}
40+
},
41+
"x-license": {
42+
"const": "https://github.com/sourcemeta/std/blob/main/LICENSE"
43+
},
44+
"x-links": {
45+
"type": "array",
46+
"minItems": 1,
47+
"uniqueItems": true,
48+
"items": {
49+
"$ref": "../schemas/ietf/http/https-url.json"
50+
}
51+
}
52+
}
53+
}

meta/schemas.json

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,39 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"type": "object",
4-
"anyOf": [
5-
{
6-
"properties": {
7-
"examples": {
8-
"type": "array",
9-
"minItems": 1
10-
},
11-
"const": true
12-
}
13-
},
14-
{
15-
"properties": {
16-
"examples": {
17-
"type": "array",
18-
"minItems": 3
19-
},
20-
"const": false
21-
}
22-
}
23-
],
24-
"required": [
25-
"x-license",
26-
"title",
27-
"description",
28-
"examples",
29-
"x-links",
30-
"$schema"
31-
],
3+
"$dynamicAnchor": "meta",
4+
"$ref": "https://json-schema.org/draft/2020-12/schema",
325
"properties": {
33-
"$schema": {
34-
"const": "https://json-schema.org/draft/2020-12/schema"
35-
},
366
"$id": false,
377
"$comment": {
38-
"not": {
39-
"$ref": "../schemas/ietf/uri/uri-reference.json"
40-
}
8+
"$ref": "#/$defs/clean-prose"
419
},
42-
"x-license": {
43-
"const": "https://github.com/sourcemeta/std/blob/main/LICENSE"
10+
"title": {
11+
"$ref": "#/$defs/clean-prose"
4412
},
45-
"x-links": {
46-
"type": "array",
47-
"minItems": 1,
48-
"uniqueItems": true,
49-
"items": {
50-
"$ref": "../schemas/ietf/http/https-url.json"
51-
}
13+
"description": {
14+
"$ref": "#/$defs/clean-prose"
15+
}
16+
},
17+
"$defs": {
18+
"clean-prose": {
19+
"type": "string",
20+
"not": {
21+
"anyOf": [
22+
{
23+
"pattern": "\\.$"
24+
},
25+
{
26+
"pattern": " \\s"
27+
},
28+
{
29+
"pattern": "[\\n\\r\\t]"
30+
},
31+
{
32+
"pattern": "[\\x00-\\x1F\\x7F]"
33+
}
34+
]
35+
},
36+
"pattern": "^[^\\s].*[^\\s]$|^[^\\s]$"
5237
}
5338
}
5439
}

schemas/xbrl/utr/duration-item-type-normative.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,56 @@
1111
"anyOf": [
1212
{
1313
"title": "Year",
14-
"description": "Gregorian calendar year of 365 days. Use only as a denominator because durationItemType is not numeric and has no units.",
14+
"description": "Gregorian calendar year of 365 days. Use only as a denominator because durationItemType is not numeric and has no units",
1515
"x-status": "REC",
1616
"x-symbol": "yr",
1717
"const": "Y"
1818
},
1919
{
2020
"title": "Month",
21-
"description": "Gregorian calendar month of 30.41 days. Use only as a denominator because durationItemType is not numeric and has no units.",
21+
"description": "Gregorian calendar month of 30.41 days. Use only as a denominator because durationItemType is not numeric and has no units",
2222
"x-status": "REC",
2323
"x-symbol": "mo",
2424
"const": "M"
2525
},
2626
{
2727
"title": "Day",
28-
"description": "Day of 24 hours. Use only as a denominator because durationItemType is not numeric and has no units.",
28+
"description": "Day of 24 hours. Use only as a denominator because durationItemType is not numeric and has no units",
2929
"x-status": "REC",
3030
"x-symbol": "d",
3131
"const": "D"
3232
},
3333
{
3434
"title": "Hour",
35-
"description": "Hour of 60 minutes. Use only as a denominator because durationItemType is not numeric and has no units.",
35+
"description": "Hour of 60 minutes. Use only as a denominator because durationItemType is not numeric and has no units",
3636
"x-status": "REC",
3737
"x-symbol": "h",
3838
"const": "H"
3939
},
4040
{
4141
"title": "Minute",
42-
"description": "Minute of 60 seconds. Use only as a denominator because durationItemType is not numeric and has no units.",
42+
"description": "Minute of 60 seconds. Use only as a denominator because durationItemType is not numeric and has no units",
4343
"x-status": "REC",
4444
"x-symbol": "m",
4545
"const": "MM"
4646
},
4747
{
4848
"title": "Second",
49-
"description": "Second. Use only as a denominator because durationItemType is not numeric and has no units.",
49+
"description": "Second. Use only as a denominator because durationItemType is not numeric and has no units",
5050
"x-status": "REC",
5151
"x-symbol": "s",
5252
"const": "S"
5353
},
5454
{
5555
"title": "Quarter",
56-
"description": "Gregorian Calendar Quarter (three months). Use only as a denominator because durationItemType is not numeric and has no units.",
56+
"description": "Gregorian Calendar Quarter (three months). Use only as a denominator because durationItemType is not numeric and has no units",
5757
"x-status": "REC",
5858
"x-symbol": "qtr",
5959
"const": "Q"
6060
},
6161
{
6262
"title": "Week",
63-
"description": "Gregorian Calendar Week. Use only as a denominator because durationItemType is not numeric and has no units.",
63+
"description": "Gregorian Calendar Week. Use only as a denominator because durationItemType is not numeric and has no units",
6464
"x-status": "REC",
6565
"x-symbol": "wk",
6666
"const": "WK"

schemas/xbrl/utr/duration-item-type.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,56 @@
1111
"anyOf": [
1212
{
1313
"title": "Year",
14-
"description": "Gregorian calendar year of 365 days. Use only as a denominator because durationItemType is not numeric and has no units.",
14+
"description": "Gregorian calendar year of 365 days. Use only as a denominator because durationItemType is not numeric and has no units",
1515
"x-status": "REC",
1616
"x-symbol": "yr",
1717
"const": "Y"
1818
},
1919
{
2020
"title": "Month",
21-
"description": "Gregorian calendar month of 30.41 days. Use only as a denominator because durationItemType is not numeric and has no units.",
21+
"description": "Gregorian calendar month of 30.41 days. Use only as a denominator because durationItemType is not numeric and has no units",
2222
"x-status": "REC",
2323
"x-symbol": "mo",
2424
"const": "M"
2525
},
2626
{
2727
"title": "Day",
28-
"description": "Day of 24 hours. Use only as a denominator because durationItemType is not numeric and has no units.",
28+
"description": "Day of 24 hours. Use only as a denominator because durationItemType is not numeric and has no units",
2929
"x-status": "REC",
3030
"x-symbol": "d",
3131
"const": "D"
3232
},
3333
{
3434
"title": "Hour",
35-
"description": "Hour of 60 minutes. Use only as a denominator because durationItemType is not numeric and has no units.",
35+
"description": "Hour of 60 minutes. Use only as a denominator because durationItemType is not numeric and has no units",
3636
"x-status": "REC",
3737
"x-symbol": "h",
3838
"const": "H"
3939
},
4040
{
4141
"title": "Minute",
42-
"description": "Minute of 60 seconds. Use only as a denominator because durationItemType is not numeric and has no units.",
42+
"description": "Minute of 60 seconds. Use only as a denominator because durationItemType is not numeric and has no units",
4343
"x-status": "REC",
4444
"x-symbol": "m",
4545
"const": "MM"
4646
},
4747
{
4848
"title": "Second",
49-
"description": "Second. Use only as a denominator because durationItemType is not numeric and has no units.",
49+
"description": "Second. Use only as a denominator because durationItemType is not numeric and has no units",
5050
"x-status": "REC",
5151
"x-symbol": "s",
5252
"const": "S"
5353
},
5454
{
5555
"title": "Quarter",
56-
"description": "Gregorian Calendar Quarter (three months). Use only as a denominator because durationItemType is not numeric and has no units.",
56+
"description": "Gregorian Calendar Quarter (three months). Use only as a denominator because durationItemType is not numeric and has no units",
5757
"x-status": "REC",
5858
"x-symbol": "qtr",
5959
"const": "Q"
6060
},
6161
{
6262
"title": "Week",
63-
"description": "Gregorian Calendar Week. Use only as a denominator because durationItemType is not numeric and has no units.",
63+
"description": "Gregorian Calendar Week. Use only as a denominator because durationItemType is not numeric and has no units",
6464
"x-status": "REC",
6565
"x-symbol": "wk",
6666
"const": "WK"

schemas/xbrl/utr/electric-charge-item-type-normative.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"anyOf": [
1212
{
1313
"title": "Ampere Hours",
14-
"description": "An ampere hour or amp hour is a unit of electric charge, equal to the charge transferred by a steady current of one ampere flowing for one hour.",
14+
"description": "An ampere hour or amp hour is a unit of electric charge, equal to the charge transferred by a steady current of one ampere flowing for one hour",
1515
"x-status": "REC",
1616
"x-symbol": "Ah",
1717
"const": "Ah"
1818
},
1919
{
2020
"title": "Coulomb",
21-
"description": "The coulomb is the International System of Units (SI) unit of electric charge. It is the charge transported by a constant current of one ampere in one second.",
21+
"description": "The coulomb is the International System of Units (SI) unit of electric charge. It is the charge transported by a constant current of one ampere in one second",
2222
"x-status": "REC",
2323
"x-symbol": "C",
2424
"const": "C"

schemas/xbrl/utr/electric-charge-item-type.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"anyOf": [
1212
{
1313
"title": "Ampere Hours",
14-
"description": "An ampere hour or amp hour is a unit of electric charge, equal to the charge transferred by a steady current of one ampere flowing for one hour.",
14+
"description": "An ampere hour or amp hour is a unit of electric charge, equal to the charge transferred by a steady current of one ampere flowing for one hour",
1515
"x-status": "REC",
1616
"x-symbol": "Ah",
1717
"const": "Ah"
1818
},
1919
{
2020
"title": "Coulomb",
21-
"description": "The coulomb is the International System of Units (SI) unit of electric charge. It is the charge transported by a constant current of one ampere in one second.",
21+
"description": "The coulomb is the International System of Units (SI) unit of electric charge. It is the charge transported by a constant current of one ampere in one second",
2222
"x-status": "REC",
2323
"x-symbol": "C",
2424
"const": "C"

schemas/xbrl/utr/energy-item-type-normative.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@
158158
},
159159
{
160160
"title": "Volt-ampere-hours",
161-
"description": "Volt-ampere (VA) hours of energy.",
161+
"description": "Volt-ampere (VA) hours of energy",
162162
"x-status": "REC",
163163
"x-symbol": "VAh",
164164
"const": "VAh"
165165
},
166166
{
167167
"title": "Dekatherm",
168-
"description": "The dekatherm is a unit of energy used to measure natural gas. One dekatherm is equal to 10 therms or one million British thermal units (Btu).",
168+
"description": "The dekatherm is a unit of energy used to measure natural gas. One dekatherm is equal to 10 therms or one million British thermal units (Btu)",
169169
"x-status": "REC",
170170
"x-symbol": "dth",
171171
"const": "dth"
172172
},
173173
{
174174
"title": "Megawatt-Day",
175-
"description": "Megawatt-Day is used to measure energy generated in one day by a power-plant. Is commonly used to define fuel-burnup. A commonly used measure of fuel burnup is the fission energy release per unit mass of fuel.",
175+
"description": "Megawatt-Day is used to measure energy generated in one day by a power-plant. Is commonly used to define fuel-burnup. A commonly used measure of fuel burnup is the fission energy release per unit mass of fuel",
176176
"x-status": "REC",
177177
"x-symbol": "MWd",
178178
"const": "MWd"

schemas/xbrl/utr/energy-item-type.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@
158158
},
159159
{
160160
"title": "Volt-ampere-hours",
161-
"description": "Volt-ampere (VA) hours of energy.",
161+
"description": "Volt-ampere (VA) hours of energy",
162162
"x-status": "REC",
163163
"x-symbol": "VAh",
164164
"const": "VAh"
165165
},
166166
{
167167
"title": "Dekatherm",
168-
"description": "The dekatherm is a unit of energy used to measure natural gas. One dekatherm is equal to 10 therms or one million British thermal units (Btu).",
168+
"description": "The dekatherm is a unit of energy used to measure natural gas. One dekatherm is equal to 10 therms or one million British thermal units (Btu)",
169169
"x-status": "REC",
170170
"x-symbol": "dth",
171171
"const": "dth"
172172
},
173173
{
174174
"title": "Megawatt-Day",
175-
"description": "Megawatt-Day is used to measure energy generated in one day by a power-plant. Is commonly used to define fuel-burnup. A commonly used measure of fuel burnup is the fission energy release per unit mass of fuel.",
175+
"description": "Megawatt-Day is used to measure energy generated in one day by a power-plant. Is commonly used to define fuel-burnup. A commonly used measure of fuel burnup is the fission energy release per unit mass of fuel",
176176
"x-status": "REC",
177177
"x-symbol": "MWd",
178178
"const": "MWd"

0 commit comments

Comments
 (0)