Python Code Playground in MkDocs. Making documentation come to life | by Kay Jan Wong | Aug, 2024

Making documentation come to life

Picture 1: Python Code Playground in Mkdocs in my documentation — Picture by writer

Impressed by dwell coding playgrounds, the place customers can code on the web site as an alternative of downloading the programming language or software program, how cool wouldn’t it be to have it in MkDocs documentation and have your Python package deal obtainable in a “plug-and-play” mode?

Documentation ought to minimally have a person and technical information, along with a glossary and launch notes. However documentation can actually come to life if readers can work together with the code instantly on the documentation!

After scouring by the Web, I noticed coding playgrounds are simpler to arrange with JavaScript, whereas my MkDocs documentation and your complete codebase have been in Python. After a lot looking out, I discovered this discussion board with what I needed, however the playground was closely hardcoded to work with one other Python package deal. I made a decision to adapt that to a generic resolution and can elaborate step-by-step on what is required and what might be tweaked to be just right for you.

Be aware: These are the hyperlinks to the playground and my codebase. Extra helpful hyperlinks might be discovered within the “Associated Hyperlinks” part on the finish of this text.