Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(/xref): expose htmlProse field from webref #401

Merged
merged 2 commits into from
Feb 12, 2024
Merged
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
1 change: 1 addition & 0 deletions @types/webref.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare module "webref" {
informative: boolean;
heading: Record<string, string>;
definedIn: string;
htmlProse: string;
}

interface SpecVersion {
Expand Down
1 change: 1 addition & 0 deletions routes/xref/lib/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function mapDefinition(
uri: dfn.href.replace(spec.url, ""), // This is full URL to term here
normative: !dfn.informative,
for: dfn.for.length > 0 ? dfn.for : undefined,
htmlProse: dfn.htmlProse,
};
}

Expand Down
3 changes: 2 additions & 1 deletion routes/xref/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface DataEntry {
uri: string;
normative: boolean;
for?: string[];
htmlProse?: string;
}

type SpecType = DataEntry["status"] | "draft" | "official";
Expand Down Expand Up @@ -58,7 +59,7 @@ const specStatusAlias = new Map([
]);

export const defaultOptions: Options = {
fields: ["shortname", "spec", "type", "for", "normative", "uri"],
fields: ["shortname", "spec", "type", "for", "normative", "uri", "htmlProse"],
spec_type: ["draft", "official"],
types: [],
};
Expand Down
2 changes: 2 additions & 0 deletions tests/routes/xref/lib/data-by-term.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export default {
shortname: "font-metrics-api",
status: "current",
uri: "#baseline",
normative: true,
htmlProse: "test html Prose",
},
],
baseline: [
Expand Down
3 changes: 3 additions & 0 deletions tests/routes/xref/lib/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ describe("xref - search", () => {
spec: "font-metrics-api-1",
type: "interface",
uri: "#baseline",
normative: true,
htmlProse: "test html Prose",
for: undefined,
},
]);
});
Expand Down
3 changes: 2 additions & 1 deletion tests/routes/xref/lib/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ describe("xref - utils", () => {
});
expect(utils.pickFields(object, ["foo", "nope", "bar"])).toEqual({
foo: object.foo,
bar: object.foo,
bar: object.bar,
nope: undefined,
});
expect(utils.pickFields(object, ["bar"]).bar).toBe(object.bar);
});
Expand Down