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


Making documentation come to life

Towards Data Science
Image 1: Python Code Playground in Mkdocs in my documentation — Image by author

Inspired by live coding playgrounds, where users can code on the website instead of downloading the programming language or software, how cool would it be to have it in MkDocs documentation and have your Python package available in a “plug-and-play” mode?

Documentation should minimally have a user and technical guide, together with a glossary and release notes. But documentation can truly come to life if readers can interact with the code directly on the documentation!

After scouring through the Internet, I realized coding playgrounds are easier to set up with JavaScript, while my MkDocs documentation and the entire codebase were in Python. After much searching, I found this forum with what I wanted, but the playground was heavily hardcoded to work with another Python package. I decided to adapt that to a generic solution and will elaborate step-by-step on what is needed and what can be tweaked to work for you.

Note: These are the links to the playground and my codebase. More useful links can be found in the “Related Links” section at the end of this article.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here