-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core Components Integration #131
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9fa95aa
resources generator
waralex d2734d7
remove hardcoded resources
waralex f1901eb
remove unused file
waralex 8d7c4cc
preload metadata at compilation time
waralex 387cab3
Merge branch 'dev' into components_integration
waralex 3abfea9
core component integrations
waralex 559bac4
fix
waralex b265a18
change components pkgs versions and resources repo
waralex dbf86ff
typo fixes
waralex 87533d9
remove TestComponents
waralex f59aae9
dev.jl comment
waralex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ Manifest.toml | |
docs/build | ||
venv | ||
*.pyc | ||
tmp | ||
tmp | ||
gen_resources/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[dash_resources] | ||
git-tree-sha1 = "c857e355d2c21dfc458fb315371431dda2506109" | ||
|
||
[[dash_resources.download]] | ||
sha256 = "4ff3910a8ff1f5420784397cfc6ad80341bbe03f1010eab38dcb9b8ce2423310" | ||
url = "https://github.com/waralex/DashCoreResources/releases/download/v2.0.0+0/DashCoreResources.v2.0.0.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[deps] | ||
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d" | ||
GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" | ||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" | ||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" | ||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" | ||
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" | ||
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" | ||
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" | ||
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" | ||
ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[deploy] | ||
repo = "waralex/DashCoreResources" | ||
[dash] | ||
url = "https://github.com/plotly/dash.git" | ||
tag = "v2.0.0" | ||
[dash_renderer] | ||
module = "dash_renderer" | ||
resources_path = "." | ||
[components] | ||
[components.dash_html_components] | ||
module = "dash.html" | ||
prefix = "html" | ||
resources_path = ".." | ||
metadata_file = "metadata.json" | ||
[components.dash_core_components] | ||
module = "dash.dcc" | ||
prefix = "dcc" | ||
resources_path = ".." | ||
metadata_file = "metadata.json" | ||
[components.dash_table] | ||
module = "dash.dash_table" | ||
prefix = "dash" | ||
resources_path = ".." | ||
metadata_file = "metadata.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import TOML | ||
using OrderedCollections | ||
using Conda | ||
using PyCall | ||
import YAML | ||
using Pkg.Artifacts | ||
import GitHub | ||
import GitHub: gh_get_json, DEFAULT_API | ||
using HTTP | ||
import JSON | ||
using ghr_jll | ||
|
||
include("generator/generator.jl") | ||
|
||
sources = TOML.parsefile(joinpath(@__DIR__, "Sources.toml")) | ||
|
||
build_dir = joinpath(@__DIR__, "build") | ||
|
||
artifact_file = joinpath(@__DIR__, "..", "Artifacts.toml") | ||
|
||
generate(ARGS, sources, build_dir, artifact_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
using JSON3 | ||
function process_components_meta(metafile) | ||
metadata = JSON3.read( | ||
read(metafile, String) | ||
) | ||
result = [] | ||
for (file, props) in metadata | ||
name = split(split(string(file), "/")[end], ".")[1] | ||
push!(result, make_component_meta(name, props)) | ||
end | ||
return result | ||
end | ||
|
||
function make_component_meta(name, props) | ||
args = filter(filter_arg, props["props"]) | ||
regular_args = filter(collect(keys(args))) do name | ||
!endswith(string(name), "-*") | ||
end | ||
wild_args = | ||
filter(collect(keys(args))) do name | ||
endswith(string(name), "-*") | ||
end | ||
return OrderedDict( | ||
:name => Symbol(name), | ||
:args => regular_args, | ||
:wild_args => [Symbol(replace(string(a), "-*"=>"")) for a in wild_args], | ||
:docstr => docstring(name, args, props["description"]), | ||
) | ||
end | ||
|
||
|
||
const _reserwed_words = Set( | ||
["baremodule", | ||
"begin", | ||
"break", | ||
"catch", | ||
"const", | ||
"continue", | ||
"do", | ||
"else", | ||
"elseif", | ||
"end", | ||
"export", | ||
"false", | ||
"finally", | ||
"for", | ||
"function", | ||
"global", | ||
"if", | ||
"import", | ||
"let", | ||
"local", | ||
"macro", | ||
"module", | ||
"quote", | ||
"return", | ||
"struct", | ||
"true", | ||
"try", | ||
"using", | ||
"while"] | ||
) | ||
function is_reserved_world(w) | ||
return w in _reserwed_words | ||
end | ||
|
||
function filter_arg(argpair) | ||
name, props = argpair | ||
is_reserved_world(name) && return false | ||
if haskey(props, "type") | ||
arg_type = props["type"]["name"] | ||
return !in(arg_type, ["func", "symbol", "instanceOf"]) | ||
end | ||
if "flowType" in props | ||
arg_type_name = props["flowType"]["name"] | ||
if arg_type_name == "signature" | ||
# This does the same as the PropTypes filter above, but "func" | ||
# is under "type" if "name" is "signature" vs just in "name" | ||
if !in("type", props["FlowType"]) || props["FlowType"]["type"] != "object" | ||
return false | ||
end | ||
end | ||
return true | ||
end | ||
return false | ||
end | ||
|
||
function docstring(name, props, description) | ||
article = lowercase(first(name)) in ['a', 'e', 'i', 'o', 'u'] ? "An " : "A " | ||
result = string( | ||
article, name, " component", "\n", | ||
description, "\n\n" | ||
) | ||
if haskey(props, :children) | ||
result *= arg_docstring("children", props[:children]) * "\n" | ||
end | ||
if haskey(props, :id) | ||
result *= arg_docstring("id", props[:id]) * "\n" | ||
end | ||
other_props = sort( | ||
collect(filter(v->!in(v.first, [:children, :id]), props)), | ||
lt = (a, b) -> a[1] < b[1] | ||
) | ||
result *= join(arg_docstring.(other_props), "\n") | ||
return result | ||
|
||
end | ||
|
||
_jl_type(::Val{:array}, type_object) = "Array" | ||
_jl_type(::Val{:bool}, type_object) = "Bool" | ||
_jl_type(::Val{:string}, type_object) = "String" | ||
_jl_type(::Val{:object}, type_object) = "Dict" | ||
_jl_type(::Val{:any}, type_object) = "Bool | Real | String | Dict | Array" | ||
_jl_type(::Val{:element}, type_object) = "dash component" | ||
_jl_type(::Val{:node}, type_object) = "a list of or a singular dash component, string or number" | ||
|
||
_jl_type(::Val{:enum}, type_object) = join( | ||
string.( | ||
getindex.(type_object["value"], :value) | ||
), ", " | ||
) | ||
|
||
function _jl_type(::Val{:union}, type_object) | ||
join( | ||
filter(a->!isempty(a), jl_type.(type_object["value"])), | ||
" | " | ||
) | ||
end | ||
|
||
function _jl_type(::Val{:arrayOf}, type_object) | ||
result = "Array" | ||
if type_object["value"] != "" | ||
result *= string(" of ", jl_type(type_object["value"]), "s") | ||
end | ||
return result | ||
end | ||
|
||
_jl_type(::Val{:objectOf}, type_object) = | ||
string("Dict with Strings as keys and values of type ", jl_type(type_object["value"])) | ||
|
||
function _jl_type(::Val{:shape}, type_object) | ||
child_names = join(string.(keys(type_object["value"])), ", ") | ||
result = "lists containing elements $(child_names)" | ||
result *= join( | ||
[ | ||
arg_docstring(name, prop, prop["required"], get(prop, "description", ""), 1) | ||
for (name, prop) in type_object["value"] | ||
] | ||
) | ||
return result | ||
end | ||
_jl_type(::Val{:exact}, type_object) = _jl_type(Val(:shape), type_object) | ||
_jl_type(val, type_object) = "" | ||
|
||
|
||
jl_type(type_object) = _jl_type(Val(Symbol(type_object["name"])), type_object) | ||
|
||
arg_docstring(name_prop::Pair, indent_num = 0) = arg_docstring(name_prop[1], name_prop[2], indent_num) | ||
arg_docstring(name, prop, indent_num = 0) = | ||
arg_docstring( | ||
string(name), | ||
haskey(prop, "type") ? prop["type"] : prop["flowType"], | ||
prop["required"], | ||
prop["description"], | ||
indent_num | ||
) | ||
|
||
function arg_docstring(prop_name, type_object, required, description, indent_num) | ||
typename = jl_type(type_object) | ||
indent_spacing = repeat(" ", indent_num) | ||
if occursin("\n", typename) | ||
return string( | ||
indent_spacing, "- `", prop_name, "` ", | ||
"(", required ? "required" : "optional", "):", | ||
description, ". ", | ||
prop_name, " has the following type: ", typename | ||
) | ||
end | ||
|
||
return string( | ||
indent_spacing, "- `", prop_name, "` ", | ||
"(", | ||
isempty(typename) ? "" : string(typename, "; "), | ||
required ? "required" : "optional", | ||
")", | ||
isempty(description) ? "" : string(": ", description) | ||
) | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in dbf86ff