From 78823cc71f296b5b1d6624dc93ee7244bea4ef30 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 23 Jul 2022 23:08:16 +0800 Subject: [PATCH] chore(website): multiple fixes to rule docs generation (#5365) * chore(website): multiple fixes to rule docs generation * add trailing period --- packages/website/plugins/generated-rule-docs.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index 23ff08c54df..f074db04355 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -18,18 +18,21 @@ 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((value, index, array) => ({ + type: index % 2 === 0 ? 'text' : 'inlineCode', + value: index === array.length - 1 ? `${value}.` : value, + })), type: 'paragraph', }, ],