Skip to content

Commit 6ab8470

Browse files
committed
Give every variable a heading and group by purpose
The table of contents is built from headings, so putting the variables in it means each one needs its own heading. Every variable now has an h3 with its description, TOML key, CLI flag, and "Read by:" line, and the tables are gone. Group the variables by what they configure rather than by which clients read them: configuration file, connection, TLS, gRPC metadata, Codec Server, then the two CLI-only groups. "Client settings" was not a phrase this documentation uses, and the page is about environment variables either way. Lead with the intro's precedence order from highest to lowest, and link Temporal Client to the encyclopedia entry. Because support now lives on every variable, the checker drops its per-section rules and reads only "Read by:" lines. A variable reintroduced as a table row carries no such line, so the checker rejects the row instead of leaving its support unchecked.
1 parent 5043bca commit 6ab8470

2 files changed

Lines changed: 224 additions & 118 deletions

File tree

bin/check-env-config-table.js

Lines changed: 25 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,10 @@ const DOCS_PAGE = path.join(
3838
const ALL_CLIENTS = ["Go", "Java", "Python", "TypeScript", ".NET", "Ruby", "CLI"];
3939

4040
// The page carries no copy of the support matrix for this script to drift from.
41-
// Which clients read a variable is read back off the page itself, from the
42-
// structure the reader sees:
41+
// Which clients read a variable is read back off the page itself: every variable
42+
// gets its own heading and states its support in a "Read by:" line. A heading
43+
// without one stops the check rather than passing quietly.
4344
//
44-
// * a variable in a table under one of these sections takes the section's
45-
// support, which that section states in its opening sentence;
46-
// * a variable with its own heading states support in a "Read by:" line.
47-
//
48-
// A variable that falls under neither rule, or a section heading not listed
49-
// here, stops the check rather than passing quietly.
50-
const SECTION_SUPPORT = {
51-
"Client settings": ALL_CLIENTS,
52-
// "The Temporal CLI reads the variables below [...] No other client reads them."
53-
"Temporal CLI settings": ["CLI"],
54-
// Every variable here carries its own "Read by:" line.
55-
"Client settings not read by every client": null,
56-
};
57-
5845
// Tokens accepted in a "Read by:" line, mapped to the labels sources use.
5946
const CLIENT_TOKENS = new Map([
6047
...ALL_CLIENTS.map((c) => [c.toLowerCase(), c]),
@@ -149,15 +136,14 @@ async function fetchSource({ repo, ref, files }) {
149136
}
150137

151138
/**
152-
* Reads the documented variables off the page: table rows under a known section,
153-
* and variables that have their own heading with a "Read by:" line. Returns a
154-
* Map of variable name to the Set of clients the page says read it.
139+
* Reads the documented variables off the page. Each variable has its own heading
140+
* followed by a "Read by:" line. Returns a Map of variable name to the Set of
141+
* clients the page says read it.
155142
*/
156143
function parseDocsPage(mdx) {
157144
const lines = mdx.split("\n");
158145
const documented = new Map();
159146
const problems = [];
160-
let section = null;
161147
// The heading of the variable currently being read, awaiting its "Read by:".
162148
let pending = null;
163149

@@ -168,61 +154,36 @@ function parseDocsPage(mdx) {
168154
pending = null;
169155
};
170156

171-
for (let i = 0; i < lines.length; i++) {
172-
const line = lines[i];
173-
174-
const h2 = line.match(/^##\s+(.+?)\s*$/);
175-
if (h2) {
176-
closePending();
177-
section = h2[1].replace(/`/g, "");
178-
if (!(section in SECTION_SUPPORT)) {
179-
problems.push(
180-
`section "${section}" is not listed in SECTION_SUPPORT, so the support ` +
181-
`it implies is unknown`
182-
);
183-
}
184-
continue;
185-
}
186-
187-
// A variable documented under its own heading, at any depth below h2.
188-
const varHeading = line.match(/^#{3,}\s+`(TEMPORAL_[A-Z0-9_*]+)`\s*$/);
189-
if (varHeading) {
190-
closePending();
191-
pending = varHeading[1];
192-
continue;
193-
}
194-
195-
// Any other heading ends the current variable's block.
196-
if (/^#{3,}\s/.test(line)) {
157+
for (const line of lines) {
158+
const heading = line.match(/^#{2,}\s+(.*?)\s*$/);
159+
if (heading) {
197160
closePending();
161+
const name = heading[1].match(/^`(TEMPORAL_[A-Z0-9_*]+)`$/);
162+
if (name) pending = name[1];
198163
continue;
199164
}
200165

201-
if (pending) {
202-
const readBy = line.match(/^-\s+Read by:\s*(.+?)\s*$/);
203-
if (readBy) {
204-
const clients = parseReadBy(readBy[1]);
205-
if (!clients) {
206-
problems.push(`${pending} has an unrecognized "Read by:" value: ${readBy[1]}`);
207-
} else {
208-
documented.set(pending, clients);
209-
}
166+
const readBy = pending && line.match(/^-\s+Read by:\s*(.+?)\s*$/);
167+
if (readBy) {
168+
const clients = parseReadBy(readBy[1]);
169+
if (!clients) {
170+
problems.push(`${pending} has an unrecognized "Read by:" value: ${readBy[1]}`);
171+
} else {
172+
documented.set(pending, clients);
210173
}
174+
// The block is satisfied either way; the next heading starts a new one.
175+
pending = null;
211176
continue;
212177
}
213178

214-
// Table rows inherit their section's support.
179+
// Every variable belongs under its own heading. A variable reintroduced as a
180+
// table row would carry no "Read by:" line, so reject the row outright
181+
// rather than leave its support unchecked.
215182
if (line.trim().startsWith("|")) {
216183
const name = (line.split("|")[1] || "").replace(/`/g, "").trim();
217-
if (!name.startsWith("TEMPORAL_")) continue;
218-
const support = SECTION_SUPPORT[section];
219-
if (!support) {
220-
problems.push(
221-
`${name} is a table row under "${section}", which requires a per-variable "Read by:" line`
222-
);
223-
continue;
184+
if (name.startsWith("TEMPORAL_")) {
185+
problems.push(`${name} is a table row; it needs its own heading and a "Read by:" line`);
224186
}
225-
documented.set(name, new Set(support));
226187
}
227188
}
228189
closePending();

0 commit comments

Comments
 (0)