From ad422bac86e545ac620a267bb89bc598f746789f Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 23 Jul 2022 21:00:13 +0800 Subject: [PATCH 1/2] chore(website): multiple fixes to rule docs generation --- packages/website/plugins/generated-rule-docs.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index 23ff08c54df1..2ec78979258a 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -18,18 +18,19 @@ const generatedRuleDocs: Plugin = () => { const parent = root as unist.Parent; // 1. Remove the " 🛑 This file is source code, not the primary documentation location! 🛑" - parent.children.splice(3, 1); + parent.children.splice( + parent.children.findIndex(v => v.type === 'blockquote'), + 1, + ); // 2. Add a description of the rule at the top of the file parent.children.unshift({ children: [ { - children: [ - { - type: 'text', - value: `${docs.description}.`, - }, - ], + children: docs.description.split(/`(.+?)`/).map((v, i) => ({ + type: i % 2 === 0 ? 'text' : 'inlineCode', + value: v, + })), type: 'paragraph', }, ], From 621ae053ff92e476b1a807709e8bd2324e2f2a52 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 23 Jul 2022 22:02:16 +0800 Subject: [PATCH 2/2] add trailing period --- packages/website/plugins/generated-rule-docs.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index 2ec78979258a..f074db043551 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -27,10 +27,12 @@ const generatedRuleDocs: Plugin = () => { parent.children.unshift({ children: [ { - children: docs.description.split(/`(.+?)`/).map((v, i) => ({ - type: i % 2 === 0 ? 'text' : 'inlineCode', - value: v, - })), + children: docs.description + .split(/`(.+?)`/) + .map((value, index, array) => ({ + type: index % 2 === 0 ? 'text' : 'inlineCode', + value: index === array.length - 1 ? `${value}.` : value, + })), type: 'paragraph', }, ],