dash-docs icon indicating copy to clipboard operation
dash-docs copied to clipboard

Tool to build dash docs chapter from notebook + chapter on image annotation

Open emmanuelle opened this issue 4 years ago • 4 comments

This PR is made of two contributions:

  • I modified and extended tools.py so that it can parse a jupyter notebook file (to be included as a markdown file for easier version control, but it could also be an ipynb file), where every cell is a JupyterDash app. Indeed, a notebook is an easy way to develop small apps for documentation (which can also be hosted on binder for example).
  • This tool was motivated by the notebook which I have written for new documentation on image annotations with shape drawing. This tutorial is still work in progress, I'll polish the content and add a few examples today.

I'm interested in an early high-level review of the "notebook to dash docs chapter" process. I noticed a few caveats, for example:

  • one must avoid name collisions between different cells of the notebook, because even if every cell of the notebook is a different JupyterDash app, all their layouts are merged in a single Dash app. A future improvement could check for collisions and change component names.
  • at the moment it is not possible to have cells not defining a Dash app. Since every cell must be transformed into layout elements (and possibly callbacks to be attached), one could also permit to have notebook cells displaying plotly figures, and include the figure in a dcc.Graph as layout element.

Post-merge checklist:

The master branch is auto-deployed to dash.plotly.com. Once you have merged your PR, wait 5-10 minutes and check dash.plotly.com to verify that your changes have been made.

  • [x] I understand

If this PR documents a new feature of Dash:

  • [ ] Comment on the original Dash issue with a link to the new docs.
  • [ ] Reply to any community thread(s) asking for this feature.

If I introduced a new relative link inside dcc.Markdown:

  • [x] I considered whether I could replace the dcc.Markdown call with rc.Markdown, which will replace relative links with tools.relpath internally. Otherwise, I used e.g. <dccLink href=tools.relpath('/layout') children="the first chapter"/> instead of [the first chapter](/layout) (importing tools from dash_docs), and set dangerously_allow_html=true in the dcc.Markdown call.

emmanuelle avatar Oct 27 '20 12:10 emmanuelle

The CI failure seems unrelated to this PR, but the dash-docs build does not seem to complete ever.

I've updated the tutorial on annotations, so that the PR is now ready for review I think.

emmanuelle avatar Oct 27 '20 15:10 emmanuelle

Neat idea @emmanuelle! We may want to have a discussion on Friday about how this would fit with some of the ideas @Marc-Andre-Rivet, @rpkyle, and I were discussing earlier today about how we can make multi-language (ie R, Julia) support more manageable, but anything that makes it easier for more folks to contribute to the docs deserves serious consideration 🥇

The test failures just come from the new page not being in the sitemap I think - I believe you just need to run python generate_sitemap.py - then hopefully the percy job will complete as well.

alexcjohnson avatar Oct 27 '20 22:10 alexcjohnson

@jonmmease is there any plan to build the equivalent of JupyterDash for Julia and/or R? Indeed, the workflow proposed in this PR (writing a notebook with several cells, each of them corresponding to a JupyterDash app) works well for Python, with less boilerplate code to write the index.py. However, the workflow does not translate directly to Julia and R.

emmanuelle avatar Nov 08 '20 09:11 emmanuelle

@jonmmease is there any plan to build the equivalent of JupyterDash for Julia and/or R?

For R, I've talked about this a little bit with @rpkyle, but there were some technical challenges with the R webserver library that made it less than straightforward. I've not discussed it with anyone from the Julia side.

jonmmease avatar Nov 08 '20 14:11 jonmmease