From e4b00117c311dd309fbe0e969a5053911264b8d7 Mon Sep 17 00:00:00 2001 From: "Alexandre G.-Raymond" Date: Sat, 11 Nov 2023 14:22:52 +0100 Subject: [PATCH 01/73] Parse the synonyms tag in source documentation --- jsdoc-synonyms.js | 17 +++++++++++++++++ jsdoc.config.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 jsdoc-synonyms.js diff --git a/jsdoc-synonyms.js b/jsdoc-synonyms.js new file mode 100644 index 00000000..29aed7b2 --- /dev/null +++ b/jsdoc-synonyms.js @@ -0,0 +1,17 @@ +/* +jsdoc-synonyms.js - Add support for @synonym tag +Copyright (C) 2023 Strudel contributors - see +This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . +*/ + +function defineTags(dictionary) { + dictionary.defineTag('synonyms', { + mustHaveValue: true, + onTagged: function(doclet, tag) { + doclet.synonyms_text = tag.value; + doclet.synonyms = doclet.synonyms_text.split(/[ ,]+/); + } +}); +}; + +module.exports = {defineTags: defineTags} \ No newline at end of file diff --git a/jsdoc.config.json b/jsdoc.config.json index ca9c3d81..4098a5c5 100644 --- a/jsdoc.config.json +++ b/jsdoc.config.json @@ -3,7 +3,7 @@ "includePattern": ".+\\.(js(doc|x)?|mjs)$", "excludePattern": "node_modules|shift-parser|shift-reducer|shift-traverser|dist" }, - "plugins": ["plugins/markdown"], + "plugins": ["plugins/markdown", "jsdoc-synonyms"], "opts": { "destination": "./out/", "recurse": true From bbc292561f20b3fc04637c135693a55f1a77d734 Mon Sep 17 00:00:00 2001 From: "Alexandre G.-Raymond" Date: Sat, 11 Nov 2023 14:23:30 +0100 Subject: [PATCH 02/73] Use synonyms in Tooltip --- packages/react/src/components/Tooltip.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/Tooltip.jsx b/packages/react/src/components/Tooltip.jsx index a443c123..a508e761 100644 --- a/packages/react/src/components/Tooltip.jsx +++ b/packages/react/src/components/Tooltip.jsx @@ -31,6 +31,9 @@ window.addEventListener( export const strudelTooltip = hoverTooltip( (view, pos, side) => { // Word selection from CodeMirror Hover Tooltip example https://codemirror.net/examples/tooltip/#hover-tooltips + if (!ctrlDown) { + return null; + } let { from, to, text } = view.state.doc.lineAt(pos); let start = pos, end = pos; @@ -47,11 +50,14 @@ export const strudelTooltip = hoverTooltip( // Get entry from Strudel documentation let entry = jsdoc.docs.filter((doc) => getDocLabel(doc) === word)[0]; if (!entry) { - return null; - } - if (!ctrlDown) { - return null; + // Try for synonyms + entry = jsdoc.docs.filter((doc) => doc.synonyms && doc.synonyms.includes(word))[0]; + if (!entry) { + return null; + } + entry.name = word; } + return { pos: start, end, From 6ba2b767b0145e1f5463f4c49bae1d1670735066 Mon Sep 17 00:00:00 2001 From: "Alexandre G.-Raymond" Date: Sat, 11 Nov 2023 14:23:55 +0100 Subject: [PATCH 03/73] Show synonyms in API reference --- website/src/repl/Reference.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/src/repl/Reference.jsx b/website/src/repl/Reference.jsx index cf6fd5b1..b43f365e 100644 --- a/website/src/repl/Reference.jsx +++ b/website/src/repl/Reference.jsx @@ -37,6 +37,11 @@ export function Reference() { {visibleFunctions.map((entry, i) => (

{entry.name}

+ {!!entry.synonyms_text && ( +

+ Synonyms: {entry.synonyms_text} +

+ )} {/* {entry.meta.filename} */}