From 693e5699accc94835c403888139cd1575ef1ef61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Vodovnik?= Date: Wed, 17 Mar 2021 15:20:37 +0100 Subject: [PATCH] chore(docs): add support for language specific notes (#5810) --- utils/doclint/documentation.js | 14 ++++++++++++++ utils/markdown.js | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/doclint/documentation.js b/utils/doclint/documentation.js index e2568addf2..00ca671a45 100644 --- a/utils/doclint/documentation.js +++ b/utils/doclint/documentation.js @@ -207,6 +207,7 @@ Documentation.Class = class { member.filterForLanguage(lang); membersArray.push(member); } + this.spec = filterSpecs(this.spec, lang); this.membersArray = membersArray; } @@ -340,6 +341,7 @@ Documentation.Member = class { argsArray.push(overriddenArg); } this.argsArray = argsArray; + this.spec = filterSpecs(this.spec, lang); } clone() { @@ -687,4 +689,16 @@ function generateSourceCodeComment(spec) { return md.render(comments, 120); } +/** + * + * @param {MarkdownNode[]} spec + * @param {string} lang + * @returns {MarkdownNode[]} + */ +function filterSpecs(spec, lang) { + if(!spec) + return; + return spec.filter(n => n.type !== 'note' || (n.type === 'note' && (!n.codeLang || n.codeLang === lang))); +} + module.exports = Documentation; diff --git a/utils/markdown.js b/utils/markdown.js index 91e68899a2..453a64f437 100644 --- a/utils/markdown.js +++ b/utils/markdown.js @@ -141,10 +141,12 @@ function buildTree(lines) { } if (content.startsWith(':::')) { + let noteType = content.substring(3).split(' '); /** @type {MarkdownNode} */ const node = { type: 'note', - noteType: content.substring(3) + noteType: noteType[0], + codeLang: noteType[1] }; line = lines[++i]; const tokens = [];