DSDS authoring style guide — DSDS 0.20.1
How to order things inside a DSDS document, so every document reads the same way no matter who wrote it.
How to order things inside a DSDS document, so every document reads the same way no matter who wrote it.
None of this changes whether a document is valid. The schema accepts any order. Seven warning-only rules (
#
The schema is the style guideWrite in the order the schema lists them. The order of properties and options in the schema reflect the guidelines' recommendations on how to organize your schema documents. When in doubt, copy how the schema does it.
#
The patterns behind these rulesEverything below is one of a few ideas, applied to a different part of a document. Learn these and you can usually work out the specific rule.
Field order comes from the schema. List order comes from this guide. Each schema follows the style guide for field order. Which entry, section, or item comes first in a list is something a schema can't express, so this guide describes it.
Broad to specific. The widest thing leads:
Nothing comes before the thing it's built on. Tokens before the themes that override them, themes before the components that use them. Read top to bottom and you meet every idea before anything that depends on it.
Shared fields before specific ones. The fields every kind has come first, then the fields one kind adds. A
Catch-alls go last.
Where no rule decides, keep the order you wrote. Don't alphabetize. Items sharing a
#
1. Base documents and A base document is the outermost object. Its fields go in the order seen in
#
Entry order, inside When a base document holds several entries, order the entries themselves by
system : Always first since it contextualizes everything contained within.token : Defines the attributes that themes and components are created from.theme : Built from tokens, so only makes sense to come after.component : Built from tokens and themes.entry : Always last since it can cover a broad set of topics. Feel free to add general onboarding docs aftersystem .
This follows the same idea as §4: Broadest first, and follow the dependency chain. This theoretically means that all prerequisite information is provided up front for an entry.
Within one kind, use whatever order reads best. Avoid arbitrary ordering, such as alphabetical when another order is better for comprehension. For example, a scale reads better as
#
2. EntriesFollow the high-level order:
- Shared entry fields except
$extensions defined inentries/entry.schema.yaml . - Then that kind's own fields, defined in
entries/ . A custom kind has no file of its own, so should follow the high-level guidance..schema.yaml - Then
$extensions . All information that adds to the schema goes last.
If a document is ordered differently, the
#
3. A
#
4. Sections #
A section's own fieldsA section leads with the fields that say what it is:
That's the same reason
#
Keep each kind togetherIf an entry has more than one section, put all the sections of the same kind side by side — every
#
Kind order: broadest firstOrder section kinds like this:
guidelines — the broadest question. Should I use this at all, and how do I use it properly?definitions — reference material: parts, terms, a glossary. Narrower than guidelines, because it's about this entry's own parts and words. Wider than a set of steps.steps — one procedure or checklist. The narrowest of the three, because it's one exact sequence rather than general advice.section (the plain kind) — prose that didn't fit the other three. Last, because it's the fallback.
That's the order
#
Within Guidelines sorts content by: how broad first, who it's for second.
Guidelines should lead with when to use, then describe how to use it. That's the order
framing: when-to-use : Does it make sense to use?framing: how-to-use : If so, how do you use it? Leavingframing out means this — it's the default that file declares.- Tagged guidelines: A section counts as tagged when it has two or more items and every one of them names the same tag — the accessibility rules, say, or the mobile-only ones. Narrow instruction should follow general information, so these come last whatever their
framing is. Two items are the minimum because one item always shares a tag with itself.
Sections in the same breadth tier are then ordered by how broad the audience is. The order
for: all — also what you get by leavingfor out, since it's the default that file declares. So an omittedfor sorts first, not last.for: human for: agent
#
5. Section items #
An item's own fieldsOrder an item's fields the way its own schema file lists them.
| Shape | Its schema file |
|---|---|
| A | |
| A | |
| A |
#
Guideline item order, by Order items by
Order items at the same level in whatever way aids comprehension. Ideally, group subject matter of the same level together. Don't alphabetize items that share a level—that's dumb.
#
6. Refs and combos #
Combos: by subject, then levelCombos sort by: subject first, level second. Every rule about one trait or token sits together, so a reader checking one of them finds the rest in the same place. Within one subject,
A combo reads as one sentence: this subject, at this strength, with these things. That's the order
subject : What is the rule about? A trait, a token, or an entry.level : Does it permit or forbid and how strictly?items : What does the rule apply to?note : Why does it hold?
#
Refs: what it points at, then what kind of pointerA ref answers what it points at before what kind of pointer it is. That's the order
to orhref : What does this point at?to for something in this document,href for anything outside it. Exactly one of the two.rel : What kind of pointer is it?role : What does the thing being pointed at do here?note : Anything else worth saying about the connection.
#
7. A complete example #
ToolingSeven warning-only rules check this guide. They live in
#
What's checkedEvery rule in this guide is checked except one, and that one can't be. The right-hand column is the warning you'd get.
| Rule | Where | Checked by |
|---|---|---|
| A base document's own fields | §1 | |
| A | §1 | |
| Entry order inside | §1 | |
| An entry's own fields | §2 | |
| A | §3 | |
| A section's own fields | §4 | |
| Same-kind sections kept together | §4 | |
| Section kind order | §4 | |
| Breadth, then audience, among | §4 | |
| An item's own fields | §5 | |
| Guideline items by | §5 | |
| A combo's own fields | §6 | |
| §6 | ||
| A ref's own fields | §6 | |
| Order within one entry kind, or one | §1, §5 | can't be — it's a judgment call |
The tag tier reads the items. Every other sort here looks at a field.
Field order has one source: the schema files. The tables on the Schema page are generated from each schema file's own order,