Processing model — DSDS 0.22.0
What a tool reading DSDS documents has to work out that isn't written down: which item an address points to, which files belong together, where reused content comes from, how relationships read backwards, what replaces something deprecated, and how to avoid loops. Normative, with test vectors.
The schema says what a document can contain. This page says what a tool works out when it reads one. For example: which item a
This page sets requirements. MUST, MUST NOT, SHOULD, SHOULD NOT and MAY mean what RFC 2119 says, and only when written in capitals. The requirements apply to a conforming consumer: anything that reads a DSDS document and does something with it. Conformance covers the other kinds of tool.
Each MUST ends with what checks it, in parentheses, as the specification's §1.2 describes. That's a validator rule, a test vector, or
#
1. Terms- A project is all the documents a consumer reads together (§3).
- An address is the part of a ref's
to after the# . Inshared-a11y#focus-visible , the address isfocus-visible . - An item is one member of a section's
items , or onefreeform entry. - A chain is a path a consumer follows from one thing to the next, through
uses ,extends ,same-as orreplaced-by (§9).
#
2. Addresses #
2.1 EntriesA consumer MUST treat
#
2.2 ItemsA
- An item with an
id uses thatid . - An item without an
id uses an id made from its own text: a guideline'sstatement , a definition'sterm , or a step's or freeform entry'stitle . To make it, lowercase the text, turn each run of characters other thana –z and0 –9 into one dash, and remove any dash at either end. "Name it!" becomesname-it . This works for freeform entries at any depth. - An item with neither, because it only reuses another item with
same-as (§4), uses the address of the item it reuses. That's the part of itssame-as target after the# . - Anything else inside an item that has its own
id , such as an example, uses thatid . - A component's trait uses its
id . One value of an enum trait usestraitId.valueId , as inbutton#variant.primary . Combos use the same form. It can't be misread, because a trait id can't contain a dot.
#
2.3 When two things share an addressTwo things on one entry can end up with the same address. A consumer MUST pick the one whose address has the strongest source, in this order (vector: addresses; DSDS-05):
- an
id written in the document (rules 1, 4 and 5); - an id made from the text (rule 2);
- an address taken from a reused item (rule 3).
If two things tie for the strongest source, the address is ambiguous. A consumer MUST NOT choose between them, because it's an error (DSDS-05). The fix is to give one of the two its own
So when an item and another item reusing it sit on the same entry, their shared address points at the item that states the rule.
#
3. ProjectsA consumer looks up refs across a whole project.
- A project MUST include every document a consumer can reach by following
rel: file refs from the documents it was given, then from those, and so on (DSDS-08; vector: cross-file). - A consumer MUST NOT follow a
rel: file ref out of the folder that holds the document, or its subfolders (consumer). A document is data from whoever wrote it, and could point anywhere. See Security. rel: file is only for DSDS documents. A code file or a DTCG token file isrel: source , and a consumer doesn't read it as part of the project (DSDS-25 ).- When the project's system entry sets
metadata.sourceRoot , a consumer MUST read each relativesourceFiles path starting from there (DSDS-11 ). Without it, the path starts from the component's own document. A relativesourceRoot starts from the document that holds the system entry. IfsourceRoot points outside that document's folder, the consumer still decides whether to open it. - A consumer given several documents at once SHOULD treat them as one project. That's how a standalone entry file can point at the files next to it, since it has no field to list them.
- A ref to something not in the project is an error when the project is known to be complete: a base document with no
rel: file refs, read on its own. Otherwise the target may be in a file the consumer didn't read, so it's a warning (DSDS-05 ,DSDS-08 ).
#
4. Reused contentAn item with a
- A consumer MUST show a reusing item with its effective content: each content field the item states itself, plus every other content field from the item it reuses (vector: reuse). The content fields are:
- for a guideline:
level ,statement andcheckedBy ; - for a definition:
term ,definition andusage ; - for a step:
title anddescription .
- for a guideline:
- If the reused item itself reuses another, a consumer MUST follow the chain to the item that states the content (vector: reuse). It SHOULD say which item that is.
- A reusing item MUST point at an item of the same section kind (
DSDS-25 ). A guideline can't reuse a definition. - When both items state a
level , the two MUST match (DSDS-10 ). An item that means to state a different level is arefines , not asame-as . - When the target of a
same-as ref can't be found, a consumer SHOULD show the reusing item'slevel and the link, rather than nothing (see sections/guidelines).
#
5. Relationships and their reverseA relationship is written once, on the thing it starts from. A conforming consumer works out the reverse direction itself, and MUST NOT require it to be written on the other end too (vector: inverse).
A pointer in
Every
| Where it's written | What it means | Read backwards | What a consumer does | |
|---|---|---|---|---|
| This is built from the target, needs it, or follows it. A dialog uses its button. A button uses a color token, and the pattern it follows. | used by | Follows | ||
| This item reuses another item's content instead of repeating it. | reused by | Shows the reusing item with its effective content (§4). | ||
| The target replaces this. | replaces | Follows it to the successor (§7). | ||
| Another DSDS document in the same project. A code or token file is | — | Reads the target as part of the project (§3). | ||
| Where this is built: a repository, a source file, a DTCG token file or a package. | — | MAY fetch it. Reads a relative | ||
| The design file this comes from. | — | MAY link to it. | ||
| A live demo, such as a Storybook story. | — | MAY link to it or embed it. | ||
| Worth reading alongside this, when no other kind fits. On a guideline item with no | the same both ways | MAY show it as "see also". For an item with no statement, SHOULD show the level and the link (§4). | ||
| an entry's | This inherits from the target. | extended by | Never merges the target in (§6). Follows it as a chain (§9). | |
| Use the target instead, in the situation the entry or rule describes. | the same both ways | Offers the target when this one doesn't fit. | ||
| a guideline's | The outside standard the rule is based on. | cited by | SHOULD show it, so a reader can tell a requirement from a house preference. | |
| a guideline's | What checks the rule: a test, lint rule or agent eval (an | checks | Runs it or links to it. | |
| a component's | A machine-readable API contract that was already generated. | — | Reads the component's props, slots and events from it, with whatever parser its format needs. | |
| a guideline's | This states a human rule more precisely, for an agent. | refined by | When reading for an agent, applies both rules (§4). |
A "—" means the pointer leads outside the project, so nothing in the project reads it backwards. Custom namespaced
When a consumer shows an entry's relationships, it SHOULD include the ones written on other entries that point at it. A pointer inside an item belongs to that item. So a step that
#
6. A consumer MUST NOT copy the extended entry's fields or sections into the entry that extends it (consumer). The extending entry is complete as written. A consumer that reads it on its own reads all of it. A consumer MAY show the extended entry's content beside it, as long as it's clearly labelled as coming from that entry.
Why not merge them? An entry's meaning would then depend on another document the consumer may not have. And every consumer would need the same rules for merging lists, fields and overrides, or they'd disagree. What a theme changes lives in its DTCG
#
7. SuccessorsA successor is what replaces something deprecated.
- The successor is named in
replacedBy . It sits in thestatus that marks the entry, trait or trait value as deprecated, next to itsdeprecationNotice , where a reader learns the thing is going away. The schema only acceptsreplacedBy in a deprecated status. In one platform's status, it names that platform's successor. - To find what to use instead, a consumer MUST follow
replaced-by (vector: successors). If the successor is deprecated too, with its ownreplaced-by , a consumer MUST follow that as well and use where it ends (vector: successors). - When there's more than one successor, a consumer MUST NOT pick one on its own (vector: successors). The
deprecationNotice says when to choose which. A consumer that can't apply it MUST leave the choice to whoever it's working for (consumer). For example, an agent replacingvariant="secondary-green" across a codebase asks, or leaves a note, instead of guessing.
#
8. Unknown values- When a consumer writes a document back out, it MUST keep any
$extensions content it doesn't understand (consumer). - A consumer MAY ignore a custom namespaced
rel (such asacme.themes ) or a custom kind it doesn't understand. It MUST NOT report the document as invalid because of one (consumer). - A field the schema doesn't declare, on a generic
entry orsection , is most likely a typo or a leftover. A validator reports it as a warning (DSDS-24 ).
#
9. Chains and loopsA consumer follows four kinds of pointer from one thing to the next. Each one answers a question:
uses : what is affected if this changes?extends : what does this inherit from?same-as : where is this content stated?replaced-by : what replaces this?
A chain MUST NOT lead back to where it started, because then its question has no answer (DSDS-06; vector: cycles). A loop is an error, and a consumer that finds one MUST stop following it instead of going round forever (vector: cycles).
#
10. ProblemsWhat
| Problem | What it means | Rule |
|---|---|---|
| Two entries in the project have the same id. | ||
| A ref points at an entry the project doesn't have. | ||
| A ref points at an address the entry doesn't have. | ||
| An address points at two things, and neither one wins (§2.3). | ||
| A reusing item states a different | ||
| A | ||
| A | the schema, | |
| A | the schema | |
| A chain leads back to where it started. |
#
11. Test vectorsEach folder in
They're published with the conformance suite at
In this repo,