Executing Code Blocks #354
-
Hi, I am really impressed what you achieved with code blocks inside your documentation - it looks awesome! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The current code blocks all use Pyodide. They can run any code that is currently loaded into Pyodide, in my case, ColorAide. For general code execution, the code is actually much more simple as I do some advanced stuff to identify color objects so so I can auto-generate color previews and gradients. None of that is needed for basic Python execution and can be stripped out. It can probably be further simplified if you don't need a dedicated "notebook" page. There are currently two parts
Ideally, this is all done using Material's instant mode so that you don't have to reload package dependencies into the browser on every page change. Currently, it is not necessarily user-friendly for others to just pick up and use themselves, especially since there is a bunch of color-specific stuff in the code. |
Beta Was this translation helpful? Give feedback.
The current code blocks all use Pyodide. They can run any code that is currently loaded into Pyodide, in my case, ColorAide. For general code execution, the code is actually much more simple as I do some advanced stuff to identify color objects so so I can auto-generate color previews and gradients. None of that is needed for basic Python execution and can be stripped out. It can probably be further simplified if you don't need a dedicated "notebook" page.
There are currently two parts
custom code blocks via SuperFences custom fences. This allows me to write normal code blocks in MkDocs with Python code and they will be executed and appear to have been run in a reply showing the results…