Skip to content

Commit 4a5556f

Browse files
committed
use new templates config directive
1 parent 84b01bb commit 4a5556f

23 files changed

+786
-14
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ Install the generator:
4040

4141
Run the generator:
4242

43-
`generate-schema-doc --config no_show_breadcrumbs --config description_is_markdown --config template_name=$PWD/template schema/object.json html/object.html`
43+
`generate-schema-doc --config no_show_breadcrumbs --config description_is_markdown --config template_folder=$PWD/template --config template_name=la schema/object.json html/object.html`
4444

4545
The options I use:
4646

4747
* `no_show_breadcrumbs`: this prevents it from showing the path through the schema at each stage. We don't care about the structure of the schema in the API docs.
4848
* `description_is_markdown`: parses the `description` field in the schemas as markdown not plain text, allowing links and basic formatting
49-
* `template_name` is normally only `js` or `flat`, but this abuses a side effect of the os.path.join() function to allow passing arbitrary template directories in
49+
* `template_folder` is where templates are available
50+
* `template_name` is the name of the template within the above folder (another directory, with the HTML, CSS and JS files in it)
5051

html/object.html

Lines changed: 306 additions & 1 deletion
Large diffs are not rendered by default.

html/person.html

Lines changed: 235 additions & 1 deletion
Large diffs are not rendered by default.

html/place.html

Lines changed: 197 additions & 1 deletion
Large diffs are not rendered by default.

schema/core.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@
358358
"additionalProperties": false
359359
},
360360
"Statement": {
361+
"title": "E33_Linguistic_Object",
362+
"description": "An embedded, relatively short piece of textual content",
361363
"type": "object",
362364
"properties": {
363365
"_label": {
@@ -620,6 +622,8 @@
620622
"additionalProperties": false
621623
},
622624
"Concept": {
625+
"title": "crm:E55_Type",
626+
"description": "",
623627
"type": "object",
624628
"properties": {
625629
"id": {
@@ -916,7 +920,6 @@
916920
"additionalProperties": false
917921
},
918922
"NameOrIdentifier": {
919-
"title": "Name or Identifier",
920923
"description": "A Name or an Identifier",
921924
"anyOf": [
922925
{
@@ -928,7 +931,6 @@
928931
]
929932
},
930933
"LingObjOrStatement": {
931-
"title": "Linguistic Object Reference or Statement",
932934
"description": "A Linguistic Object Reference or Statement",
933935
"anyOf": [
934936
{
@@ -940,7 +942,6 @@
940942
]
941943
},
942944
"LingObjOrDigitalObjOrStatement": {
943-
"title": "Linguistic Object Reference, Digital Object Reference or Statement",
944945
"description": "A Linguistic Object Reference, Digitial Object Reference or Statement",
945946
"anyOf": [
946947
{
@@ -955,7 +956,6 @@
955956
]
956957
},
957958
"PersonRefOrGroupRef": {
958-
"title": "Reference to a Person or Group",
959959
"description": "A Reference to a Person or Group",
960960
"anyOf": [
961961
{
@@ -987,7 +987,6 @@
987987
]
988988
},
989989
"HumanMadeObjectRefOrPersonRefOrGroupRef": {
990-
"title": "Reference to a Human Made Object, Person or Group",
991990
"description": "A Reference to a Human Made Object,Person or Group",
992991
"anyOf": [
993992
{
@@ -1025,7 +1024,7 @@
10251024
]
10261025
},
10271026
"PlaceRef": {
1028-
"title": "Reference to a Place",
1027+
"title": "crm:E53_Place",
10291028
"description": "Reference to a `Place`",
10301029
"type": "object",
10311030
"properties": {
@@ -1057,7 +1056,7 @@
10571056
"additionalProperties": false
10581057
},
10591058
"PersonRef": {
1060-
"title": "Reference to a Person",
1059+
"title": "E21_Person",
10611060
"description": "Reference to a `Person`",
10621061
"type": "object",
10631062
"properties": {

schema/object.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
"definitions": {
5656
"Production": {
57+
"title": "crm:E12_Production",
58+
"description": "",
5759
"type": "object",
5860
"properties": {
5961
"type": {"allOf": [{"title": "General", "$ref": "core.json#/definitions/typeProp"},
@@ -75,6 +77,8 @@
7577
}
7678
},
7779
"Destruction": {
80+
"title": "crm:E6_Destruction",
81+
"description": "",
7882
"type": "object",
7983
"properties": {
8084
"type": {"allOf": [{"title": "General", "$ref": "core.json#/definitions/typeProp"},
@@ -89,6 +93,8 @@
8993
}
9094
},
9195
"PartRemoval": {
96+
"title": "crm:E80_Part_Removal",
97+
"description": "",
9298
"type": "object",
9399
"properties": {
94100
"type": {"allOf": [{"title": "General", "$ref": "core.json#/definitions/typeProp"},

schema/person.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818
"representation": {"$ref": "core.json#/definitions/representationProp"},
1919
"member_of": {"$ref": "core.json#/definitions/member_ofGroupProp"},
2020
"subject_of": {"$ref": "core.json#/definitions/subject_ofProp"},
21-
2221
"carried_out": {"$ref": "core.json#/definitions/carried_outProp"},
2322
"contact_point": {"$ref": "core.json#/definitions/contact_pointProp"},
2423
"residence": {"$ref": "core.json#/definitions/residenceProp"},
2524

2625
"born": {
26+
"title": "crm:P98i_was_born",
2727
"description": "The event in which this Person was born",
2828
"$ref": "#/definitions/Birth"
2929
},
3030
"died": {
31+
"title": "crm:P100i_died_in",
3132
"description": "The event in which this Person died",
3233
"$ref": "#/definitions/Death"
3334
}
3435
},
3536
"definitions": {
3637
"Birth": {
38+
"title": "crm:E67_Birth",
39+
"description": "The birth event of a person",
3740
"type": "object",
3841
"properties": {
3942
"type": {"allOf": [{"title": "General", "$ref": "core.json#/definitions/typeProp"},
@@ -48,6 +51,8 @@
4851
}
4952
},
5053
"Death": {
54+
"title": "crm:E69_Death",
55+
"description": "The death event of a person",
5156
"type": "object",
5257
"properties": {
5358
"type": {"allOf": [{"title": "General", "$ref": "core.json#/definitions/typeProp"},
File renamed without changes.
File renamed without changes.
File renamed without changes.

template/content.html renamed to template/la/content.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@
2828
<br/>
2929

3030
{%- set description = (schema | get_description) -%}
31+
32+
<!--
33+
<span style="color:red;font-weight:normal;font-style:oblique;font-size:-1;">{{ schema.property_name }} / {{ schema.title }} -> {{ schema.refers_to.title }} </span>
34+
{%- if schema.refers_to.refers_to -%}
35+
<b>{{ schema.refers_to.refers_to.title }}</b>
36+
{%- endif -%}
37+
-->
38+
39+
40+
{%- if schema.refers_to.title and (not schema.property_name or schema.property_name == "items" or (
41+
schema.title and (schema.title.startswith("crm:") or schema.title.startswith("la:")) or (
42+
schema.refers_to.property_name and schema.refers_to.property_name[0].isupper() ) ) ) -%}
43+
<span style="color:black;font-weight:normal;font-style:oblique;font-size:-1;">{{ schema.refers_to.title }}</span>
44+
45+
<!-- elif refers_to.refers_to -->
46+
47+
{%- endif -%}
48+
49+
50+
51+
52+
3153
{%- include "section_description.html" -%}
3254
{%- endif -%}
3355

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

template/section_properties.html renamed to template/la/section_properties.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ <h2 class="mb-0">
1313
{%- if sub_property.is_additional_properties -%}
1414
</em>
1515
{%- endif -%}
16-
{%- if sub_property.refers_to.title -%}
16+
{%- if sub_property.title -%}
17+
<span style="color:black;font-weight:normal;font-style:oblique;font-size:-1;">
18+
{{ " " }}({{ sub_property.title }})
19+
</span>
20+
{%- elif sub_property.refers_to.title -%}
1721
<span style="color:black;font-weight:normal;font-style:oblique;font-size:-1;">
1822
{{ " " }}({{ sub_property.refers_to.title }})
1923
</span>
File renamed without changes.

0 commit comments

Comments
 (0)