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

MarkdownAIO

Open AnnMarieW opened this issue 4 years ago • 0 comments

Adds the new component MarkdownAIO

See the live demo

MarkdownAIO is a Dash feature that allows you to write Dash Apps as Markdown files. Simply pass in a Markdown file and MarkdownAIO will return a set of components with the option to display and/or execute code blocks. So it’s part:

  • Documentation helper
  • Markdown / Text authoring tool
  • Easy way to bring a Markdown file into an app without doing open('file.md')

It's also compatible with the pages/ api. The online docs for dash-labs is a multi-page app made with pages/ and each page is a Markdown file displayed using MarkdownAIO.


Here is a summary of the TODOs and questions:

  • [x] To further reduce security risk with exec, check for local files only. Ensure that the file is within a certain directory, and by default that should be the parent directory of the main app but maybe we could create a way to override that. Similar to /assets? Update - require full path from pages/

  • [ ] css:

    • create a MarkdownAIO stylesheet?
    • eliminated dbc dependency (replace Rows and Cols with inline css)
    • document the default style in subcomponents. Or better yet - use a stylesheet? Status: inprogress
  • [x] see todos in pages.py in _register_page_from_markdown_file()

  • [x ] use UUID for clipboard ID?

  • [ ] add ability to change defaults "globally" so it doesn't have to be done for each MarkdownAIO() instance.

  • [x] add ability to embed another file within the Markdown file. Use case being, ability to keep the python app code in a separate file so you can run it individually. We could integrate jinja in here perhaps…: {% include code.py %}

  • [ ] Add Markdown files to hot reload in dash. That way users can have the same hot-reloading dev experience when working in markdown

  • [ ] if code block is not executed don't register callbacks and layout? Goal it to reduce the number of id clashes.

  • [ ] Need to remove if __name__ == "__main__": ... from the code blocks?

  • [x] refactor _update_props() (It works, but it's kinda ugly)

  • [x] rewrite the _remove_app_instance() to use the AST module

AnnMarieW avatar Jan 31 '22 17:01 AnnMarieW