Skip to content

Commit db36272

Browse files
font resource definitions for brand reference
1 parent 326fbd0 commit db36272

File tree

2 files changed

+166
-25
lines changed

2 files changed

+166
-25
lines changed

docs/reference/metadata/brand.json

Lines changed: 117 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
"options": [
66
{
77
"name": "meta",
8-
"description": "Metadata for a brand, including the brand name and important links. See [Meta](#meta) for more information"
8+
"description": "Metadata for a brand, including the brand name and important links. See [Meta](#meta) for more information."
99
},
1010
{
1111
"name": "logo",
12-
"description": "Provide definitions and defaults for brand's logo in various formats and sizes. See [Logo](#logo) for more information"
12+
"description": "Provide definitions and defaults for brand's logo in various formats and sizes. See [Logo](#logo) for more information."
1313
},
1414
{
1515
"name": "color",
16-
"description": "The brand's custom color palette and theme. See [Color](#color) for more information"
16+
"description": "The brand's custom color palette and theme. See [Color](#color) for more information."
1717
},
1818
{
1919
"name": "typography",
20-
"description": "Typography definitions for the brand. See [Typography](#typography) for more information"
20+
"description": "Typography definitions for the brand. See [Typography](#typography) for more information."
2121
},
2222
{
2323
"name": "defaults",
@@ -45,7 +45,7 @@
4545
"options": [
4646
{
4747
"name": "images",
48-
"description": "A dictionary of named logo resources."
48+
"description": ""
4949
},
5050
{
5151
"name": "small",
@@ -125,31 +125,137 @@
125125
"options": [
126126
{
127127
"name": "fonts",
128-
"description": "Font files and definitions for the brand."
128+
"description": "Font files and definitions for the brand. See [Font resource definitions](#font-resource-definitions) for more information."
129129
},
130130
{
131131
"name": "base",
132132
"description": "The base font settings for the brand. These are used as the default for all text.\n See [base](#base) for more information."
133133
},
134134
{
135135
"name": "headings",
136-
"description": "Settings for headings. See [headings](#headings) for more information."
136+
"description": "Settings for headings\n See [headings](#headings) for more information."
137137
},
138138
{
139139
"name": "monospace",
140-
"description": "Settings for monospace text. See [monospace](#monospace) for more information."
140+
"description": "Settings for monospace text\n See [monospace](#monospace) for more information."
141141
},
142142
{
143143
"name": "monospace-inline",
144-
"description": "Settings for inline code. See [monospace-inline](#monospace-inline) for more information."
144+
"description": "Settings for inline code See [monospace-inline](#monospace-inline) for more information."
145145
},
146146
{
147147
"name": "monospace-block",
148-
"description": "Settings for code blocks. See [monospace-block](#monospace-block) for more information."
148+
"description": "Settings for code blocks See [monospace-block](#monospace-block) for more information."
149149
},
150150
{
151151
"name": "link",
152-
"description": "Settings for links. See [link](#link) for more information."
152+
"description": "Settings for links See [link](#link) for more information."
153+
}
154+
]
155+
},
156+
{
157+
"name": "font-resource-definitions",
158+
"title": "Font resource definitions",
159+
"level": 3,
160+
"options": []
161+
},
162+
{
163+
"name": "brand-font-google",
164+
"title": "google",
165+
"level": 4,
166+
"options": [
167+
{
168+
"name": "source",
169+
"description": "`\"google\"`"
170+
},
171+
{
172+
"name": "family",
173+
"description": "The font family name, which must match the name of the font on the foundry website."
174+
},
175+
{
176+
"name": "weight",
177+
"description": "The font weights to include."
178+
},
179+
{
180+
"name": "style",
181+
"description": "The font styles to include."
182+
},
183+
{
184+
"name": "display",
185+
"description": "The font display method, determines how a font face is font face is shown depending on its download status and readiness for use.\n"
186+
}
187+
]
188+
},
189+
{
190+
"name": "brand-font-bunny",
191+
"title": "bunny",
192+
"level": 4,
193+
"options": [
194+
{
195+
"name": "source",
196+
"description": "`\"bunny\"`"
197+
},
198+
{
199+
"name": "family",
200+
"description": "The font family name, which must match the name of the font on the foundry website."
201+
},
202+
{
203+
"name": "weight",
204+
"description": "The font weights to include."
205+
},
206+
{
207+
"name": "style",
208+
"description": "The font styles to include."
209+
},
210+
{
211+
"name": "display",
212+
"description": "The font display method, determines how a font face is font face is shown depending on its download status and readiness for use.\n"
213+
}
214+
]
215+
},
216+
{
217+
"name": "brand-font-file",
218+
"title": "file",
219+
"level": 4,
220+
"options": [
221+
{
222+
"name": "source",
223+
"description": "`\"file\"`"
224+
},
225+
{
226+
"name": "family",
227+
"description": "The font family name."
228+
},
229+
{
230+
"name": "files",
231+
"description": "The font files to include. These can be local or online. Local file paths should be relative to the `brand.yml` file. Online paths should be complete URLs.\n"
232+
}
233+
]
234+
},
235+
{
236+
"name": "brand-font-system",
237+
"title": "system",
238+
"level": 4,
239+
"options": [
240+
{
241+
"name": "source",
242+
"description": "`\"system\"`"
243+
},
244+
{
245+
"name": "family",
246+
"description": "The font family name, which must match the name of the font on the foundry website."
247+
},
248+
{
249+
"name": "weight",
250+
"description": "The font weights to include."
251+
},
252+
{
253+
"name": "style",
254+
"description": "The font styles to include."
255+
},
256+
{
257+
"name": "display",
258+
"description": "The font display method, determines how a font face is font face is shown depending on its download status and readiness for use.\n"
153259
}
154260
]
155261
},

tools/reference.ts

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,37 @@ function readDefinitionsId(id: string, descriptions?: Record<string, string>) {
261261
const supers = obj["super"];
262262
if (supers) {
263263
(supers as { resolveRef: string }[]).forEach((sup) => {
264+
console.log('super!');
264265
results.push(...readDefinitionsId(sup.resolveRef));
265266
})
266267
}
267268
return results;
268269
}
269270

271+
function readDefinitionsIdSuper(id: string, descriptions?: Record<string, string>) {
272+
const obj = definitions.find(value => value.id === id) as any;
273+
274+
const baseObject = (obj["object"] || obj["schema"]["object"]);
275+
const props = baseObject["properties"];
276+
277+
const results = [];
278+
results.push(...readProjectProperties(props, descriptions));
279+
280+
const _super = baseObject["super"];
281+
if (_super) {
282+
results.push(...readDefinitionsIdSuper(_super.resolveRef));
283+
}
284+
return results;
285+
}
286+
270287
function readTypographyOptions(id: string, toFollow: Array<string>) {
271288
const obj = definitions.find(value => value.id === id) as any;
272289

273290
const baseObject = (obj["object"] || obj["schema"]["object"]);
274291
const props = baseObject["properties"];
275-
const descriptions = {};
292+
const descriptions = {
293+
"fonts": asDescriptionString(findVal(props.fonts, "description")) +" See [Font resource definitions](#font-resource-definitions) for more information."
294+
};
276295

277296
for (const [key, prop] of Object.entries(props).filter(([_, {ref}]) => ref)) {
278297
if (prop.hidden) {
@@ -358,10 +377,10 @@ writeMetadataTable("citation", "Citation", citationOptions);
358377
const brandDefinitions = definitions.filter(item => item.id.startsWith("brand-"));
359378

360379
const brandOptions = readDefinitionsId("brand",{
361-
"meta": "Metadata for a brand, including the brand name and important links. See [Meta](#meta) for more information",
362-
"logo": "Provide definitions and defaults for brand's logo in various formats and sizes. See [Logo](#logo) for more information",
363-
"color": "The brand's custom color palette and theme. See [Color](#color) for more information",
364-
"typography": "Typography definitions for the brand. See [Typography](#typography) for more information",
380+
"meta": "Metadata for a brand, including the brand name and important links. See [Meta](#meta) for more information.",
381+
"logo": "Provide definitions and defaults for brand's logo in various formats and sizes. See [Logo](#logo) for more information.",
382+
"color": "The brand's custom color palette and theme. See [Color](#color) for more information.",
383+
"typography": "Typography definitions for the brand. See [Typography](#typography) for more information.",
365384
"defaults": "Default settings"
366385
});
367386

@@ -378,6 +397,8 @@ const typographyOptionDescriptions = {
378397
"line-height": "The distance between lines of text.",
379398
};
380399

400+
const fontResourceDefinitions = definitions.find(value => value.id === "brand-font").anyOf;
401+
381402
const brandMetadata = [
382403
{
383404
"name": "brand",
@@ -404,18 +425,32 @@ const brandMetadata = [
404425
"title": "Typography",
405426
"options": readTypographyOptions("brand-typography", toFollow)
406427
},
428+
{
429+
"name": "font-resource-definitions",
430+
"title": "Font resource definitions",
431+
"level": 3,
432+
"options": []
433+
},
434+
...fontResourceDefinitions.map(({ref}) => {
435+
if (!ref) return null;
436+
const source = ref.replace(/^brand-font-/, "");
437+
const descriptions = {"source": '\`"' + source + '"\`'}
438+
return {
439+
"name": ref,
440+
"title": source,
441+
"level": 4,
442+
"options": readDefinitionsIdSuper(ref, descriptions)
443+
}
444+
}).filter(x => x),
407445
...toFollow.map(id => {
408446
const typography = definitions.find(value => value.id === id);
409447
const root = typography?.["anyOf"][1]?.object;
410-
if (root?.properties) {
411-
return {
412-
"name": id,
413-
"title": id.replace(/^brand-typography-options-/, ''),
414-
"level": 3,
415-
"options": readProjectProperties(root.properties, typographyOptionDescriptions)
416-
}
417-
} else {
418-
return null;
448+
if (!root?.properties) return null;
449+
return {
450+
"name": id,
451+
"title": id.replace(/^brand-typography-options-/, ""),
452+
"level": 3,
453+
"options": readProjectProperties(root.properties, typographyOptionDescriptions)
419454
}
420455
}).filter(x => x),
421456
]

0 commit comments

Comments
 (0)