Mkdocs Pyscript

screenshot of Mkdocs Pyscript

Use PyScript in mkdocs

Overview

mkdocs-pyscript is an innovative plugin designed to enhance the functionality of mkdocs by enabling users to transform code blocks into executable Python scripts right in their browsers. This means no backend server is needed, making it an efficient choice for developers looking to provide interactive code experiences. With its user-friendly interface and simple setup, mkdocs-pyscript empowers users to run and modify Python code seamlessly within their documentation.

The ability to execute code snippets directly within a browser not only streamlines the coding experience but also enriches the learning and experimentation process. By incorporating features that support interactive coding, mkdocs-pyscript is paving the way for a more dynamic and engaging approach to documentation.

Features

  • Browser Execution: Run Python scripts directly in the user's browser, eliminating the need for a backend server.
  • Interactive Code Blocks: Each Python fenced code block includes a LOAD button, turning static examples into editable snippets.
  • Web Worker Support: Code is executed in a separate Web Worker, ensuring that the main thread remains unblocked for improved performance.
  • Pre and Post Code Execution: Implement setup and teardown code using .py-pre and .py-post classes, enhancing the functionality of code snippets.
  • Configurable Options: Customize behavior through settings in the mkdocs.yaml, including version control for PyScript.
  • Selective Code Execution: Enable only specific code blocks for execution by marking them with an additional class, providing better control over the interaction.
  • Support for Latest Versions: Load both pre-release snapshots and stable versions of PyScript with flexibility in configuration.