|
| 1 | +--- |
| 2 | +title: Static docucmentation |
| 3 | +--- |
| 4 | + |
| 5 | +# {{ page.title}} |
| 6 | + |
| 7 | +Scala3doc has similar functionalites to [Jekyll](http://jekyllrb.com/) to allow users to documentation in form of static sit alongside your APIs. Moreover having a combined tool allows provide reach interaction between those to such as linking thus allowing the two to |
| 8 | +blend naturally. |
| 9 | + |
| 10 | +Creating a site is just as simple as in Jekyll. The site root contains the |
| 11 | +layout of the site and all files placed here will be either considered static, |
| 12 | +or processed for template expansion. |
| 13 | + |
| 14 | +The files that are considered for template expansion must end in `*.{html,md}` |
| 15 | +and will from here on be referred to as "template files" or "templates". |
| 16 | + |
| 17 | +A simple "hello world" site could look something like this: |
| 18 | + |
| 19 | +``` |
| 20 | +├── docs |
| 21 | +│ └── getting-started.md |
| 22 | +└── index.html |
| 23 | +``` |
| 24 | + |
| 25 | +This will give you a site with the following files in genrated documentation: |
| 26 | + |
| 27 | +``` |
| 28 | +index.html |
| 29 | +docs/getting-started.html |
| 30 | +``` |
| 31 | + |
| 32 | +Scala3doc 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)). |
| 33 | + |
| 34 | +## Properties |
| 35 | + |
| 36 | +Scala3doc uses the [Liquid](https://shopify.github.io/liquid/) templating engine |
| 37 | +and provides a number of custom filters and tags specific to Scala |
| 38 | +documentation. |
| 39 | + |
| 40 | +In Scala3doc, all templates can contain YAML front-matter. The front-matter |
| 41 | +is parsed and put into the `page` variable available in templates via Liquid. |
| 42 | + |
| 43 | +Scala3doc uses some predefied properties to controls some aspect of page. |
| 44 | + |
| 45 | +Predefiend properties: |
| 46 | + |
| 47 | + - **title** provide page title that will be used in navigation and html metadata. |
| 48 | + - **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** |
| 49 | + - **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** |
| 50 | + - **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) |
| 51 | +- **layout** - predefined layout to use, see below |
| 52 | + |
| 53 | + |
| 54 | +## Using existing Templates and Layouts |
| 55 | + |
| 56 | +To perform template expansion, Dottydoc looks at `layout` in the front-matter. |
| 57 | +Here's a simple example of the templating system in action, `index.html`: |
| 58 | + |
| 59 | +```html |
| 60 | +--- |
| 61 | +layout: main |
| 62 | +--- |
| 63 | + |
| 64 | +<h1>Hello world!</h1> |
| 65 | +``` |
| 66 | + |
| 67 | +With a simple main template like this: |
| 68 | + |
| 69 | +{% raw %} |
| 70 | +```html |
| 71 | +<html> |
| 72 | + <head> |
| 73 | + <title>Hello, world!</title> |
| 74 | + </head> |
| 75 | + <body> |
| 76 | + {{ content }} |
| 77 | + </body> |
| 78 | +</html> |
| 79 | +``` |
| 80 | + |
| 81 | +Would result in `{{ content }}` being replaced by `<h1>Hello world!</h1>` from |
| 82 | +the `index.html` file. |
| 83 | +{% endraw %} |
| 84 | + |
| 85 | +Layouts must be placed in a `_layouts` directory in the site root: |
| 86 | + |
| 87 | +``` |
| 88 | +├── _layouts |
| 89 | +│ └── main.html |
| 90 | +├── docs |
| 91 | +│ └── getting-started.md |
| 92 | +└── index.html |
| 93 | +``` |
| 94 | + |
| 95 | +Sidebar |
| 96 | +======= |
| 97 | +Scala3doc by default use 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: |
| 98 | + |
| 99 | +```yaml |
| 100 | +sidebar: |
| 101 | + - title: Blog |
| 102 | + url: blog/index.html |
| 103 | + - title: Docs |
| 104 | + url: docs/index.html |
| 105 | + - title: Usage |
| 106 | + subsection: |
| 107 | + - title: Dottydoc |
| 108 | + url: docs/usage/dottydoc.html |
| 109 | + - title: sbt-projects |
| 110 | + url: docs/usage/sbt-projects.html |
| 111 | +``` |
| 112 | +
|
| 113 | +The `sidebar` key is mandatory, as well as `title` for each element. The |
| 114 | +default table of contents allows you to have subsections - albeit the current |
| 115 | +depth limit is 2 however it accepts both files and directories and latter can be used to provide deeper structures. |
| 116 | + |
| 117 | +The items which have the `subsection` does not accepts `url` section. |
| 118 | + |
| 119 | +``` |
| 120 | +├── blog |
| 121 | +│ └── _posts |
| 122 | +│ └── 2016-12-05-implicit-function-types.md |
| 123 | +├── index.html |
| 124 | +└── sidebar.yml |
| 125 | +``` |
0 commit comments