Skip to content

Commit 42f8464

Browse files
committed
Add auto generation for html components
1 parent 83d31db commit 42f8464

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+10631
-39
lines changed

Diff for: src/Dash.NET/Dash.NET.fsproj

+136-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,143 @@
77
<ItemGroup>
88
<Compile Include="HTMLComponents.fs" />
99
<Compile Include="CoreComponents.fs" />
10+
<None Include="DashComponents\htmlComponentBackbone.template" />
11+
<None Include="DashComponents\componentBackbone.template" />
12+
<None Include="DashComponents\Readme.md" />
13+
<None Include="DashComponents\BackboneGenerator.fsx" />
1014
<Compile Include="DashComponents\ComponentBase.fs" />
15+
<None Include="DashComponents\HTMLComponents\Readme.md" />
16+
<Compile Include="DashComponents\HTMLComponents\RawString.fs" />
17+
<Compile Include="DashComponents\HTMLComponents\A.fs" />
18+
<Compile Include="DashComponents\HTMLComponents\Abbr.fs" />
19+
<Compile Include="DashComponents\HTMLComponents\Acronym.fs" />
20+
<Compile Include="DashComponents\HTMLComponents\Address.fs" />
21+
<Compile Include="DashComponents\HTMLComponents\Area.fs" />
22+
<Compile Include="DashComponents\HTMLComponents\Article.fs" />
23+
<Compile Include="DashComponents\HTMLComponents\Aside.fs" />
24+
<Compile Include="DashComponents\HTMLComponents\Audio.fs" />
25+
<Compile Include="DashComponents\HTMLComponents\B.fs" />
26+
<Compile Include="DashComponents\HTMLComponents\Base.fs" />
27+
<Compile Include="DashComponents\HTMLComponents\Basefont.fs" />
28+
<Compile Include="DashComponents\HTMLComponents\Bdi.fs" />
29+
<Compile Include="DashComponents\HTMLComponents\Bdo.fs" />
30+
<Compile Include="DashComponents\HTMLComponents\Big.fs" />
31+
<Compile Include="DashComponents\HTMLComponents\Blink.fs" />
32+
<Compile Include="DashComponents\HTMLComponents\Blockquote.fs" />
33+
<Compile Include="DashComponents\HTMLComponents\Br.fs" />
34+
<Compile Include="DashComponents\HTMLComponents\Button.fs" />
35+
<Compile Include="DashComponents\HTMLComponents\Canvas.fs" />
36+
<Compile Include="DashComponents\HTMLComponents\Caption.fs" />
37+
<Compile Include="DashComponents\HTMLComponents\Center.fs" />
38+
<Compile Include="DashComponents\HTMLComponents\Cite.fs" />
39+
<Compile Include="DashComponents\HTMLComponents\Code.fs" />
40+
<Compile Include="DashComponents\HTMLComponents\Col.fs" />
41+
<Compile Include="DashComponents\HTMLComponents\Colgroup.fs" />
42+
<Compile Include="DashComponents\HTMLComponents\Command.fs" />
43+
<Compile Include="DashComponents\HTMLComponents\Content.fs" />
44+
<Compile Include="DashComponents\HTMLComponents\Data.fs" />
45+
<Compile Include="DashComponents\HTMLComponents\Datalist.fs" />
46+
<Compile Include="DashComponents\HTMLComponents\Dd.fs" />
47+
<Compile Include="DashComponents\HTMLComponents\Del.fs" />
48+
<Compile Include="DashComponents\HTMLComponents\Details.fs" />
49+
<Compile Include="DashComponents\HTMLComponents\Dfn.fs" />
50+
<Compile Include="DashComponents\HTMLComponents\Dialog.fs" />
51+
<Compile Include="DashComponents\HTMLComponents\Dl.fs" />
52+
<Compile Include="DashComponents\HTMLComponents\Dt.fs" />
53+
<Compile Include="DashComponents\HTMLComponents\Element.fs" />
54+
<Compile Include="DashComponents\HTMLComponents\Em.fs" />
55+
<Compile Include="DashComponents\HTMLComponents\Embed.fs" />
56+
<Compile Include="DashComponents\HTMLComponents\Fieldset.fs" />
57+
<Compile Include="DashComponents\HTMLComponents\Figcaption.fs" />
58+
<Compile Include="DashComponents\HTMLComponents\Figure.fs" />
59+
<Compile Include="DashComponents\HTMLComponents\Font.fs" />
60+
<Compile Include="DashComponents\HTMLComponents\Footer.fs" />
61+
<Compile Include="DashComponents\HTMLComponents\Form.fs" />
62+
<Compile Include="DashComponents\HTMLComponents\Frame.fs" />
63+
<Compile Include="DashComponents\HTMLComponents\Frameset.fs" />
64+
<Compile Include="DashComponents\HTMLComponents\H1.fs" />
65+
<Compile Include="DashComponents\HTMLComponents\H2.fs" />
66+
<Compile Include="DashComponents\HTMLComponents\H3.fs" />
67+
<Compile Include="DashComponents\HTMLComponents\H4.fs" />
68+
<Compile Include="DashComponents\HTMLComponents\H5.fs" />
69+
<Compile Include="DashComponents\HTMLComponents\H6.fs" />
70+
<Compile Include="DashComponents\HTMLComponents\Header.fs" />
71+
<Compile Include="DashComponents\HTMLComponents\Hgroup.fs" />
72+
<Compile Include="DashComponents\HTMLComponents\Hr.fs" />
73+
<Compile Include="DashComponents\HTMLComponents\I.fs" />
74+
<Compile Include="DashComponents\HTMLComponents\Iframe.fs" />
75+
<Compile Include="DashComponents\HTMLComponents\Img.fs" />
76+
<Compile Include="DashComponents\HTMLComponents\Ins.fs" />
77+
<Compile Include="DashComponents\HTMLComponents\Isindex.fs" />
78+
<Compile Include="DashComponents\HTMLComponents\Kbd.fs" />
79+
<Compile Include="DashComponents\HTMLComponents\Keygen.fs" />
80+
<Compile Include="DashComponents\HTMLComponents\Label.fs" />
81+
<Compile Include="DashComponents\HTMLComponents\Legend.fs" />
82+
<Compile Include="DashComponents\HTMLComponents\Li.fs" />
83+
<Compile Include="DashComponents\HTMLComponents\Link.fs" />
84+
<Compile Include="DashComponents\HTMLComponents\Listing.fs" />
85+
<Compile Include="DashComponents\HTMLComponents\Main.fs" />
86+
<Compile Include="DashComponents\HTMLComponents\MapEl.fs" />
87+
<Compile Include="DashComponents\HTMLComponents\Mark.fs" />
88+
<Compile Include="DashComponents\HTMLComponents\Marquee.fs" />
89+
<Compile Include="DashComponents\HTMLComponents\Meta.fs" />
90+
<Compile Include="DashComponents\HTMLComponents\Meter.fs" />
91+
<Compile Include="DashComponents\HTMLComponents\Multicol.fs" />
92+
<Compile Include="DashComponents\HTMLComponents\Nav.fs" />
93+
<Compile Include="DashComponents\HTMLComponents\Nextid.fs" />
94+
<Compile Include="DashComponents\HTMLComponents\Nobr.fs" />
95+
<Compile Include="DashComponents\HTMLComponents\Noscript.fs" />
96+
<Compile Include="DashComponents\HTMLComponents\ObjectEl.fs" />
97+
<Compile Include="DashComponents\HTMLComponents\Ol.fs" />
98+
<Compile Include="DashComponents\HTMLComponents\Optgroup.fs" />
99+
<Compile Include="DashComponents\HTMLComponents\Option.fs" />
100+
<Compile Include="DashComponents\HTMLComponents\Output.fs" />
101+
<Compile Include="DashComponents\HTMLComponents\P.fs" />
102+
<Compile Include="DashComponents\HTMLComponents\Param.fs" />
103+
<Compile Include="DashComponents\HTMLComponents\Picture.fs" />
104+
<Compile Include="DashComponents\HTMLComponents\Plaintext.fs" />
105+
<Compile Include="DashComponents\HTMLComponents\Pre.fs" />
106+
<Compile Include="DashComponents\HTMLComponents\Progress.fs" />
107+
<Compile Include="DashComponents\HTMLComponents\Q.fs" />
108+
<Compile Include="DashComponents\HTMLComponents\Rb.fs" />
109+
<Compile Include="DashComponents\HTMLComponents\Rp.fs" />
110+
<Compile Include="DashComponents\HTMLComponents\Rt.fs" />
111+
<Compile Include="DashComponents\HTMLComponents\Rtc.fs" />
112+
<Compile Include="DashComponents\HTMLComponents\Ruby.fs" />
113+
<Compile Include="DashComponents\HTMLComponents\S.fs" />
114+
<Compile Include="DashComponents\HTMLComponents\Samp.fs" />
115+
<Compile Include="DashComponents\HTMLComponents\Script.fs" />
116+
<Compile Include="DashComponents\HTMLComponents\Section.fs" />
117+
<Compile Include="DashComponents\HTMLComponents\Select.fs" />
118+
<Compile Include="DashComponents\HTMLComponents\Shadow.fs" />
119+
<Compile Include="DashComponents\HTMLComponents\Slot.fs" />
120+
<Compile Include="DashComponents\HTMLComponents\Small.fs" />
121+
<Compile Include="DashComponents\HTMLComponents\Source.fs" />
122+
<Compile Include="DashComponents\HTMLComponents\Spacer.fs" />
123+
<Compile Include="DashComponents\HTMLComponents\Span.fs" />
124+
<Compile Include="DashComponents\HTMLComponents\Strike.fs" />
125+
<Compile Include="DashComponents\HTMLComponents\Strong.fs" />
126+
<Compile Include="DashComponents\HTMLComponents\Sub.fs" />
127+
<Compile Include="DashComponents\HTMLComponents\Summary.fs" />
128+
<Compile Include="DashComponents\HTMLComponents\Sup.fs" />
129+
<Compile Include="DashComponents\HTMLComponents\Table.fs" />
130+
<Compile Include="DashComponents\HTMLComponents\Tbody.fs" />
131+
<Compile Include="DashComponents\HTMLComponents\Td.fs" />
132+
<Compile Include="DashComponents\HTMLComponents\Template.fs" />
133+
<Compile Include="DashComponents\HTMLComponents\Textarea.fs" />
134+
<Compile Include="DashComponents\HTMLComponents\Tfoot.fs" />
135+
<Compile Include="DashComponents\HTMLComponents\Th.fs" />
136+
<Compile Include="DashComponents\HTMLComponents\Thead.fs" />
137+
<Compile Include="DashComponents\HTMLComponents\Time.fs" />
138+
<Compile Include="DashComponents\HTMLComponents\Tr.fs" />
139+
<Compile Include="DashComponents\HTMLComponents\Track.fs" />
140+
<Compile Include="DashComponents\HTMLComponents\U.fs" />
141+
<Compile Include="DashComponents\HTMLComponents\Ul.fs" />
142+
<Compile Include="DashComponents\HTMLComponents\Var.fs" />
143+
<Compile Include="DashComponents\HTMLComponents\Video.fs" />
144+
<Compile Include="DashComponents\HTMLComponents\Wbr.fs" />
145+
<Compile Include="DashComponents\HTMLComponents\Xmp.fs" />
146+
<Compile Include="DashComponents\HTMLComponents\Title.fs" />
11147
<Compile Include="DashComponents\HTMLComponents\Div.fs" />
12148
<Compile Include="DashComponents\CoreComponents\Upload.fs" />
13149
<Compile Include="DashComponents\CoreComponents\Graph.fs" />
@@ -17,11 +153,8 @@
17153
<Compile Include="DashConfig.fs" />
18154
<Compile Include="Views.fs" />
19155
<Compile Include="DashApp.fs" />
20-
<None Include="DashComponents\CoreComponents\Readme.md" />
21156
</ItemGroup>
22157

23-
<ItemGroup />
24-
25158
<ItemGroup>
26159
<PackageReference Include="Giraffe" Version="4.1.0" />
27160
<PackageReference Include="Plotly.NET" Version="2.0.0-alpha2" />

Diff for: src/Dash.NET/DashComponents/BackboneGenerator.fsx

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
open System
2+
open System.IO
3+
4+
let htmlBackbone = File.ReadAllText (__SOURCE_DIRECTORY__ + "/htmlComponentBackbone.template")
5+
let componentBackbone = File.ReadAllText (__SOURCE_DIRECTORY__ + "/componentBackbone.template")
6+
7+
module String =
8+
let replace (old:string) (_new:string) (s:string) = s.Replace(old,_new)
9+
let write path (s:string) = File.WriteAllText(path,s)
10+
11+
type ComponentType =
12+
| HTMLComponent
13+
| DashComponent
14+
static member toBackbone = function
15+
| HTMLComponent -> htmlBackbone
16+
| DashComponent -> componentBackbone
17+
18+
type ComponentParameters =
19+
{
20+
Type: ComponentType
21+
ComponentName: string
22+
CamelCaseComponentName: string
23+
ComponentChar: string
24+
ComponentNamespace: string
25+
ComponentType: string
26+
LibraryNamespace: string
27+
}
28+
static member create (_type:ComponentType) (componentName:string) (componentNameSpace:string) (componentType:string) (libraryNameSpace:string) =
29+
{
30+
Type=_type
31+
ComponentName = componentName
32+
CamelCaseComponentName = sprintf "%c%s" (Char.ToLowerInvariant(componentName.[0])) (componentName.Substring(1))
33+
ComponentChar = (componentName.ToLower().Substring(0,1))
34+
ComponentNamespace = componentNameSpace
35+
ComponentType = componentType
36+
LibraryNamespace = libraryNameSpace
37+
}
38+
39+
40+
let generateComponentTemplateFile path (parameters:ComponentParameters) =
41+
parameters.Type
42+
|> ComponentType.toBackbone
43+
|> String.replace "{ComponentName}" parameters.ComponentName
44+
|> String.replace "{camelCaseComponentName}" parameters.CamelCaseComponentName
45+
|> String.replace "{ComponentChar}" parameters.ComponentChar
46+
|> String.replace "{ComponentNamespace}" parameters.ComponentNamespace
47+
|> String.replace "{ComponentType}" parameters.ComponentType
48+
|> String.replace "{LibraryNamespace}" parameters.LibraryNamespace
49+
|> String.write path
50+
51+
let htmlComponents =
52+
[
53+
"A"
54+
"Abbr"
55+
"Acronym"
56+
"Address"
57+
"Area"
58+
"Article"
59+
"Aside"
60+
"Audio"
61+
"B"
62+
"Base"
63+
"Basefont"
64+
"Bdi"
65+
"Bdo"
66+
"Big"
67+
"Blink"
68+
"Blockquote"
69+
"Br"
70+
"Button"
71+
"Canvas"
72+
"Caption"
73+
"Center"
74+
"Cite"
75+
"Code"
76+
"Col"
77+
"Colgroup"
78+
"Command"
79+
"Content"
80+
"Data"
81+
"Datalist"
82+
"Dd"
83+
"Del"
84+
"Details"
85+
"Dfn"
86+
"Dialog"
87+
"Div"
88+
"Dl"
89+
"Dt"
90+
"Element"
91+
"Em"
92+
"Embed"
93+
"Fieldset"
94+
"Figcaption"
95+
"Figure"
96+
"Font"
97+
"Footer"
98+
"Form"
99+
"Frame"
100+
"Frameset"
101+
"H1"
102+
"H2"
103+
"H3"
104+
"H4"
105+
"H5"
106+
"H6"
107+
"Header"
108+
"Hgroup"
109+
"Hr"
110+
"I"
111+
"Iframe"
112+
"Img"
113+
"Ins"
114+
"Isindex"
115+
"Kbd"
116+
"Keygen"
117+
"Label"
118+
"Legend"
119+
"Li"
120+
"Link"
121+
"Listing"
122+
"Main"
123+
"MapEl"
124+
"Mark"
125+
"Marquee"
126+
"Meta"
127+
"Meter"
128+
"Multicol"
129+
"Nav"
130+
"Nextid"
131+
"Nobr"
132+
"Noscript"
133+
"ObjectEl"
134+
"Ol"
135+
"Optgroup"
136+
"Option"
137+
"Output"
138+
"P"
139+
"Param"
140+
"Picture"
141+
"Plaintext"
142+
"Pre"
143+
"Progress"
144+
"Q"
145+
"Rb"
146+
"Rp"
147+
"Rt"
148+
"Rtc"
149+
"Ruby"
150+
"S"
151+
"Samp"
152+
"Script"
153+
"Section"
154+
"Select"
155+
"Shadow"
156+
"Slot"
157+
"Small"
158+
"Source"
159+
"Spacer"
160+
"Span"
161+
"Strike"
162+
"Strong"
163+
"Sub"
164+
"Summary"
165+
"Sup"
166+
"Table"
167+
"Tbody"
168+
"Td"
169+
"Template"
170+
"Textarea"
171+
"Tfoot"
172+
"Th"
173+
"Thead"
174+
"Time"
175+
"Title"
176+
"Tr"
177+
"Track"
178+
"U"
179+
"Ul"
180+
"Var"
181+
"Video"
182+
"Wbr"
183+
"Xmp"
184+
]
185+
|> List.map (fun cName ->
186+
ComponentParameters.create
187+
ComponentType.HTMLComponent
188+
cName
189+
"dash_html_components"
190+
cName
191+
"Dash.NET.HTML_DSL"
192+
)
193+
194+
htmlComponents
195+
|> List.iter (fun (_component:ComponentParameters) ->
196+
_component |> generateComponentTemplateFile (__SOURCE_DIRECTORY__ + (sprintf "/HTMLComponents/%s.fs" _component.ComponentName))
197+
)

0 commit comments

Comments
 (0)