Skip to content

Commit cf064f1

Browse files
docs: DLT-3212 automate token-derived docs data files from build sources (#1298)
1 parent 8108aaf commit cf064f1

14 files changed

Lines changed: 914 additions & 80 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Docs Data Freshness
2+
3+
# Fails a PR if the token-derived docs data files under apps/dialtone-documentation/docs/_data/
4+
# are out of sync with their sources. Those files are generated by
5+
# `nx run dialtone-documentation:generate-token-data` from the design tokens + the dialtone-tokens
6+
# / dialtone-css PostCSS generator constants; committing a token/constant/generator change without
7+
# regenerating them would silently drift the docs.
8+
#
9+
# The job runs on EVERY pull request (no top-level `paths:` filter) so it is safe to mark as a
10+
# required status check — a path-filtered required check stays pending on PRs that don't touch
11+
# the paths and would block their merge. The expensive regen + diff only runs when a generator
12+
# input actually changed (detected by dorny/paths-filter); otherwise the job reports success
13+
# immediately.
14+
on:
15+
pull_request:
16+
17+
env:
18+
HUSKY: 0
19+
20+
concurrency:
21+
group: "${{ github.workflow }}-${{ github.ref }}"
22+
cancel-in-progress: true
23+
24+
jobs:
25+
check:
26+
runs-on: ubuntu-latest
27+
# Least privilege: contents:read for checkout + `git diff`; pull-requests:read so
28+
# dorny/paths-filter can read the PR's changed files; packages:read to install deps.
29+
# No write scopes — this job never pushes, commits, or publishes.
30+
permissions:
31+
contents: read
32+
pull-requests: read
33+
packages: read
34+
steps:
35+
- name: Check out branch
36+
# Diff-only check — don't persist the token in git config (no authenticated git ops needed).
37+
uses: actions/checkout@v4
38+
with:
39+
persist-credentials: false
40+
41+
- name: Detect changes to generator inputs
42+
id: changed
43+
uses: dorny/paths-filter@v3
44+
with:
45+
filters: |
46+
data:
47+
- 'apps/dialtone-documentation/docs/_data/**'
48+
- 'apps/dialtone-documentation/scripts/generate-data.mjs'
49+
- 'apps/dialtone-documentation/scripts/data/**'
50+
- 'packages/dialtone-tokens/tokens/**'
51+
- 'packages/dialtone-tokens/postcss/constants.cjs'
52+
- 'packages/dialtone-css/postcss/constants.cjs'
53+
54+
- name: Setup Environment
55+
if: steps.changed.outputs.data == 'true'
56+
uses: ./.github/actions/setup-environment
57+
58+
- name: Regenerate token-derived docs data
59+
if: steps.changed.outputs.data == 'true'
60+
run: pnpm nx run dialtone-documentation:generate-token-data
61+
62+
- name: Fail if docs data is out of sync with tokens
63+
if: steps.changed.outputs.data == 'true'
64+
run: |
65+
if ! git diff --exit-code -- apps/dialtone-documentation/docs/_data/; then
66+
echo "::error::Token-derived docs data is stale. Run 'pnpm nx run dialtone-documentation:generate-token-data' and commit the result."
67+
exit 1
68+
fi

.husky/pre-commit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,18 @@ if ! git diff --staged --quiet -- $THUMB_INPUTS; then
2828
git add apps/dialtone-documentation/docs/.vuepress/public/assets/images/components;
2929
fi
3030

31+
# Regenerate token-derived docs data when a source that feeds it changed.
32+
# generate-token-data dependsOn dialtone-tokens:build, so token edits get a fresh doc.json first.
33+
DATA_INPUTS='packages/dialtone-tokens/tokens packages/dialtone-tokens/postcss/constants.cjs packages/dialtone-css/postcss/constants.cjs apps/dialtone-documentation/scripts/data apps/dialtone-documentation/scripts/generate-data.mjs'
34+
if ! git diff --staged --quiet -- $DATA_INPUTS; then
35+
echo "Detected changes to docs-data inputs, regenerating token-derived _data files..."
36+
pnpm nx run dialtone-documentation:generate-token-data;
37+
38+
git add apps/dialtone-documentation/docs/_data/spacing.json \
39+
apps/dialtone-documentation/docs/_data/gap.json \
40+
apps/dialtone-documentation/docs/_data/width-height.json \
41+
apps/dialtone-documentation/docs/_data/icons-sizes.json \
42+
apps/dialtone-documentation/docs/_data/z-index.json;
43+
fi
44+
3145
pnpm exec lint-staged --relative
Lines changed: 97 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,101 @@
11
{
2-
"directions": ["both", "column", "row"],
2+
"directions": [
3+
"both",
4+
"column",
5+
"row"
6+
],
37
"values": [
4-
{ "stop": "0", "px": "0px" },
5-
{ "stop": "1", "px": "1px" },
6-
{ "stop": "25", "px": "2px" },
7-
{ "stop": "50", "px": "4px" },
8-
{ "stop": "75", "px": "6px" },
9-
{ "stop": "100", "px": "8px" },
10-
{ "stop": "125", "px": "10px" },
11-
{ "stop": "150", "px": "12px" },
12-
{ "stop": "175", "px": "14px" },
13-
{ "stop": "200", "px": "16px" },
14-
{ "stop": "250", "px": "20px" },
15-
{ "stop": "300", "px": "24px" },
16-
{ "stop": "350", "px": "28px" },
17-
{ "stop": "400", "px": "32px" },
18-
{ "stop": "450", "px": "36px" },
19-
{ "stop": "500", "px": "40px" },
20-
{ "stop": "525", "px": "42px" },
21-
{ "stop": "550", "px": "44px" },
22-
{ "stop": "600", "px": "48px" },
23-
{ "stop": "650", "px": "52px" },
24-
{ "stop": "700", "px": "56px" },
25-
{ "stop": "750", "px": "60px" },
26-
{ "stop": "800", "px": "64px" }
8+
{
9+
"stop": "0",
10+
"px": "0px"
11+
},
12+
{
13+
"stop": "1",
14+
"px": "1px"
15+
},
16+
{
17+
"stop": "25",
18+
"px": "2px"
19+
},
20+
{
21+
"stop": "50",
22+
"px": "4px"
23+
},
24+
{
25+
"stop": "75",
26+
"px": "6px"
27+
},
28+
{
29+
"stop": "100",
30+
"px": "8px"
31+
},
32+
{
33+
"stop": "125",
34+
"px": "10px"
35+
},
36+
{
37+
"stop": "150",
38+
"px": "12px"
39+
},
40+
{
41+
"stop": "175",
42+
"px": "14px"
43+
},
44+
{
45+
"stop": "200",
46+
"px": "16px"
47+
},
48+
{
49+
"stop": "250",
50+
"px": "20px"
51+
},
52+
{
53+
"stop": "300",
54+
"px": "24px"
55+
},
56+
{
57+
"stop": "350",
58+
"px": "28px"
59+
},
60+
{
61+
"stop": "400",
62+
"px": "32px"
63+
},
64+
{
65+
"stop": "450",
66+
"px": "36px"
67+
},
68+
{
69+
"stop": "500",
70+
"px": "40px"
71+
},
72+
{
73+
"stop": "525",
74+
"px": "42px"
75+
},
76+
{
77+
"stop": "550",
78+
"px": "44px"
79+
},
80+
{
81+
"stop": "600",
82+
"px": "48px"
83+
},
84+
{
85+
"stop": "650",
86+
"px": "52px"
87+
},
88+
{
89+
"stop": "700",
90+
"px": "56px"
91+
},
92+
{
93+
"stop": "750",
94+
"px": "60px"
95+
},
96+
{
97+
"stop": "800",
98+
"px": "64px"
99+
}
27100
]
28101
}

apps/dialtone-documentation/docs/_data/spacing.json

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
{
22
"directions": [
3-
{ "name": "All" },
4-
{ "name": "top", "deprecated": true },
5-
{ "name": "right", "deprecated": true },
6-
{ "name": "bottom", "deprecated": true },
7-
{ "name": "left", "deprecated": true },
8-
{ "name": "x" },
9-
{ "name": "y" }
3+
{
4+
"name": "All"
5+
},
6+
{
7+
"name": "top",
8+
"deprecated": true
9+
},
10+
{
11+
"name": "right",
12+
"deprecated": true
13+
},
14+
{
15+
"name": "bottom",
16+
"deprecated": true
17+
},
18+
{
19+
"name": "left",
20+
"deprecated": true
21+
},
22+
{
23+
"name": "x"
24+
},
25+
{
26+
"name": "y"
27+
}
1028
],
1129
"values": [
1230
{
@@ -219,18 +237,66 @@
219237
"combo": "yes",
220238
"value": "2.4rem"
221239
},
240+
{
241+
"coordinate": "350",
242+
"negative": "yes",
243+
"combo": "yes",
244+
"value": "2.8rem"
245+
},
222246
{
223247
"coordinate": "400",
224248
"negative": "yes",
225249
"combo": "yes",
226250
"value": "3.2rem"
227251
},
252+
{
253+
"coordinate": "450",
254+
"negative": "yes",
255+
"combo": "yes",
256+
"value": "3.6rem"
257+
},
258+
{
259+
"coordinate": "500",
260+
"negative": "yes",
261+
"combo": "yes",
262+
"value": "4rem"
263+
},
264+
{
265+
"coordinate": "525",
266+
"negative": "yes",
267+
"combo": "yes",
268+
"value": "4.2rem"
269+
},
270+
{
271+
"coordinate": "550",
272+
"negative": "yes",
273+
"combo": "yes",
274+
"value": "4.4rem"
275+
},
228276
{
229277
"coordinate": "600",
230278
"negative": "yes",
231279
"combo": "yes",
232280
"value": "4.8rem"
233281
},
282+
{
283+
"coordinate": "650",
284+
"negative": "yes",
285+
"combo": "yes",
286+
"value": "5.2rem"
287+
},
288+
{
289+
"coordinate": "700",
290+
"negative": "yes",
291+
"combo": "yes",
292+
"value": "5.6rem"
293+
},
294+
{
295+
"coordinate": "750",
296+
"negative": "yes",
297+
"combo": "yes",
298+
"value": "6rem"
299+
},
234300
{
235301
"coordinate": "800",
236302
"negative": "yes",

0 commit comments

Comments
 (0)