Closed ryyppy closed 4 years ago
@ryyppy my only concern is that most people probably won't read the Module description. So they might miss it an now copy & pasting the example will fail. We could add a small link/hint to the prelude the examples that use it, but not sure if it's too noisy.
@nikgraf What if we had a copy button which always includes the prelude (when necessary)?
@fhammerschmidt I think it's a missleading UX if the copy button contains more than the actual visible text. (maybe that's the reason I also never use them and just select and copy text). If others do that as well they would miss out on the working example.
@nikgraf to think about it from a concrete perspective: If I would go ahead and copy the example for let's say, some Set function, and I get a compile error that the CmpInt
module is missing, I'd probably go back to the docs page and CMD-F for said module and find the prelude example... I don't think it will cause many troubles (maybe we will get a lot of feedback, then we need to think about it anyways)
This PR will enable prelude snippet support. What does that mean? Some modules require some shared code to express examples more easily (and to reduce repetitive writing). Such as the
pages/belt_docs/set.mdx
file.How to use it?
Preferably in the beginning of the module description, you add your prelude as a codeblock with a
re prelude
metastring. This will still render the codeblock like any other example, but in the testing script, it will do following extra tasks:Also this PR fixes an issue with line number parsing / replacement when a syntax parse error occurs.
Fixes #55