Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- uses: actions/setup-node@v6
with: { node-version-file: '.nvmrc', cache: pnpm }
- run: pnpm i --frozen-lockfile
- run: pnpm build:w3c & pnpm build:geonovum
- run: pnpm build:w3c & pnpm build:geonovum & pnpm build:aom & pnpm build:dini
- run: pnpm test:unit
env:
BROWSERS: ${{ matrix.browser }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- uses: actions/setup-node@v6
with: { node-version-file: '.nvmrc', cache: pnpm }
- run: pnpm i --frozen-lockfile
- run: pnpm build:w3c & pnpm build:geonovum
- run: pnpm build:w3c & pnpm build:geonovum & pnpm build:aom & pnpm build:dini
- run: pnpm test
env:
BROWSERS: ChromeHeadless
1 change: 1 addition & 0 deletions src/aom/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function run(conf) {
lint,
});

if ("noToc" in conf && !("noTOC" in conf)) conf.noTOC = conf.noToc;
// computed properties
Object.assign(conf, computeProps(/** @type {NormalizedConf} */ (conf)));
}
2 changes: 1 addition & 1 deletion src/aom/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function run(conf) {
}

// Attach W3C fixup script after we are done.
if (!conf.noToc) {
if (!conf.noTOC) {
sub(
"end-all",
() => {
Expand Down
1 change: 1 addition & 0 deletions src/dini/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function run(conf) {
lint,
});

if ("noToc" in conf && !("noTOC" in conf)) conf.noTOC = conf.noToc;
// computed properties
Object.assign(conf, computeProps(/** @type {NormalizedConf} */ (conf)));
}
2 changes: 1 addition & 1 deletion src/dini/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function run(conf) {
}

// Attach W3C fixup script after we are done.
if (!conf.noToc) {
if (!conf.noTOC) {
sub(
"end-all",
() => {
Expand Down
2 changes: 2 additions & 0 deletions src/geonovum/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@ export function run(conf) {
lint,
});
// computed properties

if ("noToc" in conf && !("noTOC" in conf)) conf.noTOC = conf.noToc;
Object.assign(conf, computeProps(/** @type {NormalizedConf} */ (conf)));
}
2 changes: 1 addition & 1 deletion src/geonovum/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function run(conf) {
styleFile = "base.css";
}

if (!conf.noToc) {
if (!conf.noTOC) {
sub(
"end-all",
() => {
Expand Down
84 changes: 54 additions & 30 deletions src/type-helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ interface StoredBiblioEntry extends BiblioData {
* `true`, `false`, or `"warn"` / `"error"`.
* Supports string indexing so linter-rule files can look up individual rules.
*/
type LintConfig = false | ({ [ruleName: string]: boolean | string });
type LintConfig = false | { [ruleName: string]: boolean | string };

type ProcessFn = (config: Conf, doc: Document, utils?: unknown) => Promise<void> | void;
type ProcessFn = (
config: Conf,
doc: Document,
utils?: unknown
) => Promise<void> | void;

/** Configuration object type */
interface Conf {
Expand All @@ -119,6 +123,7 @@ interface Conf {
afterEnd?: ProcessFn;
specStatus?: string;
wgId?: string;
/** @deprecated Use noTOC instead */
noToc?: boolean;
noTOC?: boolean;
/** Disables injecting ReSpec styles */
Expand All @@ -131,24 +136,26 @@ interface Conf {
/** The URL of the pull request, if applicable */
prUrl?: string;
/** The GitHub configuration object */
github?: string | {
/** The URL of the GitHub repository */
repoURL: string;
/** The default branch name */
branch?: string;
/** Optional custom pulls URL (for monorepo scenarios) */
pullsURL?: string;
/** Optional custom commit history URL (for monorepo scenarios) */
commitHistoryURL?: string;
/** The API base URL */
apiBase?: string;
/** The full name of the repo (e.g. "w3c/my-spec") */
fullName?: string;
/** The issues URL */
issuesURL?: string;
/** The new issues URL */
newIssuesURL?: string;
};
github?:
| string
| {
/** The URL of the GitHub repository */
repoURL: string;
/** The default branch name */
branch?: string;
/** Optional custom pulls URL (for monorepo scenarios) */
pullsURL?: string;
/** Optional custom commit history URL (for monorepo scenarios) */
commitHistoryURL?: string;
/** The API base URL */
apiBase?: string;
/** The full name of the repo (e.g. "w3c/my-spec") */
fullName?: string;
/** The issues URL */
issuesURL?: string;
/** The new issues URL */
newIssuesURL?: string;
};
/** The title of the document */
title?: string;

Expand Down Expand Up @@ -349,15 +356,21 @@ interface Conf {
/** Linting configuration */
lint?: LintConfig;
/** caniuse.com feature configuration */
caniuse?: string | {
feature?: string;
browsers?: string[] | Record<string, string[]>;
maxAge?: number;
removeOnSave?: boolean;
[key: string]: unknown;
};
caniuse?:
| string
| {
feature?: string;
browsers?: string[] | Record<string, string[]>;
maxAge?: number;
removeOnSave?: boolean;
[key: string]: unknown;
};
/** External cross-reference configuration */
xref?: boolean | string | string[] | { url?: string; specs?: string[]; profile?: string };
xref?:
| boolean
| string
| string[]
| { url?: string; specs?: string[]; profile?: string };
/** Whether to include JSON-LD metadata */
doJsonLd?: boolean;
/** Whether to highlight variables */
Expand All @@ -373,9 +386,20 @@ interface Conf {
/** Accessibility linting configuration */
a11y?: boolean | Record<string, unknown>;
/** MDN annotation configuration */
mdn?: boolean | string | { key?: string; specMapUrl?: string; baseJsonPath?: string; maxAge?: number };
mdn?:
| boolean
| string
| {
key?: string;
specMapUrl?: string;
baseJsonPath?: string;
maxAge?: number;
};
/** Web Monetization configuration */
monetization?: boolean | string | { paymentPointer?: string; removeOnSave?: boolean };
monetization?:
| boolean
| string
| { paymentPointer?: string; removeOnSave?: boolean };
/** RFC 2119 usage tracking object, keyed by term */
respecRFC2119?: Record<string, boolean>;
/** Whether to place the SotD additional content after the WG info */
Expand Down
1 change: 1 addition & 0 deletions src/w3c/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function run(conf) {
lint,
});

if ("noToc" in conf && !("noTOC" in conf)) conf.noTOC = conf.noToc;
if (conf.specStatus !== "unofficial" && !conf.hasOwnProperty("license")) {
conf.license = "w3c-software-doc";
}
Expand Down
2 changes: 1 addition & 1 deletion src/w3c/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function styleMover(linkURL) {
*/
export function run(conf) {
// Attach W3C fixup script after we are done.
if (!conf.noToc) {
if (!conf.noTOC) {
sub("end-all", attachFixupScript, { once: true });
}

Expand Down
10 changes: 9 additions & 1 deletion tests/spec/aom/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ describe("AOM - Style", () => {
expect(elem.content).toBe(expectedStr);
});

it("doesn't include fixup.js when noToc is set", async () => {
it("doesn't include fixup.js when noTOC is set", async () => {
const ops = makeStandardAomOps({ noTOC: true });
Comment thread
marcoscaceres marked this conversation as resolved.
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2016/fixup.js']";
const elem = doc.querySelector(query);
expect(elem).toBeNull();
});

it("doesn't include fixup.js when legacy noToc is set", async () => {
const ops = makeStandardAomOps({ noToc: true });
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2016/fixup.js']";
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/core/id-headers-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Core - ID headers", () => {
ariaLabel = deepAppendix.getAttribute("aria-label");
expect(ariaLabel).toBe("Permalink for Appendix A.1");

// marked as noToc
// marked as noTOC
const deepH4 = doc.querySelector("h4 + a.self-link");
ariaLabel = deepH4.getAttribute("aria-label");
expect(ariaLabel).toBe("Permalink for this Section");
Expand Down
13 changes: 11 additions & 2 deletions tests/spec/geonovum/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,24 @@ describe("Geonovum - Style", () => {
);
});

it("shouldn't include fixup.js when noToc is set", async () => {
it("shouldn't include fixup.js when noTOC is set", async () => {
const ops = makeStandardGeoOps();
const newProps = {
noToc: true,
noTOC: true,
};
Comment thread
marcoscaceres marked this conversation as resolved.
Object.assign(ops.config, newProps);
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2016/fixup.js']";
const elem = doc.querySelector(query);
expect(elem).toBeNull();
});

it("shouldn't include fixup.js when legacy noToc is set", async () => {
const ops = makeStandardGeoOps();
Object.assign(ops.config, { noToc: true });
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2016/fixup.js']";
const elem = doc.querySelector(query);
expect(elem).toBeNull();
});
});
15 changes: 12 additions & 3 deletions tests/spec/w3c/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,22 @@ describe("W3C - Style", () => {
expect(linkBase.nextElementSibling).toBe(linkDarkMode);
});

it("shouldn't include fixup.js when noToc is set", async () => {
it("shouldn't include fixup.js when noTOC is set", async () => {
const ops = makeStandardOps();
const newProps = {
noToc: true,
noTOC: true,
};
Comment on lines +253 to 257
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: test verifying noToc: true (legacy spelling) still suppresses fixup.js.

Object.assign(ops.config, newProps);
const doc = await makeRSDoc(ops, "spec/core/simple.html");
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2021/fixup.js']";
const elem = doc.querySelector(query);
expect(elem).toBeNull();
});

it("shouldn't include fixup.js when legacy noToc is set", async () => {
const ops = makeStandardOps();
Object.assign(ops.config, { noToc: true });
const doc = await makeRSDoc(ops);
const query = "script[src^='https://www.w3.org/scripts/TR/2021/fixup.js']";
const elem = doc.querySelector(query);
expect(elem).toBeNull();
Expand Down