Skip to content

Commit 68bec5f

Browse files
authored
Merge pull request #44 from jbampton/lint-markdown
Add a GitHub action to lint the Markdown.
2 parents fc8197f + a5070b8 commit 68bec5f

File tree

5 files changed

+68
-18
lines changed

5 files changed

+68
-18
lines changed

.github/workflows/lint.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Lint Markdown
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-18.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Use Node.js
11+
uses: actions/setup-node@v1
12+
with:
13+
node-version: '12.x'
14+
- run: npm install -g [email protected]
15+
- run: markdownlint '**/*.md' --ignore node_modules

.markdownlint.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# MD001 Header levels should only increment by one level at a time
2+
MD001: false
3+
4+
# MD013 Line length
5+
MD013: false
6+
7+
# MD022 Headers should be surrounded by blank lines
8+
MD022: false
9+
10+
# MD026 Trailing punctuation in header
11+
MD026: false
12+
13+
# MD032 Lists should be surrounded by blank lines
14+
MD032: false

CHANGELOG.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Change Log for Dash for Julia
22
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
33

4-
5-
6-
### [UNRELEASED]
4+
## [UNRELEASED]
75
### Added
86
- Support for client side callbacks [#30](https://github.com/plotly/Dash.jl/pull/30)
97
- Support for hot reloading on application or asset changes [#25](https://github.com/plotly/Dash.jl/pull/25)

README.md

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Dash for Julia
1+
# Dash for Julia
22

33
#### Create beautiful, analytic applications in Julia.
44

@@ -36,7 +36,7 @@ julia> using DashHtmlComponents
3636
julia> using DashCoreComponents
3737
3838
julia> app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])
39-
39+
4040
julia> app.layout = html_div() do
4141
html_h1("Hello Dash"),
4242
html_div("Dash.jl: Julia interface for Dash"),
@@ -56,18 +56,18 @@ julia> run_server(app, "0.0.0.0", 8080)
5656
```
5757

5858
* The `DashApp` struct represents a dashboard application.
59-
* To make `DashApp` struct use `dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")`` where `layout_maker` is a function with signature ()::Component
59+
* To make `DashApp` struct use `dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")` where `layout_maker` is a function with signature ()::Component
6060
* Unlike the Python version where each Dash component is represented as a separate class, all components in Dash.jl are represented by struct `Component`.
6161
* You can create `Component` specific for concrete Dash component by the set of functions in the form ``lowercase(<component package>)_lowercase(<component name>)``. For example, in Python html `<div>` element is represented as `HTML.Div` in Dashboards it is created using function `html_div`
6262
* The list of all supported components is available in docstring for Dashboards module.
6363
* All functions for a component creation have the signature `(;kwargs...)::Component`. List of key arguments specific for the concrete component is available in the docstring for each function.
6464
* Functions for creation components which have `children` property have two additional methods ``(children::Any; kwargs...)::Component`` and ``(children_maker::Function; kwargs..)::Component``. `children` must by string or number or single component or collection of components.
6565
* ``make_handler(app::Dash; debug::Bool = false)`` makes a handler function for using in HTTP package.
6666

67-
6867
__Once you have run the code to create the Dashboard, go to `http://127.0.0.1:8080` in your browser to view the Dashboard!__
6968

7069
### Basic Callback
70+
7171
```jldoctest
7272
7373
julia> using Dash
@@ -78,7 +78,7 @@ julia> app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwg
7878
7979
julia> app.layout = html_div() do
8080
dcc_input(id = "my-id", value="initial value", type = "text"),
81-
html_div(id = "my-div")
81+
html_div(id = "my-div")
8282
end
8383
8484
julia> callback!(app, Output("my-div", "children"), Input("my-id", "value")) do input_value
@@ -87,22 +87,24 @@ end
8787
8888
julia> run_server(app, "0.0.0.0", 8080)
8989
```
90+
9091
* You can make your dashboard interactive by register callbacks for changes in frontend with function ``callback!(func::Function, app::Dash, output, input, state)``
9192
* Inputs and outputs (and states, see below) of callback can be `Input`, `Output`, `State` objects or vectors of this objects
9293
* Callback function must have the signature(inputs..., states...), and provide a return value comparable (in terms of number of elements) to the outputs being updated.
9394

9495
### States and Multiple Outputs
96+
9597
```jldoctest
9698
julia> using Dash
9799
julia> using DashHtmlComponents
98100
julia> using DashCoreComponents
99101
100102
julia> app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])
101-
103+
102104
julia> app.layout = html_div() do
103105
dcc_input(id = "my-id", value="initial value", type = "text"),
104106
html_div(id = "my-div"),
105-
html_div(id = "my-div2")
107+
html_div(id = "my-div2")
106108
end
107109
108110
julia> callback!(app, [Output("my-div"."children"), Output("my-div2"."children")], Input("my-id", "value"), State("my-id", "type")) do input_value, state_value
@@ -131,25 +133,30 @@ html_div(id="outer-div") do
131133
end
132134
end
133135
```
136+
134137
### application and layout:
135138

136139
* python:
140+
137141
```python
138142
app = dash.Dash("Test", external_stylesheets=external_stylesheets)
139143
app.layout = html.Div(children=[....])
140144
```
141145

142146
* Dash.jl:
147+
143148
```julia
144-
app = dash("Test", external_stylesheets=external_stylesheets)
149+
app = dash("Test", external_stylesheets=external_stylesheets)
145150

146151
app.layout = html_div() do
147152
......
148153
end
149-
150154
```
155+
151156
### callbacks:
157+
152158
* Python:
159+
153160
```python
154161
@app.callback(Output('output', 'children'),
155162
[Input('submit-button', 'n_clicks')],
@@ -159,7 +166,9 @@ def update_output(n_clicks, state1, state2):
159166
.....
160167

161168
```
169+
162170
* Dash.jl:
171+
163172
```julia
164173
callback!(app, Output("output", "children"),
165174
[Input("submit-button", "n_clicks")],
@@ -168,9 +177,11 @@ callback!(app, Output("output", "children"),
168177
.....
169178
end
170179
```
180+
171181
Be careful - in Dash.jl states come first in an arguments list.
172182

173183
### JSON:
174-
I use JSON2.jl for JSON serialization/deserialization, so in callbacks all JSON objects are `NamedTuples` rather than dictionaries. Within component properties you can use both `Dict` and `NamedTuple` for JSON objects.
184+
185+
I use JSON2.jl for JSON serialization/deserialization, so in callbacks all JSON objects are `NamedTuples` rather than dictionaries. Within component properties you can use both `Dict` and `NamedTuple` for JSON objects.
175186

176187
Note when declaring elements with a single properly that `layout = (title = "Test graph")` is not interpreted as a `NamedTuple` by Julia - you'll need to add a comma when declaring the layout, e.g. `layout = (title = "Test graph",)`

docs/src/index.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Julia backend for [Plotly Dash](https://github.com/plotly/dash)
88
* [dash-bootstrap-components](https://github.com/facultyai/dash-bootstrap-components) added with prefix dbc. Examples of use will be soon
99
* pass_changed_props argument added to [`callback!`](@ref) function. For details see docs of [`callback!`](@ref)
1010

11-
1211
## Version 0.2.5 released
1312

1413
* Now you can use `PlotlyBase.Plot` to work with the `figure` property of the `dcc_graph` component. Examples are: [Plot usage in layout](https://github.com/waralex/DashboardsExamples/blob/master/dash_tutorial/2_dash_layout_4.jl), [Plot usage in callback](https://github.com/waralex/DashboardsExamples/blob/master/dash_tutorial/3_basic_dash_callbacks_2.jl)
@@ -52,6 +51,7 @@ end
5251
julia> handler = make_handler(app, debug = true)
5352
julia> HTTP.serve(handler, HTTP.Sockets.localhost, 8080)
5453
```
54+
5555
* The `Dash` struct represent dashboard application.
5656
* The constructor for `Dash` struct is ``Dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")`` where `layout_maker` is a function with signature ()::Component
5757
* Unlike the python version where each Dash component is represented as a separate class, all components in Dashboard are represented by struct `Component`.
@@ -61,17 +61,17 @@ julia> HTTP.serve(handler, HTTP.Sockets.localhost, 8080)
6161
* Functions for creation components which have `children` property have two additional methods ``(children::Any; kwargs...)::Component`` and ``(children_maker::Function; kwargs..)::Component``. `children` must by string or number or single component or collection of components
6262
* ``make_handler(app::Dash; debug::Bool = false)`` makes handler function for using in HTTP package
6363

64-
6564
__Once you have run the code to create the Dashboard, go to `http://127.0.0.1:8080` in your browser to view the Dashboard!__
6665

6766
### Basic Callback
67+
6868
```jldoctest
6969
julia> import HTTP
7070
julia> using Dashboards
7171
julia> app = Dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]) do
7272
html_div() do
7373
dcc_input(id = "my-id", value="initial value", type = "text"),
74-
html_div(id = "my-div")
74+
html_div(id = "my-div")
7575
end
7676
end
7777
julia> callback!(app, callid"my-id.value => my-div.children") do input_value
@@ -80,20 +80,22 @@ end
8080
julia> handler = make_handler(app, debug = true)
8181
julia> HTTP.serve(handler, HTTP.Sockets.localhost, 8080)
8282
```
83+
8384
* You can make your dashboard interactive by register callbacks for changes in frontend with function ``callback!(func::Function, app::Dash, id::CallbackId)``
8485
* Inputs and outputs (and states, see below) of callback are described by struct `CallbackId` which can easily created by string macro `callid""`
8586
* `callid""` parse string in form ``"[{state1 [,...]}] input1[,...] => output1[,...]"`` where all items is ``"<element id>.<property name>"``
8687
* Callback function must have the signature(states..., inputs...) and return data for output
8788

8889
### States and Multiple Outputs
90+
8991
```jldoctest
9092
julia> import HTTP
9193
julia> using Dashboards
9294
julia> app = Dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]) do
9395
html_div() do
9496
dcc_input(id = "my-id", value="initial value", type = "text"),
9597
html_div(id = "my-div"),
96-
html_div(id = "my-div2")
98+
html_div(id = "my-div2")
9799
end
98100
end
99101
julia> callback!(app, callid"{my-id.type} my-id.value => my-div.children, my-div2.children") do state_value, input_value
@@ -103,6 +105,7 @@ end
103105
julia> handler = make_handler(app, debug = true)
104106
julia> HTTP.serve(handler, HTTP.Sockets.localhost, 8080)
105107
```
108+
106109
* For multiple output callback must return any collection with element for each output
107110

108111
## Comparision with original python syntax
@@ -124,42 +127,51 @@ html_div(id="outer-div") do
124127
end
125128
end
126129
```
130+
127131
### application and layout:
128132

129133
* python:
134+
130135
```python
131136
app = dash.Dash("Test", external_stylesheets=external_stylesheets)
132137
app.layout = html.Div(children=[....])
133138
```
134139

135140
* Dashboards:
141+
136142
```julia
137143
app = Dash("Test", external_stylesheets=external_stylesheets) do
138144
html_div() do
139145
......
140146
end
141147
end
142148
```
149+
143150
### callbacks:
151+
144152
* python:
153+
145154
```python
146155
@app.callback(Output('output', 'children'),
147156
[Input('submit-button', 'n_clicks')],
148157
[State('state-1', 'value'),
149158
State('state-2', 'value')])
150159
def update_output(n_clicks, state1, state2):
151160
.....
152-
153161
```
162+
154163
* Dashboards:
164+
155165
```julia
156166
callback!(app, callid"""{state1.value, state2.value}
157167
submit-button.n_clicks
158168
=> output.children""" ) do state1, state2, n_clicks
159169
.....
160170
end
161171
```
172+
162173
Be careful - in Dashboards states came first in arguments list
163174

164175
### json:
176+
165177
I use JSON2 for json serialization/deserialization, so in callbacks all json objects are NamedTuples not Dicts. In component props you can use both Dicts and NamedTuples for json objects. But be careful with single property objects: `layout = (title = "Test graph")` is not interpreted as NamedTuple by Julia - you need add comma at the end `layout = (title = "Test graph",)`

0 commit comments

Comments
 (0)