Skip to main content

No project description provided

Project description

Unit tests codecov

The dash-down module provides tools to convert markdown files into Plotly Dash applications.

Getting started

Make sure that you have setup poetry. Then run

poetry install

to install dependencies.

Running the example

poetry run python example.py

Running the tests

poetry run pytest

Custom content

Custom content is rendered the markdown directive syntax extension. A directive has the following syntax,

.. directive-name:: directive value
   :option-key: option value
   :option-key: option value

   full featured markdown text here

where the directive-name is mandatory, while the value, the options (specified as key value pairs), and the text are optional.

What directives are bundled?

Currently, the bundled directives are

  • api-doc - a directive for rendering api documentation for a component
  • dash-proxy - a block for rendering dash apps (including interactivity)

How to create custom directives?

To create a new directive, simply make a subclass of DashDirective and implement the render_directive function. Say you want to make a new directive that yields a plot of the iris dataset. The code would be along the lines of,

import plotly.express as px
from dash_down.directives import DashDirective
from dash_extensions.enrich import dcc

class GraphDirective(DashDirective):
    def render_directive(self, value, text, options, blueprint):
        df = getattr(px.data, options.dataset)()
        fig = px.scatter(df, x=options.x, y=options.y)
        return dcc.Graph(figure=fig)

The directive name is derived from the class name by dropping Directive, and converting to kebab-case (or you can override the get_directive_name function). With this directive defined, you can now create a graph similar to the one in the Dash docs with the following syntax,

.. graph::
   :dataset: iris
   :x: sepal_width
   :y: sepal_length

To render a markdown file using your new, shiny directive, the syntax would be,

from dash_extensions.enrich import DashProxy
from dash_down.express import md_to_blueprint_dmc

path_to_your_md_file = "..."
blueprint = md_to_blueprint_dmc(path_to_your_md_file, plugins=[GraphDirective()])

if __name__ == '__main__':
    DashProxy(blueprint=blueprint).run_server()

A working example is bundled in the repo (see example_custom_directive.py).

How to customize the layout of the rendered blueprint?

The layout of the blueprint returned by the renderer can be customized by passing a custom layout function to the PluginBlueprint. A working example is bundled in the repo (see example_code_renderer.py).

How to customize the markdown rendering itself?

Make a subclass of DashMantineRenderer (or DashHtmlRenderer, if you prefer to start from raw HTML) and override the render function(s) for any element that you want to change.

How to customize the way code is rendered with the DashProxyDirective?

The DashProxyDirective takes optional arguments to customize code rendering. A working example is bundled in the repo (see example_code_renderer.py).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash-down-0.0.13rc7.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_down-0.0.13rc7-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file dash-down-0.0.13rc7.tar.gz.

File metadata

  • Download URL: dash-down-0.0.13rc7.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.1 Darwin/21.3.0

File hashes

Hashes for dash-down-0.0.13rc7.tar.gz
Algorithm Hash digest
SHA256 bdeec44172ca5cf19bb32028c3f031396071b8a21fec4ce30af61dfb5d3a537b
MD5 4e41b3c376ab1fcbb80663fd06b86bc5
BLAKE2b-256 4489bfb4f901b7fee6b127ee053ab25667a238f8eee6706792334578e23258b0

See more details on using hashes here.

File details

Details for the file dash_down-0.0.13rc7-py3-none-any.whl.

File metadata

  • Download URL: dash_down-0.0.13rc7-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.1 Darwin/21.3.0

File hashes

Hashes for dash_down-0.0.13rc7-py3-none-any.whl
Algorithm Hash digest
SHA256 c1c7a8b5bf50623d48326c6e491e300aafe38707b582e7c273f57f7d781e1015
MD5 8ac12466fbf88f40fd5a4362ee9fa81d
BLAKE2b-256 a3f7ba341d09a668bb294785a23c1565e2beb54be9f6c8cbd0104ced36a89b9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page