Skip to content

Commit 40844de

Browse files
author
james-ball-qualcomm
authored
Merge pull request #119 from riscv/118-display-kind-and-instances
Cleaning up norm rule schema to remove unused features and add more flexibility
2 parents 7f7f63a + aa8e26f commit 40844de

File tree

9 files changed

+160
-182
lines changed

9 files changed

+160
-182
lines changed

schemas/common-schema.json

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"description": "Comprehensive description of the normative rule (sentence, paragraph, or longer)"
1111
},
1212
"kindRuleDesc": {
13-
"description": "The kind of ISA object associated with this normative rule"
13+
"description": "The kind of standards object associated with this normative rule"
14+
},
15+
"instanceRuleDesc": {
16+
"description": "The name of a standards object of the specified kind associated with this normative rule"
1417
},
1518
"instancesRuleDesc": {
16-
"description": "The names of ISA object instances of the specified kind associated with this normative rule"
19+
"description": "The names of standards objects of the specified kind associated with this normative rule"
1720
},
1821
"stringArray": {
1922
"type": "array",
@@ -25,7 +28,7 @@
2528
"tagNamePattern" : {
2629
"pattern": "^[a-zA-z][:a-zA-z0-9_-]+$"
2730
},
28-
"isaObjectKind": {
31+
"stdsObjectKind": {
2932
"type": "string",
3033
"enum": ["extension", "instruction", "csr", "csr_field", "parameter"]
3134
},
@@ -44,29 +47,11 @@
4447
"type": "string",
4548
"$ref": "#/tagNamePattern"
4649
},
47-
"tagObject": {
48-
"type": "object",
49-
"properties": {
50-
"name": { "$ref": "#/tagName" },
51-
"kind": {
52-
"$ref": "#/isaObjectKind",
53-
"description": "The kind of ISA object associated with this tag"
54-
},
55-
"instances": {
56-
"$ref": "#/stringArray",
57-
"description": "The names of ISA object instances of the specified kind associated with this tag"
58-
}
59-
},
60-
"required": ["name"],
61-
"additionalProperties": false
62-
},
63-
"tagArray": {
50+
"tagNameArray": {
6451
"type": "array",
6552
"items": {
66-
"anyOf": [
67-
{ "$ref": "#/tagName" },
68-
{ "$ref": "#/tagObject" }
69-
]
53+
"type": "string",
54+
"$ref": "#/tagNamePattern"
7055
}
7156
}
7257
}

schemas/defs-schema.json

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"chapter_name": {
1111
"type": "string",
12-
"description": "Name of chapter in standards doc associated with these normative rules definitions"
12+
"description": "Name of chapter (keep it short) in standards document associated with normative rules definitions"
1313
},
1414
"normative_rule_definitions": {
1515
"type": "array",
@@ -34,32 +34,46 @@
3434
},
3535
"kind": {
3636
"allOf": [
37-
{ "$ref": "common-schema.json#/isaObjectKind" },
37+
{ "$ref": "common-schema.json#/stdsObjectKind" },
3838
{ "$ref": "common-schema.json#/kindRuleDesc" }
3939
]
4040
},
41+
"instance": {
42+
"type": "string",
43+
"$ref": "common-schema.json#/instanceRuleDesc"
44+
},
4145
"instances": {
4246
"allOf": [
4347
{ "$ref": "common-schema.json#/stringArray" },
4448
{ "$ref": "common-schema.json#/instancesRuleDesc" }
4549
]
4650
},
47-
"tags": {
48-
"$ref": "common-schema.json#/tagArray",
49-
"description": "List of normative rule tags that have normative text from adoc files"
51+
"tag": {
52+
"$ref": "common-schema.json#/tagName",
53+
"description": "Name of tag containing normative text"
5054
},
51-
"tags_without_text": {
52-
"$ref": "common-schema.json#/tagArray",
53-
"description": "List of normative rule tags that don't have normative text (just an anchor) from adoc files"
55+
"tags": {
56+
"$ref": "common-schema.json#/tagNameArray",
57+
"description": "List of tag names containing normative text"
5458
}
5559
},
56-
"oneOf": [
57-
{ "required": ["name"] },
58-
{ "required": ["names"] }
59-
],
60-
"anyOf": [
61-
{ "required": ["tags"] },
62-
{ "required": ["tags_without_text"] }
60+
"allOf": [
61+
{
62+
"oneOf": [
63+
{ "required": ["name"] },
64+
{ "required": ["names"] }
65+
]
66+
},
67+
{
68+
"not": {
69+
"required": ["tag", "tags"]
70+
}
71+
},
72+
{
73+
"not": {
74+
"required": ["instance", "instances"]
75+
}
76+
}
6377
],
6478
"additionalProperties": false
6579
}

schemas/norm-rules-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"kind": {
3333
"allOf": [
34-
{ "$ref": "common-schema.json#/isaObjectKind" },
34+
{ "$ref": "common-schema.json#/stdsObjectKind" },
3535
{ "$ref": "common-schema.json#/kindRuleDesc" }
3636
]
3737
},

tests/norm-rule/expected/test-norm-rules.adoc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44

55
[cols="20%,20%,60%"]
66
|===
7-
| Rule Name | Link to Standard | Text from Standard
7+
| Rule Name | Info Source | Info Text
88

9-
.2+| inline
9+
.4+| inline
1010
| Summary | A few words
11+
| Kind | extension
12+
[Zicsr, ABC]
1113
a| link:test.html#norm:inline[norm:inline] | inside inline
1214

15+
.1+| no_tag
16+
| Summary | Normative rule without tag/tags
17+
1318
.2+| paragraph-with-a-really-wide-rule-name
1419
| Description | Here's a description.
1520
It's got 2 lines.
@@ -148,8 +153,10 @@ Paragraph 3
148153
a| link:test.html#norm:admonition:only-anchors-in-notes:note1[norm:admonition:only-anchors-in-notes:note1] | Paragraph X
149154
a| link:test.html#norm:admonition:only-anchors-in-notes:note3[norm:admonition:only-anchors-in-notes:note3] | Paragraph Z
150155

151-
.3+| admon5
156+
.5+| admon5
152157
| Description | One line description
158+
| Kind | parameter
159+
[MY_PARAMETER]
153160
a| link:test.html#norm:admonition:anchors-in-notes:note1[norm:admonition:anchors-in-notes:note1] | Paragraph 1
154161
a| link:test.html#norm:admonition:anchors-in-notes:note3[norm:admonition:anchors-in-notes:note3] | Paragraph 3
155162
|===

tests/norm-rule/expected/test-norm-rules.html

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,31 @@ <h3>my-chapter_name</h3>
106106
<col class="col-text">
107107
</colgroup>
108108
<thead>
109-
<tr><th>Rule Name</th><th>Link to Standard</th><th>Text from Standard</th></tr>
109+
<tr><th>Rule Name</th><th>Info Source</th><th>Info Text</th></tr>
110110
</thead>
111111
<tbody>
112112
<tr>
113-
<td rowspan=2>inline</td>
113+
<td rowspan=4>inline</td>
114114
<td>Summary</td>
115115
<td>A few words</td>
116116
</tr>
117+
<tr>
118+
<td>Kind</td>
119+
<td>extension</td>
120+
</tr>
121+
<tr>
122+
<td>Instances</td>
123+
<td>[Zicsr, ABC]</td
124+
</tr>
117125
<tr>
118126
<td><a href="test.html#norm:inline">norm:inline</a></td>
119127
<td>inside inline</td></tr>
120128
</tr>
129+
<tr>
130+
<td rowspan=1>no_tag</td>
131+
<td>Summary</td>
132+
<td>Normative rule without tag/tags</td>
133+
</tr>
121134
<tr>
122135
<td rowspan=2>paragraph-with-a-really-wide-rule-name</td>
123136
<td>Description</td>
@@ -275,10 +288,18 @@ <h3>my-chapter_name</h3>
275288
<td>Paragraph Z</td></tr>
276289
</tr>
277290
<tr>
278-
<td rowspan=3>admon5</td>
291+
<td rowspan=5>admon5</td>
279292
<td>Description</td>
280293
<td>One line description</td>
281294
</tr>
295+
<tr>
296+
<td>Kind</td>
297+
<td>parameter</td>
298+
</tr>
299+
<tr>
300+
<td>Instances</td>
301+
<td>[MY_PARAMETER]</td
302+
</tr>
282303
<tr>
283304
<td><a href="test.html#norm:admonition:anchors-in-notes:note1">norm:admonition:anchors-in-notes:note1</a></td>
284305
<td>Paragraph 1</td></tr>

tests/norm-rule/expected/test-norm-rules.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
}
1919
]
2020
},
21+
{
22+
"name": "no_tag",
23+
"def_filename": "tests/norm-rule/test.yaml",
24+
"chapter_name": "my-chapter_name",
25+
"summary": "Normative rule without tag/tags",
26+
"tags": []
27+
},
2128
{
2229
"name": "paragraph-with-a-really-wide-rule-name",
2330
"def_filename": "tests/norm-rule/test.yaml",
48 Bytes
Binary file not shown.

tests/norm-rule/test.yaml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,78 +12,80 @@ normative_rule_definitions:
1212
summary: A few words
1313
kind: extension
1414
instances: [Zicsr, ABC]
15-
tags: ["norm:inline"]
15+
tag: "norm:inline"
16+
- name: no_tag
17+
summary: Normative rule without tag/tags
1618

1719
# Paragraph
1820
- name: paragraph-with-a-really-wide-rule-name
1921
description: |
2022
Here's a description.
2123
It's got 2 lines.
22-
tags: ["norm:paragraph:no-inline-anchors"]
24+
tag: "norm:paragraph:no-inline-anchors"
2325
- name: inline-anchors-in-paragraph-entire
24-
tags: ["norm:paragraph:inline-anchors:entire"]
26+
tag: "norm:paragraph:inline-anchors:entire"
2527
- name: inline-anchors-in-paragraph-inline-anchor
26-
tags: ["norm:paragraph:inline-anchors:inline-anchor"]
28+
tag: "norm:paragraph:inline-anchors:inline-anchor"
2729
- name: formulae
28-
tags: ["norm:formulae"]
30+
tag: "norm:formulae"
2931
- name: rule_with_newlines
30-
tags: ["norm:paragraph:tag_with_newlines"]
32+
tag: "norm:paragraph:tag_with_newlines"
3133
- name: double_tags
32-
tags: ["norm:def"]
34+
tag: "norm:def"
3335

3436
# Table
3537
- name: table1
36-
tags: ["norm:table:anchors-in-cells:entire-table"]
38+
tag: "norm:table:anchors-in-cells:entire-table"
3739
- name: table2
38-
tags: ["norm:table:no-anchors-in-cells:entire-table"]
40+
tag: "norm:table:no-anchors-in-cells:entire-table"
3941
- name: table3
40-
tags: ["norm:table:anchors-in-cells:entire-table-tagged:cell"]
42+
tag: "norm:table:anchors-in-cells:entire-table-tagged:cell"
4143
- name: table4
42-
tags: ["norm:table:anchors-in-cells:entire-table-not-tagged:cell"]
44+
tag: "norm:table:anchors-in-cells:entire-table-not-tagged:cell"
4345
- name: table5
44-
tags: ["norm:table:many-rows"]
46+
tag: "norm:table:many-rows"
4547

4648
# Unordered lists
4749
- name: unordered1
48-
tags: ["norm:unordered-list:no-anchors-in-items:entire-list"]
50+
tag: "norm:unordered-list:no-anchors-in-items:entire-list"
4951
- name: unordered2
50-
tags: ["norm:unordered-list:anchors-in-items:entire-list"]
52+
tag: "norm:unordered-list:anchors-in-items:entire-list"
5153
- name: unordered3
52-
tags: ["norm:unordered-list:anchors-in-items:item1"]
54+
tag: "norm:unordered-list:anchors-in-items:item1"
5355
- name: unordered4
54-
tags: ["norm:unordered-list:anchors-in-items:item2"]
56+
tag: "norm:unordered-list:anchors-in-items:item2"
5557
- name: unordered5
56-
tags: ["norm:unordered-list:multiple-levels"]
58+
tag: "norm:unordered-list:multiple-levels"
5759

5860
# Ordered lists
5961
- name: ordered1
60-
tags: ["norm:ordered-list:no-anchors-in-items:entire-list"]
62+
tag: "norm:ordered-list:no-anchors-in-items:entire-list"
6163
- name: ordered2
62-
tags: ["norm:ordered-list:anchors-in-items:entire-list"]
64+
tag: "norm:ordered-list:anchors-in-items:entire-list"
6365
- name: ordered3
64-
tags: ["norm:ordered-list:anchors-in-items:item1"]
66+
tag: "norm:ordered-list:anchors-in-items:item1"
6567
- name: ordered4
66-
tags: ["norm:ordered-list:anchors-in-items:item2"]
68+
tag: "norm:ordered-list:anchors-in-items:item2"
6769

6870
# Description lists
6971
- name: desc1
70-
tags: ["norm:description-list:no-anchors-in-items:entire-list"]
72+
tag: "norm:description-list:no-anchors-in-items:entire-list"
7173
- name: desc2
72-
tags: ["norm:description-list:anchors-in-items:entire-list"]
74+
tag: "norm:description-list:anchors-in-items:entire-list"
7375
- names: [desc3, desc4]
7476
tags: ["norm:description-list:anchors-in-items:item1", "norm:description-list:anchors-in-items:item3"]
7577

7678
# Admonitions
7779
- name: admon1
78-
tags: ["norm:admonition:single-paragraph-note"]
80+
tag: "norm:admonition:single-paragraph-note"
7981
- name: admon2
80-
tags: ["norm:admonition:no-anchors-in-notes:entire-note"]
82+
tag: "norm:admonition:no-anchors-in-notes:entire-note"
8183
- name: admon3
82-
tags: ["norm:admonition:anchors-in-notes:entire-note"]
84+
tag: "norm:admonition:anchors-in-notes:entire-note"
8385
- name: admon4
8486
tags: ["norm:admonition:only-anchors-in-notes:note1", "norm:admonition:only-anchors-in-notes:note3"]
8587
- name: admon5
8688
description: One line description
8789
kind: parameter
88-
instances: [MY_PARAMETER]
90+
instance: MY_PARAMETER
8991
tags: ["norm:admonition:anchors-in-notes:note1", "norm:admonition:anchors-in-notes:note3"]

0 commit comments

Comments
 (0)