Skip to content

Commit 1087834

Browse files
committed
Add tutorials documentation into @webdoc/cli's README
1 parent 546b754 commit 1087834

File tree

1 file changed

+122
-15
lines changed

1 file changed

+122
-15
lines changed

packages/webdoc-cli/README.md

Lines changed: 122 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ npm install --save-dev @webdoc/cli
1818
generate the `sitemap.xml`. This is useful if you want to integrate with [Algolia and use its crawler](https://www.algolia.com/products/crawler/). You must include the protocol for this to work currently, e.g. `http://pixijs.webdoclabs.com`.
1919
* `--site-root <path>`: If using absolute links in a template, this will set the basepath. The basepath should the directory in which the documentation is being stored relative to where the server is running. The site root is "/" by default - which means that you'll need to serve the documentation directory as top-level. Note that @webdoc/default-template uses absolute links.
2020
* `-c <config-path>`: This sets the path of the configuration file webdoc uses.
21+
* `-u <tutorials-directory>` - (optional) This should point to a directory containing tutorials written in Markdown (".md") or HTML ".html, ".htm". JSON files can be used to configure the hierarchy and naming of tutorials (see the Tutorial Configuration section).
2122

2223
### Configuration
2324

@@ -90,21 +91,23 @@ The `template` object is used by the site template.
9091

9192
```json
9293
{
93-
"applicationName": "{ <i>webdoc</i> }",
94-
"meta": {
95-
"og:title": "webdoc",
96-
"og:description": "webdoc API documentation",
97-
"og:image": "https://camo.githubusercontent.com/1427d2fdabd8790c93ca05cbfb653e2c6a8ab5694e671a04aa3af3fcef313539/68747470733a2f2f692e6962622e636f2f5a4850395044382f4c6f676f2d4672616d652d352e706e67",
98-
"og:url": "{{url}}",
99-
"og:site_name": "webdoclabs.com"
100-
},
101-
"repository": "http://github.com/webdoc-labs/webdoc",
102-
"integrations": {
103-
"search": {
104-
"provider": "algolia",
105-
"apiKey": "kadlfj232983lkqwem",
106-
"indexName": "webdoc-example",
107-
"appId": "349o39841;akdsfu"
94+
"template": {
95+
"applicationName": "{ <i>webdoc</i> }",
96+
"meta": {
97+
"og:title": "webdoc",
98+
"og:description": "webdoc API documentation",
99+
"og:image": "https://camo.githubusercontent.com/1427d2fdabd8790c93ca05cbfb653e2c6a8ab5694e671a04aa3af3fcef313539/68747470733a2f2f692e6962622e636f2f5a4850395044382f4c6f676f2d4672616d652d352e706e67",
100+
"og:url": "{{url}}",
101+
"og:site_name": "webdoclabs.com"
102+
},
103+
"repository": "http://github.com/webdoc-labs/webdoc",
104+
"integrations": {
105+
"search": {
106+
"provider": "algolia",
107+
"apiKey": "kadlfj232983lkqwem",
108+
"indexName": "webdoc-example",
109+
"appId": "349o39841;akdsfu"
110+
}
108111
}
109112
}
110113
}
@@ -117,3 +120,107 @@ The `template` object is used by the site template.
117120
* `template.integrations`: (optional) Integrations with 3rd party solutions in your template. This object is dependent on which template you're using. For @webdoc/default-template, the following integrations are available:
118121
* `search`: This is used as the backend for the global site search. You'll need to create an Algolia account yourself and provide
119122
the `apiKey`, `appId`, `indexName`. (The only supported provider is "algolia" right now)
123+
124+
### Tutorial configuration
125+
126+
Tutorials can be structured in a hierarchy using JSON files in the tutorials directory. If you have multiple JSON configuration, they
127+
are deep-merged before being processed.
128+
129+
#### Per-tutorial configuration
130+
131+
Tutorials are referenced using their file name - so make sure all file names in the tutorial directory are unique. To configure a specific
132+
tutorial file, any configuration should reference it by the file name (excluding the extension). For example, to configure "hello-world.md":
133+
134+
```json
135+
{
136+
"hello-world": {
137+
"title": "Hello world! by webdoc"
138+
}
139+
}
140+
```
141+
142+
* `title` - This is what the navigation sidebar will list the tutorial as.
143+
144+
#### Defining a hierarchy
145+
146+
You can also define children in tutorial configurators inline:
147+
148+
```json
149+
{
150+
"hello-world": {
151+
"title": "Hello world! by webdoc",
152+
"children": {
153+
"chapter-1": {
154+
"title": "Chapter 1"
155+
},
156+
"chapter-2": {
157+
"title": "Chapter 2"
158+
}
159+
}
160+
},
161+
"next-steps": {
162+
"title": "Next-steps"
163+
}
164+
}
165+
```
166+
167+
In this configuration, "Chapter 1" and "Chapter 2" will be items under the "Hello world!" category.
168+
169+
#### Referencing other tutorials
170+
171+
Instead of defining tutorials inline in the `children` object, you can add them to the root and then reference
172+
them by name in a `children` array.
173+
174+
```json
175+
{
176+
"hello-world": {
177+
"title": "Hello world! by webdoc",
178+
"children": [
179+
"chapter-1",
180+
"chapter-2"
181+
]
182+
},
183+
"chapter-1": {
184+
"title": "Chapter 1"
185+
},
186+
"chapter-2": {
187+
"title": "Chapter 2"
188+
},
189+
"next-steps": {
190+
"title": "Next-steps"
191+
}
192+
}
193+
```
194+
195+
The above configuration is equivalent to the one defining "Chapter 1" and "Chapter 2" children inline "Hello world!". This way,
196+
you can also split the configuration into multiple files:
197+
198+
**main.json**
199+
200+
```json
201+
{
202+
"hello-world": {
203+
"title": "Hello world! by webdoc",
204+
"children": [
205+
"chapter-1",
206+
"chapter-2"
207+
]
208+
},
209+
"next-steps": {
210+
"title": "Next-steps"
211+
}
212+
}
213+
```
214+
215+
**chapters.json**
216+
217+
```json
218+
{
219+
"chapter-1": {
220+
"title": "Chapter 1"
221+
},
222+
"chapter-2": {
223+
"title": "Chapter 2"
224+
}
225+
}
226+
```

0 commit comments

Comments
 (0)