Skip to content

Commit 52301f3

Browse files
committed
add clarifying comments about how we derive data filepaths from data refs
1 parent 82644ef commit 52301f3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

script/early-access/update-data-and-image-paths.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,16 @@ earlyAccessContentAndDataFiles
114114
console.log('Done! Run "git status" in your docs-early-access checkout to see the changes.\n')
115115

116116
function checkVariable (dataRef) {
117-
// Get the data file path from the data reference
117+
// Get the data filepath from the data reference,
118+
// where the data reference looks like: {% data variables.foo.bar %}
119+
// and the data filepath looks like: data/variables/foo.yml with key of 'bar'.
118120
const variablePathArray = dataRef.match(/{% data (.*?) %}/)[1].split('.')
119121
// If early access is part of the path, remove it (since the path below already includes it)
120122
.filter(n => n !== 'early-access')
121123

124+
// Given a string `variables.foo.bar` split into an array, we want the last segment 'bar', which is the variable key.
125+
// Then pop 'bar' off the array because it's not really part of the filepath.
126+
// The filepath we want is `variables/foo.yml`.
122127
const variableKey = last(variablePathArray); variablePathArray.pop()
123128
const variablePath = path.posix.join(earlyAccessData, `${variablePathArray.join('/')}.yml`)
124129

@@ -131,6 +136,9 @@ function checkVariable (dataRef) {
131136
}
132137

133138
function checkReusable (dataRef) {
139+
// Get the data filepath from the data reference,
140+
// where the data reference looks like: {% data reusables.foo.bar %}
141+
// and the data filepath looks like: data/reusables/foo/bar.md.
134142
const reusablePath = dataRef.match(/{% data (.*?) %}/)[1].split('.')
135143
// If early access is part of the path, remove it (since the path below already includes it)
136144
.filter(n => n !== 'early-access')

0 commit comments

Comments
 (0)