You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _overviews/scala3-scaladoc/static-site.md
+96-77Lines changed: 96 additions & 77 deletions
Original file line number
Diff line number
Diff line change
@@ -20,16 +20,18 @@ and will from here on be referred to as "template files" or "templates".
20
20
A simple "hello world" site could look something like this:
21
21
22
22
```
23
-
├── docs
24
-
│ └── getting-started.md
25
-
└── index.html
23
+
.
24
+
└── <site-root>/
25
+
└── _docs/
26
+
├── index.html
27
+
└── getting-started.html
26
28
```
27
29
28
30
This will give you a site with the following files in generated documentation:
29
31
30
32
```
31
33
index.html
32
-
docs/getting-started.html
34
+
getting-started.html
33
35
```
34
36
35
37
Scaladoc can transform both files and directories (to organize your documentation into a tree-like structure). By default, directories have a title based on the file name and have empty content. It is possible to provide index pages for each section by creating `index.html` or `index.md` (not both) in the dedicated directory.
@@ -98,63 +100,65 @@ Layouts must be placed in a `_layouts` directory in the site root:
98
100
```
99
101
├── _layouts
100
102
│ └── main.html
101
-
├── docs
102
-
│ └── getting-started.md
103
-
└── index.html
103
+
└── _docs
104
+
├── getting-started.md
105
+
└── index.html
106
+
```
107
+
108
+
## Assets
109
+
110
+
In order to render assets along with static site, they need to be placed in the `_assets` directory in the site root:
111
+
```
112
+
├── _assets
113
+
│ └── images
114
+
│ └── myimage.png
115
+
└── _docs
116
+
└── getting-started.md
117
+
```
118
+
To reference the asset on a page, one needs to create a link relative to the `_assets` directory
119
+
120
+
```
121
+
Take a look at the following image: [My image](images/myimage.png)
104
122
```
105
123
106
124
## Sidebar
107
125
108
-
Scaladoc by default uses layout of files in `docs` directory to create table of content. There is also ability to override it by providing a `sidebar.yml` file in the site root:
126
+
By default, Scaladoc reflects the directory structure from `_docs` directory in the rendered site. There is also the ability to override it by providing a `sidebar.yml` file in the site root directory. The YAML configuration file describes the structure of the rendered static site and the table of content:
109
127
110
128
```yaml
111
-
sidebar:
112
-
- title: Blog
113
-
- title: My title
114
-
page: my-page1.md
115
-
- page: my-page2.md
116
-
- page: my-page3/subsection
117
-
- title: Reference
118
-
subsection:
119
-
- page: my-page3.md
120
-
- index: my-page4/index.md
121
-
subsection:
122
-
- page: my-page4/my-page4.md
123
-
- title: My subsection
124
-
index: my-page5/index.md
125
-
subsection:
126
-
- page: my-page5/my-page5.md
127
-
- index: my-page6/index.md
128
-
subsection:
129
-
- index: my-page6/my-page6/index.md
130
-
subsection:
131
-
- page: my-page6/my-page6/my-page6.md
132
-
```
133
-
134
-
The `sidebar` key is mandatory.
135
-
On each level, you can have three different types of entries: `page`, `blog` or `subsection`.
136
-
137
-
`page` is a leaf of the structure and accepts the following attributes:
138
-
- `title`(optional) - title of the page
139
-
- `page`(mandatory) - path to the file that will represent the page, it can be either html or markdown file to be rendered, there is also the possibility to pass the `directory` path. If so, the scaladoc will render the directory and all its content as if there were no `sidebar.yml` basing on its tree structure and index files.
140
-
141
-
The `page` property `subsection` accepts nested nodes, these can be either pages or subsections, which allow you to create tree-like navigation. The attributes are:
142
-
- `title`(optional) - title of the page
143
-
- `index`(optional) - path to the file that will represent the index file of the subsection, it can be either html or markdown file to be rendered
144
-
- `subsection`(mandatory) - nested nodes, can be either pages or subsections
145
-
146
-
In `subsection`s, you can omit `title` or `index`, however not specifying any of these properties prevents you from specifying the title of the section.
147
-
148
-
`blog` is a special node represented by simple entry `- title: Blog` with no other attributes. All your blog posts will be automatically linked under this section. You can read more about the blog [here]({% link _overviews/scala3-scaladoc/blog.md %}).
149
-
150
-
```
151
-
├── blog
152
-
│ ├── _posts
153
-
│ │ └── 2016-12-05-implicit-function-types.md
154
-
│ └── index.html
155
-
├── index.html
156
-
└── sidebar.yml
157
-
```
129
+
index: index.html
130
+
subsection:
131
+
- title: Usage
132
+
index: usage/index.html
133
+
directory: usage
134
+
subsection:
135
+
- title: Dottydoc
136
+
page: usage/dottydoc.html
137
+
hidden: false
138
+
- title: sbt-projects
139
+
page: usage/sbt-projects.html
140
+
hidden: false
141
+
```
142
+
The root element needs to be a `subsection`.
143
+
Nesting subsections will result in a tree-like structure of navigation.
144
+
145
+
`subsection` properties are:
146
+
- `title`- Optional string - A default title of the subsection.
147
+
Front-matter titles have higher priorities.
148
+
- `index`- Optional string - A path to index page of a subsection. The path is relative to the `_docs` directory.
149
+
- `directory`- Optional string - A name of the directory that will contain the subsection in the generated site.
150
+
By default, the directory name is the subsection name converted to kebab case.
151
+
- `subsection`- Array of `subsection` or `page`.
152
+
153
+
Either `index` or `subsection` must be defined. The subsection defined with `index` and without `subsection` will contain pages and directories loaded recursively from the directory of the index page.
154
+
155
+
`page` properties are:
156
+
- `title`- Optional string - A default title of the page.
157
+
Front-matter titles have higher priorities.
158
+
- `page`- String - A path to the page, relative to the `_docs` directory.
159
+
- `hidden`- Optional boolean - A flag that indicates whether the page should be visible in the navigation sidebar. By default, it is set to `false`.
160
+
161
+
**Note**: All the paths in the YAML configuration file are relative to `<static-root>/_docs`.
158
162
159
163
## Hierarchy of title
160
164
@@ -174,30 +178,45 @@ If the title is specified multiple times, the priority is as follows (from highe
174
178
175
179
Note that if you skip the `index` file in your tree structure or you don't specify the `title` in the frontmatter, there will be given a generic name `index`. The same applies when using `sidebar.yml` but not specifying `title` nor `index`, just a subsection. Again, a generic `index` name will appear.
176
180
181
+
## Blog
182
+
Blog feature is described in [a separate document]({% link _overviews/scala3-scaladoc/blog.md %})
177
183
178
-
## Static resources
179
-
180
-
You can attach static resources (pdf, images) to your documentation by using two dedicated directories:
181
-
`resources`and `images`. After placing your assets under any of these directories, you can reference them in markdown
182
-
as if they were relatively at the same level.
183
-
184
-
For example, consider the following situation:
185
-
184
+
## Advanced configuration
185
+
### Full structure of site root
186
186
```
187
-
├── blog
188
-
│ ├── _posts
189
-
│ │ └── 2016-12-05-implicit-function-types.md
190
-
│ └── index.html
191
-
├── index.html
192
-
├── resources
193
-
│ └── my_file.pdf
194
-
├── images
195
-
│ └── my_image.png
196
-
└── sidebar.yml
197
-
187
+
.
188
+
└── <site-root>/
189
+
├── _layouts_/
190
+
│ └── ...
191
+
├── _docs/
192
+
│ └── ...
193
+
├── _blog/
194
+
│ ├── index.md
195
+
│ └── _posts/
196
+
│ └── ...
197
+
└── _assets/
198
+
├── js/
199
+
│ └── ...
200
+
├── img/
201
+
│ └── ...
202
+
└── ...
198
203
```
204
+
It results in a static site containing documents as well as a blog. It also contains custom layouts and assets. The structure of the rendered documentation can be based on the file system but it can also be overridden by YAML configuration.
199
205
200
-
You can refer to the assets from within any of the files using markdown links:
206
+
### Mapping directory structure
201
207
202
-
```
203
-
This is my blog post. Here is the image  and here is my [pdf](my_file.pdf)```
208
+
Using the YAML configuration file, we can define how the source directory structure should be transformed into an outputs directory structure.
209
+
210
+
Take a look at the following subsection definition:
211
+
```yaml
212
+
- title: Some other subsection
213
+
index: abc/index.html
214
+
directory: custom-directory
215
+
subsection:
216
+
- page: abc2/page1.md
217
+
- page: foo/page2.md
218
+
```
219
+
This subsection shows the ability of YAML configuration to map the directory structure.
220
+
Even though the index page and all defined children are in different directories, they will be rendered in `custom-directory`.
221
+
The source page `abc/index.html` will generate a page `custom-directory/index.html`, the source page `abc2/page1.md` will generate a page `custom-directory/page1.html`,
222
+
and the source page `foo/page2.md` will generate a page `custom-directory/page2.html`.
0 commit comments