Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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) conf.noTOC = conf.noToc;
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
// 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) conf.noTOC = conf.noToc;
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
// 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) conf.noTOC = conf.noToc;
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
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) conf.noTOC = conf.noToc;
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
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
4 changes: 2 additions & 2 deletions tests/spec/aom/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
expect(elem.content).toBe(expectedStr);
});

it("doesn't include fixup.js when noToc is set", async () => {
const ops = makeStandardAomOps({ noToc: true });
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();

Check failure on line 60 in tests/spec/aom/style-spec.js

View workflow job for this annotation

GitHub Actions / Karma Unit Tests (ChromeHeadless)

AOM - Style doesn't include fixup.js when noTOC is set Expected [object HTMLScriptElement] to be null.
});
});
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
4 changes: 2 additions & 2 deletions tests/spec/geonovum/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ 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);
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/w3c/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ 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 thread
marcoscaceres marked this conversation as resolved.
Object.assign(ops.config, newProps);
const doc = await makeRSDoc(ops, "spec/core/simple.html");
Expand Down
Loading