@@ -6,116 +6,124 @@ This section describes how you can set up your demos easily in _five lines of co
6
6
7
7
The rules of demo management are super simple:
8
8
9
- * you need one demo page to hold all the demo files
10
- * a demo page has several demo sections
9
+ * you need one demo page (folder) to hold all the demo files
10
+ * a demo page has several demo sections (subfolders)
11
11
* a demo section either
12
12
* has other demo sections as nested subsections, or,
13
- * has the demo files
13
+ * has the demo files ( ` .md ` , ` .jl ` )
14
14
15
15
In the following example:
16
16
17
- * we have one demo page: "quickstart" ---> The current page you're looking at
18
- * "quickstart" has one demo section: "usage example"
19
- * "usage example" has two demo subsections: "basics" and "julia_demos"
20
- * "basics" section holds all markdown demos
21
- * "julia_demos" section holds all julia demos
22
- * "assets" folders are ignored by ` DemoCards.jl `
23
- * "index.md" is where all demo cards are organized in (aka page template)
24
- * "config.json" are configuration files (there're many)
17
+ * we have one demo page: ` "quickstart" ` ---> The current page you're looking at
18
+ * ` "quickstart" ` has one demo section: ` "usage example" `
19
+ * ` "usage example" ` has two demo subsections: ` "basics" ` and ` "julia_demos" `
20
+ * ` "basics" ` section holds all markdown demos
21
+ * ` "julia_demos" ` section holds all julia demos
22
+ * ` "assets" ` folders are ignored by ` DemoCards.jl `
23
+ * ` "index.md" ` is where all demo cards are organized in (aka page template)
24
+ * ` "config.json" ` are configuration files (there are many of them! )
25
25
26
26
``` text
27
27
docs/quickstart
28
+ ├── config.json
28
29
├── index.md
29
30
└── usage_example
30
31
├── basics
31
32
│ ├── assets
32
33
│ ├── config.json
33
34
│ ├── configure_card.md
34
35
│ ├── configure_sec_and_page.md
36
+ │ ├── hidden_card.jl
37
+ │ ├── hide_your_card_from_index.md
35
38
│ └── simple_markdown_demo.md
36
39
├── config.json
37
40
└── julia_demos
38
41
├── 1.julia_demo.jl
39
42
├── 2.cover_on_the_fly.jl
40
- └── assets
43
+ ├── assets
44
+ └── config.json
41
45
```
42
46
43
- ``` @setup simplest_demopage
44
- using DemoCards
45
- using DemoCards: DemoPage
46
- ```
47
-
48
- _ Democards_ can read the demo structure from your folder structure:
47
+ This is the core idea, as long as you organize your folder in a structural way, DemoCards will read
48
+ and process your demos to map your folder structure.
49
49
50
50
``` @repl simplest_demopage
51
- cd("../../../..") do
52
- DemoPage("docs/quickstart")
51
+ using DemoCards
52
+ cd(pkgdir(DemoCards)) do
53
+ DemoCards.DemoPage("docs/quickstart")
53
54
end
54
55
```
55
56
56
57
## Deploy your demo page
57
58
58
- Deployment is also very simple:
59
+ ![ democards workflow] ( assets/democards_workflow.png )
60
+
61
+ The above image is the workflow of ` DemoCards ` . The deployment would be pretty easy:
59
62
60
- 1 . load a theme using ` cardtheme `
61
- 2 . create a demopage using ` makedemos `
62
- 3 . pass the results to ` Documenter.jl `
63
- 4 . postprocess demos generated by Documenter
63
+ 1 . pass your demos to ` makedemos ` , so that they're preprocessed before passing into ` Documenter.jl `
64
+ 2 . generate the entire documentation using ` Documenter.makedocs `
65
+ 3 . post process the generated demos using callbacks.
64
66
65
67
``` julia
66
- # 1. generate a DemoCard theme
67
- templates, theme = cardtheme ( " grid " )
68
+ # 1. generate demo files
69
+ demopage, postprocess_cb, demo_assets = makedemos ( " demos " ) # this is the relative path to docs/
68
70
69
- # 2. generate demo files
70
- demopage, postprocess_cb = makedemos (" demos" , templates) # relative path to docs/
71
+ # if there are generated css assets, pass it to Documenter.HTML
72
+ assets = []
73
+ isnothing (demo_assets) || (push! (assets, demo_assets))
71
74
72
- # 3 . normal Documenter usage
73
- format = Documenter. HTML (assets = [theme, ] )
75
+ # 2 . normal Documenter usage
76
+ format = Documenter. HTML (assets = assets )
74
77
makedocs (format = format,
75
78
pages = [
76
79
" Home" => " index.md" ,
77
80
demopage,
78
81
],
79
82
sitename = " Awesome demos" )
80
83
81
- # 4 . postprocess after makedocs
84
+ # 3 . postprocess after makedocs
82
85
postprocess_cb ()
83
86
```
84
87
88
+ In this example, there are three returned objects from ` makedemos ` :
89
+
90
+ * ` demopage ` : this is the relative path to the generated demos (typically in ` src/democards ` ), you
91
+ can pass it to ` makedocs ` 's ` pages ` .
92
+ * ` postprocess_cb ` : this is the callback function that you'll need to call after ` makedocs ` .
93
+ * ` demo_assets ` : if available, it is the path to css file which you could pass to ` Documenter.HTML `
94
+ as style assets. If no theme is configured for your page, it will be `nothing.
85
95
86
96
After it's set up, you can now focus on contributing more demos and leave
87
97
other works to ` DemoCards.jl ` .
88
98
89
- Here's the generated democards! You can read it one by one to get how things are managed in ` DemoCards.jl ` .
99
+ 🎉 The following example grids are generated using ` DemoCards ` ! You can read them one by one for
100
+ advanced configuration helps. Or you could read the [ Concepts] (@ref concepts) page first to get
101
+ better understanding about the DemoCards type system.
90
102
91
103
---
92
104
93
105
{{{democards}}}
94
106
95
107
---
96
108
97
- Actually, this exact page you're reading is generated by ` DemoCards.jl ` , which we call _ the index
98
- page_ of demos. An index page always have cover images, that could sometimes be undesired. In this
99
- case, you could choose to not generate the index page, and use the Documenter's sidebar for
100
- navigation. For example, the "Theme: None" section in "Theme Gallery" is generated by the following
101
- setup:
109
+ The page you are reading right now is the generated index page of demos. An index page always have
110
+ cover images for the demos. An index page is only generated if you configure the ` theme ` option in
111
+ your page config file (e.g., ` docs/quickstart/config.json ` ):
102
112
103
- ``` julia
104
- # 1. generate demo files
105
- # If you don't pass the templates for index page, then it won't be generated
106
- demopage, postprocess_cb = makedemos (" demos" )
113
+ ``` json
114
+ {
115
+ "theme" : " grid"
116
+ }
117
+ ```
107
118
108
- # 2. normal Documenter usage
109
- makedocs (format = Documenter. HTML (),
110
- pages = [
111
- " Home" => " index.md" ,
112
- demopage,
113
- ],
114
- sitename = " Awesome demos" )
119
+ There are three themes available now:
115
120
116
- # 3. postprocess after makedocs
117
- postprocess_cb ()
118
- ```
121
+ * ` "nothing" ` (default): index page and associated assets will not be generated, instead, it will use
122
+ the sidebar generated by Documenter.jl to navigate through pages. This is the default option when
123
+ you doesn't configure ` "theme" ` .
124
+ * ` "grid" ` and ` "list" ` : an index page and associated cover images are generated
125
+
126
+ Please check the "Theme Gallery" part for a preview of these themes.
119
127
120
128
## What DemoCards.jl does
121
129
@@ -124,8 +132,9 @@ The pipeline of [`makedemos`](@ref DemoCards.makedemos) is:
124
132
1 . analyze the structure of your demo folder and extracts supplementary configuration information
125
133
2 . copy "` assets ` " folder without processing
126
134
3 . preprocess demo files and save it
127
- 4 . process and save cover images
128
- 5 . generate a postprocessing callback function
135
+ 4 . (optional) process and save cover images
136
+ 5 . (optional) generate index page
137
+ 6 . generate a postprocessing callback function
129
138
130
139
Since all files are generated to ` docs/src ` , the next step is to leave everything else
131
140
to ` Documenter.jl ` 💯
@@ -140,9 +149,8 @@ to `Documenter.jl` 💯
140
149
For advanced usage of ` DemoCards.jl ` , you need to understand the core [ concepts] (@ref concepts) of it.
141
150
142
151
!!! warning
143
-
144
152
Currently, there's no guarantee that this function works for untypical
145
- documentation folder structure. By the name **typical**, it is:
153
+ documentation folder structure. By the word ** typical** , it is:
146
154
147
155
```julia
148
156
.
0 commit comments