Skip to content

Commit 171b575

Browse files
committed
Update user manual for scaladoc
1 parent b568cdb commit 171b575

File tree

15 files changed

+208
-65
lines changed

15 files changed

+208
-65
lines changed

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ major authors were omitted by oversight.
8282
modifications. They were originally authored by Lex Spoon, Som Snytt,
8383
Adriaan Moors, Paul Phillips and others.
8484

85-
* dotty.tools.dottydoc: The Dottydoc documentation utility ships some
85+
* dotty.tools.scaladoc: The Scaladoc documentation utility ships some
8686
third-party JavaScript and CSS libraries which are located under
87-
dotty-doc/resources/css/, dotty-doc/resources/js/, docs/css/ and
87+
scaladoc/resources/dotty_res/styles/, scaladoc/resources/dotty_res/scripts/, docs/css/ and
8888
docs/js/. Please refer to the license header of the concerned files for
8989
details.
9090

compiler/src/dotty/tools/dotc/config/Printers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Printers {
2020
val debug = noPrinter
2121
val derive = noPrinter
2222
val desugar = noPrinter
23-
val dottydoc = noPrinter
23+
val scaladoc = noPrinter
2424
val exhaustivity = noPrinter
2525
val gadts = noPrinter
2626
val gadtsConstr = noPrinter

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
213213

214214
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
215215

216-
/** Dottydoc specific settings that are not used in scaladoc */
217-
val docSnapshot: Setting[Boolean] = BooleanSetting("-doc-snapshot", "Generate a documentation snapshot for the current Dotty version")
218-
219216
val projectUrl: Setting[String] = StringSetting (
220217
"-project-url",
221218
"project repository homepage",

compiler/src/dotty/tools/dotc/core/Comments.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object Comments {
143143
* @author Felix Mulder
144144
*/
145145
class CommentExpander {
146-
import dotc.config.Printers.dottydoc
146+
import dotc.config.Printers.scaladoc
147147
import scala.collection.mutable
148148

149149
def expand(sym: Symbol, site: Symbol)(using Context): String = {
@@ -203,7 +203,7 @@ object Comments {
203203
case None =>
204204
// SI-8210 - The warning would be false negative when this symbol is a setter
205205
if (ownComment.indexOf("@inheritdoc") != -1 && ! sym.isSetter)
206-
dottydoc.println(s"${sym.span}: the comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.")
206+
scaladoc.println(s"${sym.span}: the comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.")
207207
ownComment.replace("@inheritdoc", "<invalid inheritdoc annotation>")
208208
case Some(sc) =>
209209
if (ownComment == "") sc
@@ -317,7 +317,7 @@ object Comments {
317317
val sectionTextBounds = extractSectionText(parent, section)
318318
cleanupSectionText(parent.substring(sectionTextBounds._1, sectionTextBounds._2))
319319
case None =>
320-
dottydoc.println(s"""${sym.span}: the """" + getSectionHeader + "\" annotation of the " + sym +
320+
scaladoc.println(s"""${sym.span}: the """" + getSectionHeader + "\" annotation of the " + sym +
321321
" comment contains @inheritdoc, but the corresponding section in the parent is not defined.")
322322
"<invalid inheritdoc annotation>"
323323
}
@@ -384,7 +384,7 @@ object Comments {
384384
lookupVariable(vname, site) match {
385385
case Some(replacement) => replaceWith(replacement)
386386
case None =>
387-
dottydoc.println(s"Variable $vname undefined in comment for $sym in $site")
387+
scaladoc.println(s"Variable $vname undefined in comment for $sym in $site")
388388
}
389389
}
390390
}

compiler/src/dotty/tools/dotc/util/CommentParsing.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ package dotty.tools.dotc.util
88
import scala.collection.mutable
99

1010
/** The comment parsing in `dotc` is used by both the comment cooking and the
11-
* dottydoc tool.
11+
* scaladoc tool.
1212
*
1313
* The comment cooking is used to expand comments with `@inheritdoc` and
1414
* `@define` annotations. The rest of the comment is untouched and later
15-
* handled by dottydoc.
15+
* handled by scaladoc.
1616
*/
1717
object CommentParsing {
1818
import Chars._

docs/docs/usage/scaladoc/blog.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,33 @@ title: Built-in blog
77
Scaladoc allows you to include a simple blog in your documentation. For now, it
88
provides only basic features. In the future, we plan to include more advanced
99
features like tagging or author pages.
10+
11+
Blog is treated a little differently than regular static sites. This article will help you set up your own blog.
12+
13+
## Proper directory setup
14+
15+
All your blogposts must be put under `blog/_posts` directory.
16+
17+
18+
```
19+
├── blog
20+
│ ├── _posts
21+
│ │ └── 2016-12-05-implicit-function-types.md
22+
│ └── index.html
23+
```
24+
25+
If you are using sidebar don't forget to place
26+
27+
```
28+
sidebar:
29+
- title: Blog
30+
```
31+
32+
somewhere inside the tree. Scaladoc will attach under that section all of your blogposts.
33+
34+
## Naming convention
35+
36+
All the blogpost filenames should start with date in numeric format matching `YYYY-MM-DD`.
37+
Example name is `2015-10-23-dotty-compiler-bootstraps.md`.
38+
39+

docs/docs/usage/scaladoc/settings.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: Scaladoc settings
3+
---
4+
5+
# {{page.title}}
6+
7+
You can find brief information included in this chapter while calling scaladoc with `-help` flag. However it can be a little tricky if one uses sbt `doc` task.
8+
9+
## Parity with scaladoc for Scala 2
10+
11+
Scaladoc has been rewritten from scratch and some of the features turned out to be useless in the new context.
12+
If you want to know what is current state of compatibility with scaladoc old flags, you can visit this issue for tracking [progress](https://github.com/lampepfl/dotty/issues/11907).
13+
14+
## Providing settings
15+
16+
Scaladoc accepts settings provided as a string, e. g. `scaladoc -d output -project my-project target/scala-3.0.0-RC2/classes` or, if called from sbt,
17+
update the value of `Compile / doc / scalacOptions`, e. g. `Compile / doc / scalacOptions ++= Seq("-d", "output", "-project", "my-project")`
18+
19+
## Overview of all available settings
20+
21+
##### -project
22+
The name of the project. To provide compatibility with Scala2 aliases with `-doc-title`
23+
24+
##### -project-version
25+
The current version of your project that appears in a top left corner. To provide compatibility with Scala2 aliases with `-doc-version`
26+
27+
##### -project-logo
28+
The logo of your project that appears in a top left corner. To provide compatibility with Scala2 aliases with `-doc-logo`
29+
30+
##### -project-footer
31+
The string message that appears in a footer section. To provide compatibility with Scala2 aliases with `-doc-footer`
32+
33+
##### -comment-syntax
34+
The default syntax of comments. Defaults to markdown however wikisyntax can be used.
35+
36+
##### -revision
37+
Revision (branch or ref) used to build project project. Useful with sourcelinks to prevent them from pointing always to the newest master that is subject to changes.
38+
39+
##### -source-links
40+
Source links provide a mapping between file in documentation and code repository.
41+
42+
Accepted formats:
43+
<\sub-path>=<\source-link>
44+
<\source-link>
45+
46+
where <\source-link> is one of following:
47+
- `github://<organization>/<repository>[/revision][#subpath]`
48+
will match https://github.com/$organization/$repository/\[blob|edit]/$revision\[/$subpath]/$filePath\[$lineNumber]
49+
when revision is not provided then requires revision to be specified as argument for scaladoc
50+
- `gitlab://<organization>/<repository>`
51+
will match https://gitlab.com/$organization/$repository/-/\[blob|edit]/$revision\[/$subpath]/$filePath\[$lineNumber]
52+
when revision is not provided then requires revision to be specified as argument for scaladoc
53+
- <\scaladoc-template>
54+
55+
<scaladoc-template> is a format for `doc-source-url` parameter scaladoc.
56+
NOTE: We only supports `€{FILE_PATH_EXT}`, `€{TPL_NAME}`, `€{FILE_EXT}`,
57+
€{FILE_PATH}, and €{FILE_LINE} patterns
58+
59+
60+
Template can defined only by subset of sources defined by path prefix represented by `<sub-path>`.
61+
In such case paths used in templates will be relativized against `<sub-path>`
62+
63+
Example source links is:
64+
`-source-links:docs=github://lampepfl/dotty/master#docs`
65+
66+
67+
##### -external-mappings
68+
69+
Mapping between regexes matching classpath entries and external documentation.
70+
'regex::\[scaladoc|scaladoc|javadoc]::path' syntax is used
71+
72+
Example external mapping is:
73+
`-external-mappings:.*scala.*::scaladoc3::http://dotty.epfl.ch/api/,.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/`
74+
75+
##### -social-links
76+
77+
Links to social sites. '[github|twitter|gitter|discord]::link' syntax is used. 'custom::link::white_icon_name::black_icon_name' is also allowed, in this case icons must be present in 'images/'' directory.
78+
79+
Example social link is:
80+
81+
`-social-links:github::https://github.com/lampepfl/dotty,gitter::https://gitter.im/scala/scala,twitter::https://twitter.com/scala_lang`
82+
83+
##### -skip-by-id
84+
85+
Identifiers of packages or top-level classes to skip when generating documentation.
86+
87+
##### -skip-by-regex
88+
89+
Regexes that match fully qualified names of packages or top-level classes to skip when generating documentation.
90+
91+
##### -doc-root-content
92+
93+
The file from which the root package documentation should be imported.
94+
95+
##### -author
96+
97+
Include authors.
98+
99+
##### -groups
100+
101+
Group similar functions together (based on the @group annotation)
102+
103+
##### -private
104+
105+
Show all types and members. Unless specified, show only public and protected types and members.
106+
107+
##### -doc-canonical-base-url
108+
109+
A base URL to use as prefix and add `canonical` URLs to all pages. The canonical URL may be used by search engines to choose the URL that you want people to see in search results. If unset no canonical URLs are generated.
110+
111+
##### -siteroot
112+
113+
A directory containing static files from which to generate documentation. Default directory is `./docs`

docs/docs/usage/scaladoc/staticSite.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,13 @@ Layouts must be placed in a `_layouts` directory in the site root:
9292
└── index.html
9393
```
9494

95-
Sidebar
96-
=======
95+
## Sidebar
96+
9797
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:
9898

9999
```yaml
100100
sidebar:
101101
- title: Blog
102-
url: blog/index.html
103102
- title: Docs
104103
url: docs/index.html
105104
- title: Usage
@@ -114,12 +113,43 @@ The `sidebar` key is mandatory, as well as `title` for each element. The
114113
default table of contents allows you to have subsections - albeit the current
115114
depth limit is 2 however it accepts both files and directories and latter can be used to provide deeper structures.
116115

117-
The items which have on the `subsection` level does not accepts `url`.
116+
The items must provide either `subsection` or `url` but not both at once!
117+
The only excepiton is `Blog` which is only a `title` and behaves differently.
118+
You can read more about blog [here](blog.md).
118119

119120
```
120121
├── blog
121-
│ └── _posts
122-
│ └── 2016-12-05-implicit-function-types.md
122+
│ ├── _posts
123+
│ │ └── 2016-12-05-implicit-function-types.md
124+
│ └── index.html
123125
├── index.html
124126
└── sidebar.yml
125127
```
128+
129+
## Static resources
130+
131+
You can attach static resources (pdf, images) in your documentation using two dedicated directories:
132+
`resources` and `images`. When you upload your assests under any of these directories you can reference them in markdown
133+
as if they were relatively at the same level.
134+
135+
For example let's look at this situation:
136+
137+
```
138+
├── blog
139+
│ ├── _posts
140+
│ │ └── 2016-12-05-implicit-function-types.md
141+
│ └── index.html
142+
├── index.html
143+
├── resources
144+
│ └── my_file.pdf
145+
├── images
146+
│ └── my_image.png
147+
└── sidebar.yml
148+
149+
```
150+
151+
You can access them directly inside any of the files using markdown links:
152+
153+
```
154+
This is my blogpost. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf)
155+
```

docs/sidebar.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
sidebar:
22
- title: Blog
3-
url: blog/index.html
43
- title: Usage
54
subsection:
65
- title: Getting Started
@@ -17,8 +16,6 @@ sidebar:
1716
url: docs/usage/cbt-projects.html
1817
- title: Scaladoc
1918
url: docs/usage/scaladoc
20-
- title: Dottydoc [Legacy]
21-
url: docs/usage/dottydoc.html
2219
- title: Reference
2320
subsection:
2421
- title: Overview

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ object DottyPlugin extends AutoPlugin {
287287
// classpath, because we need all of those to actually run the compiler.
288288
// NOTE: All of those should have the *same version* (equal to scalaVersion
289289
// for everything but scala-library).
290-
// (Complication: because dottydoc is a separate artifact with its own dependencies,
290+
// (Complication: because scaladoc is a separate artifact with its own dependencies,
291291
// running it requires putting extra dependencies on the _JVM_ classpath)
292292
//
293293
// 3. scala-library, dotty-library on the _compiler_ bootclasspath or

0 commit comments

Comments
 (0)