Skip to content

Commit

Permalink
Expose htmlProse field from webref in xref route
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom committed Feb 12, 2024
1 parent 5769f0e commit 4167e5f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
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

0 comments on commit 4167e5f

Please sign in to comment.