Using interactive widgets as part of the documentation is a great way to make parts of the docs more flexible, allowing it to cater to multiple audiences while still being clear and concise.
I eventually got something like this done for k6 which was published as the xk6 extension bundler.
Examples
installation instructions by spaCy