Skip to content

Commit c7cd41b

Browse files
committed
fix stability
1 parent c2e7947 commit c7cd41b

File tree

10 files changed

+15
-13
lines changed

10 files changed

+15
-13
lines changed

src/generators/jsx-ast/test/utils.test.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ test('buildMetaBarProps includes expected fields', () => {
4848
assert.deepEqual(result.viewAs, [['JSON', 'sample-api.json']]);
4949
assert.ok(result.readingTime.startsWith('1 min'));
5050
assert.ok(result.editThisPage.endsWith('sample-api.md'));
51-
assert.deepEqual(result.headings, [{ depth: 2, value: 'SampleFunc' }]);
51+
assert.deepEqual(result.headings, [
52+
{ depth: 2, value: 'SampleFunc', data: { id: 'sample-func' } },
53+
]);
5254
});
5355

5456
test('createJSXElement builds correct JSX tree', () => {

src/generators/jsx-ast/utils/buildContent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const createSourceLink = sourceLink => {
8686
const transformStabilityNode = ({ data }, index, parent) => {
8787
parent.children[index] = createJSXElement(JSX_IMPORTS.AlertBox.name, {
8888
children: data.description,
89-
level: STABILITY_LEVELS[data.index],
89+
level: STABILITY_LEVELS[parseInt(data.index)],
9090
title: data.index,
9191
});
9292

src/generators/legacy-html/utils/buildContent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const buildStability = ({ children, data }, index, parent) => {
5353
// Creates the `div` element with the class `api_stability` and the stability index class
5454
// FYI: Since the Stability Index `blockquote` node gets modified within `queries.mjs`
5555
// it contains the StabilityIndexMetadataEntry within the `data` property
56-
`div.api_stability.api_stability_${data.index}`,
56+
`div.api_stability.api_stability_${parseInt(data.index)}`,
5757
// Processed the Markdown nodes into HTML nodes
5858
children
5959
);

src/generators/legacy-html/utils/buildExtraContent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const buildStabilityOverview = headMetadata => {
2626
createElement('a', { href: `${api}.html` }, heading.data.name)
2727
),
2828
createElement(
29-
`td.api_stability.api_stability_${data.index}`,
29+
`td.api_stability.api_stability_${parseInt(data.index)}`,
3030
// Grabs the first sentence of the description
3131
// to be used as a summary of the Stability Index
3232
`(${data.index}) ${data.description.split('. ')[0]}`

src/generators/legacy-html/utils/tableOfContents.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ tableOfContents.parseToCNode = ({ stability, api, heading }) => {
5353
const [firstStability] = stability.children;
5454

5555
return (
56-
`<span class="stability_${firstStability.data.index}">` +
56+
`<span class="stability_${parseInt(firstStability.data.index)}">` +
5757
`<a href="${fullSlug}">${heading.data.text}</a></span>`
5858
);
5959
}

src/generators/legacy-json/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface SectionBase {
7878
/**
7979
* Stability index of the section.
8080
*/
81-
stability?: number;
81+
stability?: string;
8282

8383
/**
8484
* Descriptive text related to the stability of the section (E.G. "Experimental").

src/generators/web/components/CodeBox.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const MDXCodeBox = ({ className, ...props }) => {
77
const language = matches?.groups?.language ?? '';
88
const [copyText, setCopyText] = useState('Copy to clipboard');
99

10-
const handleCopy = async (text) => {
10+
const handleCopy = async text => {
1111
await navigator.clipboard.writeText(text);
1212

1313
setCopyText('Copied to clipboard!');

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface NodeWithData<T extends Node, J extends Data> extends T {
1010

1111
declare global {
1212
export interface StabilityIndexMetadataEntry {
13-
index: number;
13+
index: string;
1414
description: string;
1515
}
1616

src/utils/queries/index.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const createQueries = () => {
134134
// so that the original node data can also be inferred
135135
node.data = {
136136
// The 2nd match should be the group that matches the Stability Index
137-
index: Number(matches[1]),
137+
index: matches[1],
138138
// The 3rd match should be the group containing all the remaining text
139139
// which is used as a description (we trim it to an one liner)
140140
description: matches[2].replace(/\n/g, ' ').trim(),
@@ -190,9 +190,9 @@ createQueries.QUERIES = {
190190
// so that they can be transformed into HTML links
191191
linksWithTypes: /\[`<([a-zA-Z0-9.| \\[\]]+)>`\]\((\S+)\)/g,
192192
// ReGeX for handling Stability Indexes Metadata
193-
stabilityIndex: /^Stability: ([0-5])(?:\s*-\s*)?(.*)$/s,
193+
stabilityIndex: /^Stability: ([0-5](?:\.[0-3])?)(?:\s*-\s*)?(.*)$/s,
194194
// ReGeX for handling the Stability Index Prefix
195-
stabilityIndexPrefix: /Stability: ([0-5])/,
195+
stabilityIndexPrefix: /Stability: ([0-5](?:\.[0-3])?)/,
196196
// ReGeX for retrieving the inner content from a YAML block
197197
yamlInnerContent: /^<!--[ ]?(?:YAML([\s\S]*?)|([ \S]*?))?[ ]?-->/,
198198
};

src/utils/tests/queries.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ describe('createQueries', () => {
9696
children: [
9797
{
9898
type: 'paragraph',
99-
children: [{ type: 'text', value: 'Stability: 2 - Frozen' }],
99+
children: [{ type: 'text', value: 'Stability: 1.0 - Frozen' }],
100100
},
101101
],
102102
};
103103
const apiEntryMetadata = {
104104
addStability: stability => {
105105
deepStrictEqual(stability.data, {
106-
index: 2,
106+
index: '1.0',
107107
description: 'Frozen',
108108
});
109109
},

0 commit comments

Comments
 (0)