Skip to content

Commit 1413dab

Browse files
authored
Merge pull request #13004 from BarkingBad/scaladoc/update-docs
Update the docs, change sidebar url property to page/index
2 parents 525f4a5 + edd52ba commit 1413dab

File tree

9 files changed

+335
-330
lines changed

9 files changed

+335
-330
lines changed

docs/docs/usage/scaladoc/settings.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ If you want to know what is current state of compatibility with scaladoc old fla
1313

1414
## Providing settings
1515

16-
Supply scaladoc settings as command-line arguments, e.g., `scaladoc -d output -project my-project target/scala-3.0.0-RC2/classes`. If called from sbt,
17-
update the value of `Compile / doc / scalacOptions`, e. g. `Compile / doc / scalacOptions ++= Seq("-d", "output", "-project", "my-project")`
16+
Supply scaladoc settings as command-line arguments, e.g., `scaladoc -d output -project my-project target/scala-3.0.0-RC2/classes`. If called from sbt, update the value of `Compile / doc / scalacOptions` and `Compile / doc / target` respectively, e. g.
17+
18+
```
19+
Compile / doc / target ++= Seq("-d", "output")
20+
Compile / doc / scalacOptions ++= Seq("-project", "my-project")
21+
```
1822

1923
## Overview of all available settings
2024

@@ -118,6 +122,10 @@ A base URL to use as prefix and add `canonical` URLs to all pages. The canonical
118122

119123
A directory containing static files from which to generate documentation. Default directory is `./docs`
120124

125+
##### -no-link-warnings
126+
127+
Suppress warnings for ambiguous or incorrect links in members’ lookup. Doesn't affect warnings for incorrect links of assets etc.
128+
121129
##### -versions-dictionary-url
122130

123131
A URL pointing to a JSON document containing a dictionary: `version label -> documentation location`.
@@ -134,3 +142,39 @@ Example JSON file:
134142
}
135143
```
136144

145+
##### -snippet-compiler
146+
147+
Snippet compiler arguments provide a way to configure snippet type checking.
148+
149+
This setting accepts a list of arguments in the format:
150+
args := arg{,arg}
151+
arg := [path=]flag
152+
where `path` is a prefix of the path to source files where snippets are located and `flag` is the mode in which snippets will be type checked.
153+
154+
If the path is not present, the argument will be used as the default for all unmatched paths.
155+
156+
Available flags:
157+
compile - Enables snippet checking.
158+
nocompile - Disables snippet checking.
159+
fail - Enables snippet checking, asserts that snippet doesn't compile.
160+
161+
The fail flag comes in handy for snippets that present that some action would eventually fail during compilation, e. g. [Opaques page](docs/reference/other-new-features/opaques.html)
162+
163+
Example usage:
164+
165+
`-snippet-compiler:my/path/nc=nocompile,my/path/f=fail,compile`
166+
167+
Which means:
168+
169+
all snippets in files under directory `my/path/nc` should not be compiled at all
170+
all snippets in files under directory `my/path/f` should fail during compilation
171+
all other snippets should compile successfully
172+
173+
##### -Ysnippet-compiler-debug
174+
175+
Setting this option makes snippet compiler print the snippet as it is compiled (after wrapping).
176+
177+
##### -Ydocument-synthetic-types
178+
179+
Include pages providing documentation for the intrinsic types (e. g. Any, Nothing) to the docs. The setting is useful only for stdlib because scaladoc for Scala 3 relies on TASTy files, but we cannot provide them for intrinsic types since they are embedded in the compiler.
180+
All other users should not concern with this setting.

docs/docs/usage/scaladoc/staticSite.md

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Static documentation
33
---
44

5-
# {{ page.title}}
5+
# {{ page.title }}
66

7-
Scaladoc is able to generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/).
8-
Having a combined tool allows to provide interaction between static documentation and API, thus allowing the two to blend naturally.
7+
Scaladoc can generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/).
8+
Having a combined tool allows providing interaction between static documentation and API, thus allowing the two to blend naturally.
99

1010
Creating a site is just as simple as in Jekyll. The site root contains the
11-
layout of the site and all files placed there will be either considered static,
11+
the layout of the site and all files placed there will be either considered static,
1212
or processed for template expansion.
1313

1414
The files that are considered for template expansion must end in `*.{html,md}`
@@ -29,26 +29,33 @@ index.html
2929
docs/getting-started.html
3030
```
3131

32-
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)).
32+
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.
3333

3434
## Properties
3535

3636
Scaladoc uses the [Liquid](https://shopify.github.io/liquid/) templating engine
37-
and provides a number of custom filters and tags specific to Scala
37+
and provides several custom filters and tags specific to Scala
3838
documentation.
3939

4040
In Scaladoc, all templates can contain YAML front-matter. The front-matter
4141
is parsed and put into the `page` variable available in templates via Liquid.
4242

43-
Scaladoc uses some predefined properties to controls some aspect of page.
43+
Example front-matter
44+
```
45+
---
46+
title: My custom title
47+
---
48+
```
49+
50+
Scaladoc uses some predefined properties to controls some aspects of page.
4451

4552
Predefined properties:
4653

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). **This setting is not exported to template engine.**
51-
- **layout** - predefined layout to use, see below. **This setting is not exported to template engine.**
54+
- **title** provide page title that will be used in navigation and HTML metadata.
55+
- **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.**
56+
- **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.**
57+
- **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.**
58+
- **layout** - predefined layout to use, see below. **This setting is not exported to the template engine.**
5259

5360

5461
## Using existing Templates and Layouts
@@ -99,23 +106,44 @@ Scaladoc by default uses layout of files in `docs` directory to create table of
99106
```yaml
100107
sidebar:
101108
- title: Blog
102-
- title: Docs
103-
url: docs/index.html
104-
- title: Usage
109+
- title: My title
110+
page: my-page1.md
111+
- page: my-page2.md
112+
- page: my-page3/subsection
113+
- title: Reference
105114
subsection:
106-
- title: Dottydoc
107-
url: docs/usage/dottydoc.html
108-
- title: sbt-projects
109-
url: docs/usage/sbt-projects.html
115+
- page: my-page3.md
116+
- index: my-page4/index.md
117+
subsection:
118+
- page: my-page4/my-page4.md
119+
- title: My subsection
120+
index: my-page5/index.md
121+
subsection:
122+
- page: my-page5/my-page5.md
123+
- index: my-page6/index.md
124+
subsection:
125+
- index: my-page6/my-page6/index.md
126+
subsection:
127+
- page: my-page6/my-page6/my-page6.md
110128
```
111129
112-
The `sidebar` key is mandatory, as well as `title` for each element. The
113-
default table of contents allows you to have subsections - albeit the current
114-
depth limit is 2 however it accepts both files and directories and latter can be used to provide deeper structures.
130+
The `sidebar` key is mandatory.
131+
On each level, you can have three different types of entries: `page`, `blog` or `subsection`.
132+
133+
`page` is a leaf of the structure and accepts the following attributes:
134+
- `title` (optional) - title of the page
135+
- `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.
136+
137+
The `page` property
115138

116-
The items must provide either `subsection` or `url` but not both at once!
117-
The only exception is `Blog` which is only a `title` and behaves differently.
118-
You can read more about blog [here](blog.md).
139+
`subsection` accepts nested nodes, these can be either pages or subsections, which allow you to create tree-like navigation. The attributes are:
140+
- `title` (optional) - title of the page
141+
- `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
142+
- `subsection` (mandatory) - nested nodes, can be either pages or subsections
143+
144+
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.
145+
146+
`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).
119147

120148
```
121149
├── blog
@@ -126,10 +154,29 @@ You can read more about blog [here](blog.md).
126154
└── sidebar.yml
127155
```
128156

157+
## Hierarchy of title
158+
159+
If the title is specified multiple times, the priority is as follows (from highest to lowest priority):
160+
161+
#### Page
162+
163+
1. `title` from the `front-matter` of the markdown/html file
164+
2. `title` property from the `sidebar.yml` property
165+
3. filename
166+
167+
#### Subsection
168+
169+
1. `title` from the `front-matter` of the markdown/html index file
170+
2. `title` property from the `sidebar.yml` property
171+
3. filename
172+
173+
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.
174+
175+
129176
## Static resources
130177

131178
You can attach static resources (pdf, images) to your documentation by using two dedicated directories:
132-
`resources` and `images`. When you upload your assests under any of these directories you can reference them in markdown
179+
`resources` and `images`. After placing your assets under any of these directories, you can reference them in markdown
133180
as if they were relatively at the same level.
134181

135182
For example, consider the following situation:
@@ -151,5 +198,5 @@ For example, consider the following situation:
151198
You can refer to the assets from within any of the files using markdown links:
152199

153200
```
154-
This is my blogpost. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf)
201+
This is my blog post. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf)
155202
```

0 commit comments

Comments
 (0)