-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update the docs, change sidebar url property to page/index #13004
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
Changes from 3 commits
7ed4a53
5df2432
cbe76ee
36e3406
edd52ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ title: Static documentation | |
|
||
# {{ page.title}} | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Scaladoc is able to generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/). | ||
Having a combined tool allows to provide interaction between static documentation and API, thus allowing the two to blend naturally. | ||
Scaladoc can generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/). | ||
Having a combined tool allows providing interaction between static documentation and API, thus allowing the two to blend naturally. | ||
|
||
Creating a site is just as simple as in Jekyll. The site root contains the | ||
layout of the site and all files placed there will be either considered static, | ||
the layout of the site and all files placed there will be either considered static, | ||
or processed for template expansion. | ||
|
||
The files that are considered for template expansion must end in `*.{html,md}` | ||
|
@@ -29,26 +29,33 @@ index.html | |
docs/getting-started.html | ||
``` | ||
|
||
Scaladoc can transform both files and directories (to organize your documentation into tree-like structure). By default directories has title based on file name and has empty content. There is an option to include `index.html` or `index.md` (not both) to provide both content and properties like title (see [Properties](#properties)). | ||
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. There is an option to include `index.html` or `index.md` (not both) to provide both content and properties like the title (see [Properties](#properties)). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
## Properties | ||
|
||
Scaladoc uses the [Liquid](https://shopify.github.io/liquid/) templating engine | ||
and provides a number of custom filters and tags specific to Scala | ||
and provides several custom filters and tags specific to Scala | ||
documentation. | ||
|
||
In Scaladoc, all templates can contain YAML front-matter. The front-matter | ||
is parsed and put into the `page` variable available in templates via Liquid. | ||
|
||
Scaladoc uses some predefined properties to controls some aspect of page. | ||
Example front-matter | ||
``` | ||
--- | ||
title: My custom title | ||
--- | ||
``` | ||
|
||
Scaladoc uses some predefined properties to controls some aspects of page. | ||
|
||
Predefined properties: | ||
|
||
- **title** provide page title that will be used in navigation and html metadata. | ||
- **extraCss** additional `.css` files that will be included in this page. Paths should be relative to documentation root. **This setting is not exported to template engine.** | ||
- **extraJs** additional `.js` files that will be included in this page. Paths should be relative to documentation root. **This setting is not exported to template engine.** | ||
- **hasFrame** when set to `false` page will not include default layout (navigation, breadcrumbs etc.) but only token html wrapper to provide metadata and resources (js and css files). **This setting is not exported to template engine.** | ||
- **layout** - predefined layout to use, see below. **This setting is not exported to template engine.** | ||
- **title** provide page title that will be used in navigation and HTML metadata. | ||
- **extraCss** additional `.css` files that will be included in this page. Paths should be relative to the documentation root. **This setting is not exported to the template engine.** | ||
- **extraJs** additional `.js` files that will be included in this page. Paths should be relative to the documentation root. **This setting is not exported to the template engine.** | ||
- **hasFrame** when set to `false` page will not include default layout (navigation, breadcrumbs, etc.) but only token HTML wrapper to provide metadata and resources (js and css files). **This setting is not exported to the template engine.** | ||
- **layout** - predefined layout to use, see below. **This setting is not exported to the template engine.** | ||
|
||
|
||
## Using existing Templates and Layouts | ||
|
@@ -99,23 +106,44 @@ Scaladoc by default uses layout of files in `docs` directory to create table of | |
```yaml | ||
sidebar: | ||
- title: Blog | ||
- title: Docs | ||
url: docs/index.html | ||
- title: Usage | ||
- title: My title | ||
page: my-page1.md | ||
- page: my-page2.md | ||
- page: my-page3/subsection | ||
- title: Reference | ||
subsection: | ||
- title: Dottydoc | ||
url: docs/usage/dottydoc.html | ||
- title: sbt-projects | ||
url: docs/usage/sbt-projects.html | ||
- page: my-page3.md | ||
- index: my-page4/index.md | ||
subsection: | ||
- page: my-page4/my-page4.md | ||
- title: My subsection | ||
index: my-page5/index.md | ||
subsection: | ||
- page: my-page5/my-page5.md | ||
- index: my-page6/index.md | ||
subsection: | ||
- index: my-page6/my-page6/index.md | ||
subsection: | ||
- page: my-page6/my-page6/my-page6.md | ||
``` | ||
|
||
The `sidebar` key is mandatory, as well as `title` for each element. The | ||
default table of contents allows you to have subsections - albeit the current | ||
depth limit is 2 however it accepts both files and directories and latter can be used to provide deeper structures. | ||
The `sidebar` key is mandatory. | ||
On each level, you can have three different types of entries: `page`, `blog` or `subsection`. | ||
|
||
`Page` is a leaf of the structure and accepts the following attributes: | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- `title` (optional) - title of the page | ||
- `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. | ||
|
||
The `page` property | ||
|
||
The items must provide either `subsection` or `url` but not both at once! | ||
The only exception is `Blog` which is only a `title` and behaves differently. | ||
You can read more about blog [here](blog.md). | ||
`Subsection` accepts nested nodes, these can be either pages or subsections, which allow you to create tree-like navigation. The attributes are: | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- `title` (optional) - title of the page | ||
- `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 | ||
- `subsection` (mandatory) - nested nodes, can be either pages or subsections | ||
|
||
The `Subsection` can omit `title` or `index`, however not specifying any of these properties disables you from giving the title of the section. | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The `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](blog.md). | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` | ||
├── blog | ||
|
@@ -126,10 +154,29 @@ You can read more about blog [here](blog.md). | |
└── sidebar.yml | ||
``` | ||
|
||
## Hierarchy of title | ||
|
||
There is a possibility to give the custom title using `sidebar.yml`. The default strategy when choosing the title for: | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Page | ||
|
||
1. `title` from the `front-matter` of the markdown/html file | ||
2. `title` property from the `sidebar.yml` property | ||
3. filename | ||
|
||
#### Subsection | ||
|
||
1. `title` from the `front-matter` of the markdown/html index file | ||
2. `title` property from the `sidebar.yml` property | ||
3. filename | ||
|
||
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. | ||
|
||
|
||
## Static resources | ||
|
||
You can attach static resources (pdf, images) to your documentation by using two dedicated directories: | ||
`resources` and `images`. When you upload your assests under any of these directories you can reference them in markdown | ||
`resources` and `images`. When you upload your assets under any of these directories you can reference them in markdown | ||
BarkingBad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
as if they were relatively at the same level. | ||
|
||
For example, consider the following situation: | ||
|
@@ -151,5 +198,5 @@ For example, consider the following situation: | |
You can refer to the assets from within any of the files using markdown links: | ||
|
||
``` | ||
This is my blogpost. Here is the image  and here is my [pdf](my_file.pdf) | ||
This is my blog post. Here is the image  and here is my [pdf](my_file.pdf) | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.