Should we add an interactive demonstration to the documentation and if so, what form should it take?
First, some background: Back in 2012 I had created a small one-page site which replicated the demo on daringfireball.net, which is currently hosted at https://waylan.pythonanywhere.com/dingus (I expect that to go away soon and the link will be dead). The old tool used a traditional Python server to accept a POST request and rebuild the page with the rendered Markdown included (the code is preserved here). Recently, I updated the tool to use Pyodide, which runs a Python instance directly in the browser. The new site is a single page app which runs completely in the browser, no server needed once the page is loaded (I have had a local instance running in a browser tab for a week after terminating the dev server). Code is at Python-Markdown/dingus and you can see a demo at https://dingus.python-markdown.workers.dev/.
As I was working on an update to the documentation for this project (#1627) it occurred to me that we could include a demo right in the documentation now that no server component is needed. My question is: what form should the demo be? There are a few options:
- Copy the existing solution into the docs as-is. This would work but would not match the site's style.
- Reimplement in the style of the site. We could even use Content Tabs to switch between the source, raw output, and preview.
- Implement a Python console. Basically, slightly modify Pyodide's example to have it preinstall Python-Markdown and some common extensions (such as PyMdown) so that users can import and run the library in their browser.
I started to build Option 2 as part of #1627, but backed it out as it was getting complicated and makes more sense as a separate PR. My thinking is that I would like to give users the option to play with the config options. The existing solution only allows enabling extensions, but there is no way to set config options. Therefore, I was thinking option 2 could include a fourth tab which provided the user with an editable YAML or JSON file to define all of the keyword arguments to pass into markdown.markdown. But then we would need to build the in-browser code to process and error-handle that along with documentation for is. I also considered just creating a form for all of the options. but that would limit options to what is explicitly implemented. Then it occurred to me that Option 3 was possible. That would let users try writing the code themselves without the need to set up any environment or install any tools. It would also give users the ability to fully customize any option (such as the toc slugify option which accepts a Python callable; a YAML parser would need to be "safe" in this environment and wouldn't be able to support that). The console is sandboxed and users would only be able to import the libraries we preselect (in addition to the list of libs provided by Pyodide by default). The console would also not persist across sessions and therefore would not be sharable by multiple users. We could incorporate a copy-to-clipboard and/or download-to-file button for users to easily save their work and/or copy to a bug report. One thing the console would not do is display an in-browser preview (I am not interested in reimplementing Python-notebook; although, if some already did, that might be a better solution...).
I like Option 3 as we are a library first. Option 3 is directly targeted at developers. And it would encourage bug reports which include console sessions (and therefore would clearly include all config options that the user is using). That said, a significant portion of our users are not Python developers, but users of MkDocs, Zensical and the like. Those users could be intimidated by a console, but might be very comfortable with a YAML/JSON config. Many would likely prefer Options 1 and 2.
One final thought: Yes, we could offer both a console and non-console options, but if we went that route, then my inclination would be to do the console (Option 3) and leave the existing tool at https://dingus.python-markdown.workers.dev/ in place.
Before I spend any more time on Option 2, I thought I would ask for feedback from others. Is there anything obvious I am missing? Or maybe someone knows of a serverless (fully in-browser) Python-Notebook-like-implementation we could incorporate.
Should we add an interactive demonstration to the documentation and if so, what form should it take?
First, some background: Back in 2012 I had created a small one-page site which replicated the demo on daringfireball.net, which is currently hosted at https://waylan.pythonanywhere.com/dingus (I expect that to go away soon and the link will be dead). The old tool used a traditional Python server to accept a POST request and rebuild the page with the rendered Markdown included (the code is preserved here). Recently, I updated the tool to use Pyodide, which runs a Python instance directly in the browser. The new site is a single page app which runs completely in the browser, no server needed once the page is loaded (I have had a local instance running in a browser tab for a week after terminating the dev server). Code is at Python-Markdown/dingus and you can see a demo at https://dingus.python-markdown.workers.dev/.
As I was working on an update to the documentation for this project (#1627) it occurred to me that we could include a demo right in the documentation now that no server component is needed. My question is: what form should the demo be? There are a few options:
I started to build Option 2 as part of #1627, but backed it out as it was getting complicated and makes more sense as a separate PR. My thinking is that I would like to give users the option to play with the config options. The existing solution only allows enabling extensions, but there is no way to set config options. Therefore, I was thinking option 2 could include a fourth tab which provided the user with an editable YAML or JSON file to define all of the keyword arguments to pass into
markdown.markdown. But then we would need to build the in-browser code to process and error-handle that along with documentation for is. I also considered just creating a form for all of the options. but that would limit options to what is explicitly implemented. Then it occurred to me that Option 3 was possible. That would let users try writing the code themselves without the need to set up any environment or install any tools. It would also give users the ability to fully customize any option (such as the toc slugify option which accepts a Python callable; a YAML parser would need to be "safe" in this environment and wouldn't be able to support that). The console is sandboxed and users would only be able to import the libraries we preselect (in addition to the list of libs provided by Pyodide by default). The console would also not persist across sessions and therefore would not be sharable by multiple users. We could incorporate a copy-to-clipboard and/or download-to-file button for users to easily save their work and/or copy to a bug report. One thing the console would not do is display an in-browser preview (I am not interested in reimplementing Python-notebook; although, if some already did, that might be a better solution...).I like Option 3 as we are a library first. Option 3 is directly targeted at developers. And it would encourage bug reports which include console sessions (and therefore would clearly include all config options that the user is using). That said, a significant portion of our users are not Python developers, but users of MkDocs, Zensical and the like. Those users could be intimidated by a console, but might be very comfortable with a YAML/JSON config. Many would likely prefer Options 1 and 2.
One final thought: Yes, we could offer both a console and non-console options, but if we went that route, then my inclination would be to do the console (Option 3) and leave the existing tool at https://dingus.python-markdown.workers.dev/ in place.
Before I spend any more time on Option 2, I thought I would ask for feedback from others. Is there anything obvious I am missing? Or maybe someone knows of a serverless (fully in-browser) Python-Notebook-like-implementation we could incorporate.