Skip to content

Commit 0e4378f

Browse files
committed
Add Makefile and course definition reference files
1 parent 4314967 commit 0e4378f

File tree

4 files changed

+280
-0
lines changed

4 files changed

+280
-0
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
copy_course_definition_schema:
2+
cp ../core/data/course_definition_schema.json ./docs/data/course_definition_schema.json
3+
4+
generate_course_definition_reference:
5+
ruby ./scripts/generate_course_definition_reference.rb
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
# generated by scripts/generate_course_definition_reference.rb
3+
title: "Course Definition Reference"
4+
description: "Schema for the course-definition.yml file."
5+
---
6+
7+
8+
<ResponseField name="slug" type="string">
9+
</ResponseField>
10+
11+
12+
<ResponseField name="name" type="string">
13+
</ResponseField>
14+
15+
16+
<ResponseField name="short_name" type="string">
17+
</ResponseField>
18+
19+
20+
<ResponseField name="release_status" type="string">
21+
</ResponseField>
22+
23+
24+
<ResponseField name="description_md" type="string">
25+
</ResponseField>
26+
27+
28+
<ResponseField name="short_description_md" type="string">
29+
</ResponseField>
30+
31+
32+
<ResponseField name="completion_percentage" type="integer">
33+
</ResponseField>
34+
35+
36+
<ResponseField name="languages" type="array">
37+
<Expandable title="item properties">
38+
<ResponseField name="slug" type="string">
39+
</ResponseField>
40+
41+
42+
<ResponseField name="starter_repository_url" type="string">
43+
</ResponseField>
44+
45+
46+
47+
</Expandable>
48+
</ResponseField>
49+
50+
51+
<ResponseField name="marketing" type="object">
52+
<Expandable title="properties">
53+
<ResponseField name="difficulty" type="string">
54+
</ResponseField>
55+
56+
57+
<ResponseField name="sample_extension_idea_title" type="string">
58+
</ResponseField>
59+
60+
61+
<ResponseField name="sample_extension_idea_description" type="string">
62+
</ResponseField>
63+
64+
65+
<ResponseField name="testimonials" type="array">
66+
<Expandable title="item properties">
67+
<ResponseField name="author_name" type="string">
68+
</ResponseField>
69+
70+
71+
<ResponseField name="author_description" type="string">
72+
</ResponseField>
73+
74+
75+
<ResponseField name="author_avatar" type="string">
76+
</ResponseField>
77+
78+
79+
<ResponseField name="link" type="string">
80+
</ResponseField>
81+
82+
83+
<ResponseField name="text" type="string">
84+
</ResponseField>
85+
86+
87+
88+
</Expandable>
89+
</ResponseField>
90+
91+
92+
93+
</Expandable>
94+
</ResponseField>
95+
96+
97+
<ResponseField name="stages" type="array">
98+
<Expandable title="item properties">
99+
<ResponseField name="slug" type="string">
100+
</ResponseField>
101+
102+
103+
<ResponseField name="name" type="string">
104+
</ResponseField>
105+
106+
107+
<ResponseField name="description_md" type="string">
108+
</ResponseField>
109+
110+
111+
<ResponseField name="difficulty" type="string">
112+
</ResponseField>
113+
114+
115+
<ResponseField name="marketing_md" type="string">
116+
</ResponseField>
117+
118+
119+
<ResponseField name="tester_source_code_url" type="string">
120+
</ResponseField>
121+
122+
123+
124+
</Expandable>
125+
</ResponseField>
126+
127+
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-06/schema#",
3+
"type": "object",
4+
"properties": {
5+
"slug": { "type": "string", "minLength": 1 },
6+
"name": { "type": "string", "minLength": 1 },
7+
"short_name": { "type": "string", "minLength": 1 },
8+
"release_status": { "type": "string", "minLength": 1 },
9+
"description_md": { "type": "string", "minLength": 1 },
10+
"short_description_md": { "type": "string", "minLength": 1 },
11+
"completion_percentage": { "type": "integer", "not": { "type": "null" } },
12+
"languages": {
13+
"type": "array",
14+
"items": {
15+
"type": "object",
16+
"properties": {
17+
"slug": { "type": "string", "minLength": 1 },
18+
"starter_repository_url": { "type": "string", "minLength": 1 }
19+
},
20+
"required": ["slug", "starter_repository_url"]
21+
}
22+
},
23+
"marketing": {
24+
"type": "object",
25+
"properties": {
26+
"difficulty": { "type": "string", "minLength": 1 },
27+
"sample_extension_idea_title": { "type": "string", "minLength": 1 },
28+
"sample_extension_idea_description": {
29+
"type": "string",
30+
"minLength": 1
31+
},
32+
"testimonials": {
33+
"type": "array",
34+
"items": {
35+
"type": "object",
36+
"properties": {
37+
"author_name": { "type": "string", "minLength": 1 },
38+
"author_description": { "type": "string", "minLength": 1 },
39+
"author_avatar": { "type": "string", "minLength": 1 },
40+
"link": { "type": "string", "minLength": 1 },
41+
"text": { "type": "string", "minLength": 1 }
42+
},
43+
"required": [
44+
"author_name",
45+
"author_description",
46+
"author_avatar",
47+
"link",
48+
"text"
49+
]
50+
}
51+
}
52+
},
53+
"required": ["difficulty", "testimonials"]
54+
},
55+
"stages": {
56+
"type": "array",
57+
"items": {
58+
"type": "object",
59+
"properties": {
60+
"slug": { "type": "string", "minLength": 1 },
61+
"name": { "type": "string", "minLength": 1 },
62+
"description_md": { "type": "string", "minLength": 1 },
63+
"difficulty": { "type": "string", "minLength": 1 },
64+
"marketing_md": { "type": "string", "minLength": 1 },
65+
"tester_source_code_url": { "type": "string", "minLength": 1 }
66+
},
67+
"required": [
68+
"slug",
69+
"name",
70+
"description_md",
71+
"difficulty",
72+
"marketing_md"
73+
]
74+
}
75+
}
76+
},
77+
"required": [
78+
"slug",
79+
"name",
80+
"short_name",
81+
"release_status",
82+
"description_md",
83+
"short_description_md",
84+
"completion_percentage",
85+
"languages",
86+
"marketing",
87+
"stages"
88+
]
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require "json"
2+
3+
def generate_response_field_for_property(property_name, property_hash)
4+
if property_hash["type"] == "object"
5+
inner_fields = ""
6+
7+
property_hash["properties"].each do |sub_property_name, sub_property_hash|
8+
inner_fields += generate_response_field_for_property(sub_property_name, sub_property_hash)
9+
inner_fields += "\n\n"
10+
end
11+
12+
<<~EOF
13+
<ResponseField name="#{property_name}" type="#{property_hash["type"]}">
14+
<Expandable title="properties">
15+
#{inner_fields}
16+
</Expandable>
17+
</ResponseField>
18+
EOF
19+
elsif property_hash["type"] == "array"
20+
inner_fields = ""
21+
22+
property_hash["items"]["properties"].each do |sub_property_name, sub_property_hash|
23+
inner_fields += generate_response_field_for_property(sub_property_name, sub_property_hash)
24+
inner_fields += "\n\n"
25+
end
26+
27+
<<~EOF
28+
<ResponseField name="#{property_name}" type="#{property_hash["type"]}">
29+
<Expandable title="item properties">
30+
#{inner_fields}
31+
</Expandable>
32+
</ResponseField>
33+
EOF
34+
else
35+
<<~EOF
36+
<ResponseField name="#{property_name}" type="#{property_hash["type"]}">
37+
</ResponseField>
38+
EOF
39+
end
40+
end
41+
42+
json_schema = JSON.parse(File.read("docs/data/course_definition_schema.json"))
43+
44+
file_contents = <<~EOF
45+
---
46+
# generated by scripts/generate_course_definition_reference.rb
47+
title: "Course Definition Reference"
48+
description: "Schema for the course-definition.yml file."
49+
---
50+
EOF
51+
52+
file_contents += "\n\n"
53+
54+
json_schema["properties"].each do |property_name, property_hash|
55+
file_contents += generate_response_field_for_property(property_name, property_hash)
56+
file_contents += "\n\n"
57+
end
58+
59+
File.write("docs/authoring-challenges/course-definition-reference.mdx", file_contents)

0 commit comments

Comments
 (0)