Skip to content

Commit dc693b7

Browse files
committed
hotfix: added missing json simple parsing
1 parent 1ac979c commit dc693b7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/generators/json-simple/index.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ export default {
3434
const remarkProcessor = getRemark();
3535

3636
// Iterates the input (ApiDocMetadataEntry) and performs a few changes
37-
const mappedInput = input.map(({ content, ...rest }) => {
38-
// Depp clones the content nodes to avoid affecting upstream nodes
39-
const clonedContent = JSON.parse(JSON.stringify(content));
37+
const mappedInput = input.map(node => {
38+
// Deep clones the content nodes to avoid affecting upstream nodes
39+
const content = JSON.parse(JSON.stringify(node.content));
4040

4141
// Removes all the Stability Index nodes, since they shouldn't be included in the final JSON
4242
// and are already represented in the metadata (metadata.stability.toJSON)
43-
remove(clonedContent, [createQueries.UNIST.isStabilityNode]);
43+
remove(content, [createQueries.UNIST.isStabilityNode]);
4444

4545
// For the JSON generate we want to transform the whole content into JSON
46-
clonedContent.toJSON = () => remarkProcessor.stringify(clonedContent);
46+
content.toJSON = () => remarkProcessor.stringify(content);
4747

48-
return { ...rest, content: clonedContent };
48+
return { ...node, content };
4949
});
5050

5151
// This simply grabs all the different files and stringifies them

src/queries.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ const createQueries = () => {
170170
createQueries.QUERIES = {
171171
// Fixes the references to Markdown pages into the API documentation
172172
markdownUrl: /^(?![+a-zA-Z]+:)([^#?]+)\.md(#.+)?$/,
173-
// ReGeX to match the {Type}<Type> (Structure Type metadatas)
173+
// ReGeX to match the {Type}<Type> (API type references)
174174
// eslint-disable-next-line no-useless-escape
175175
normalizeTypes: /(\{|<)(?! )[a-zA-Z0-9.| \[\]\\]+(?! )(\}|>)/g,
176+
// ReGex to match the type API type references that got already parsed
177+
// so that they can be transformed into HTML links
178+
linksWithTypes: /\[`<([a-zA-Z0-9.| \\[\]]+)>`\]\((.*)\)/,
176179
// ReGeX for handling Stability Indexes Metadata
177180
stabilityIndex: /^Stability: ([0-5])(?:\s*-\s*)?(.*)$/s,
178181
// ReGeX for handling the Stability Index Prefix
@@ -189,6 +192,8 @@ createQueries.UNIST = {
189192
type === 'html' && createQueries.QUERIES.yamlInnerContent.test(value),
190193
isTextWithType: ({ type, value }) =>
191194
type === 'text' && createQueries.QUERIES.normalizeTypes.test(value),
195+
isHtmlWithType: ({ type, value }) =>
196+
type === 'html' && createQueries.QUERIES.linksWithTypes.test(value),
192197
isMarkdownUrl: ({ type, url }) =>
193198
type === 'link' && createQueries.QUERIES.markdownUrl.test(url),
194199
isHeading: ({ type, depth }) =>

0 commit comments

Comments
 (0)