Skip to content

Commit 6c0bfd5

Browse files
committed
dont clone stability, use ref
1 parent 9af1e62 commit 6c0bfd5

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

src/generators/legacy-json/utils/buildSection.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ export const createSectionBuilder = () => {
109109
section.stability = Number(stabilityNode.data.index);
110110
section.stabilityText = stabilityNode.data.description;
111111

112-
const nodeToRemove = content.children.findIndex(
113-
({ data }) => data === stabilityNode.data
114-
);
115-
nodes.splice(nodeToRemove - 1, 1);
112+
const stabilityIdx = content.children.indexOf(stability.children[0]);
113+
114+
if (stabilityIdx) {
115+
nodes.splice(stabilityIdx - 1, 1);
116+
}
116117
}
117118
};
118119

src/metadata.mjs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ const createMetadata = slugger => {
4747
*
4848
* @param {StabilityIndexParent} stability The stability index node to be added
4949
*/
50-
addStability: stability => {
51-
// We clone the stability to ensure that we don't accidentally override it
52-
// with later mutations below on the `.create` method
53-
internalMetadata.stability.children.push({ ...stability });
54-
},
50+
addStability: stability =>
51+
internalMetadata.stability.children.push(stability),
5552
/**
5653
* Set the Metadata (from YAML if exists) properties to the current Metadata entry
5754
* it also allows for extra data (such as Stability Index) and miscellaneous data to be set

src/utils/queries/index.mjs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
import { u as createTree } from 'unist-builder';
43
import { SKIP } from 'unist-util-visit';
54

65
import { DOC_API_STABILITY_SECTION_REF_URL } from './constants.mjs';
@@ -142,15 +141,8 @@ const createQueries = typeMap => {
142141
description: matches[2].replace(/\n/g, ' ').trim(),
143142
};
144143

145-
// Creates a new Tree node containing the Stability Index metadata
146-
const stabilityIndexNode = createTree(
147-
'root',
148-
{ data: node.data },
149-
node.children
150-
);
151-
152144
// Adds the Stability Index metadata to the current Metadata entry
153-
apiEntryMetadata?.addStability(stabilityIndexNode);
145+
apiEntryMetadata?.addStability(node);
154146
}
155147

156148
return [SKIP];

0 commit comments

Comments
 (0)