mainsail-crew / mainsail

Mainsail is the popular web interface for managing and controlling 3D printers with Klipper.
https://docs.mainsail.xyz
GNU General Public License v3.0
1.69k stars 353 forks source link

feat: CodeMirror plugin for Klipper Documentation tooltip links in editor #1898

Open khill-fbmc opened 4 months ago

khill-fbmc commented 4 months ago

Description

This PR adds the following features:

Desktop Screenshots

Editor Before

editor_before

Editor After

editor_after

Settings Before

settings_before

Settings After

settings_after

Note

I am not the happiest with how the actual code is written for the CodeMirror plugin in CodeMirrorPluginKlipperDocsTooltips.ts, so this PR is the POC / MVP of the idea to see if it has any interest.

PS: I am also terrible with naming files, I apologize that it is so long, heh

github-actions[bot] commented 4 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 2
github-actions[bot] commented 4 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 2
khill-fbmc commented 4 months ago

I have never tried to submit a PR like this to a popular repo, so please be kind if I am not doing it correctly.

I didn't mean to set it for review, unless, that was correct. I will leave this as a draft for now since I assume it might need more work...

meteyou commented 4 months ago

@khill-fbmc thank you very much for this PR! I think this is a very useful function for the editor!

i've only looked at it briefly so far, but what immediately caught my eye is the long list of possible Klipper modules. would it be possible to make this list “dynamic”? i.e. simply link to the Klipper docs in general, even if this module doesn't exist?

this would just minimize the effort to update this list.

khill-fbmc commented 4 months ago

Thank you! I agree that trying to maintain a list of module names was not optimal. I had ChatGPT extract them from the docs page just to see if it would work.

I will work out a better solution and remove the big array of keywords. My thought process was to avoid having any tooltip generate a link that might be a 404.

github-actions[bot] commented 4 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 2
khill-fbmc commented 4 months ago

I removed the keywords array and tweaked the algorithm to match on words in the brackets. I think it is safe that if it is a valid config section, then it will link. If you put [exduder] then a 404 would actually help you realize a typo.

I tweaked the CSS a little too to reduce the amount of contrast with the link text. image

kevinkhill commented 4 months ago

I just noticed this, maybe I could use it instead of my hard-coded URL

meteyou commented 3 months ago

i had a little more time today to take a closer look at the PR and i noticed the following things:

Thank you very much and feel free to ping me, if you need help.

kevinkhill commented 3 months ago

I have not forgotten this. I am just ADHD and things sit longer than I realize :)

meteyou commented 3 months ago

@khill-fbmc no problem! Take the time you need for this PR.