Skip to content

Commit 9433228

Browse files
authored
Merge pull request #1353 from ashawley/scaladoc
Add page on generating Scaladoc
2 parents 9a9b968 + af88f65 commit 9433228

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

_overviews/scaladoc/generate.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
layout: multipage-overview
3+
title: Generating Scaladoc
4+
5+
discourse: true
6+
7+
partof: scaladoc
8+
overview-name: Scaladoc
9+
10+
num: 4
11+
12+
permalink: /overviews/scaladoc/:title.html
13+
---
14+
15+
There are two ways to generate API documentation in HTML from your Scala code. Those options are:
16+
17+
* use sbt to do it,
18+
* use the scaladoc command-line tool.
19+
20+
## Using sbt
21+
22+
The easiest and most commonly used way to generate API documentation from your Scala code is with the build tool [sbt](https://www.scala-sbt.org).
23+
24+
In the sbt shell, generate Scaladoc by running `doc`:
25+
26+
> doc
27+
[info] Main Scala API documentation to target/scala-2.12/api...
28+
[info] model contains 1 documentable templates
29+
[info] Main Scala API documentation successful.
30+
[success] Total time: 20 s
31+
32+
The HTML documentation will show up in the respective `target/` directory (or directories for builds with multiple projects) that sbt prints to the console output.
33+
34+
For more information on using sbt on your system, see the [download instructions](https://www.scala-lang.org/download/) for [getting started with Scala and sbt on the command line]({{site.baseurl}}/getting-started-sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html).
35+
36+
For additional information about configuring Scaladoc in sbt, see the [Generate API documentation](https://www.scala-sbt.org/1.x/docs/Howto-Scaladoc.html) section of the sbt reference manual.
37+
38+
## Using scaladoc command
39+
40+
If you use Scala commands directly to start a console with `scala` or compile with `scalac`, then you should have a `scaladoc` command-line utility, as well. This is a more advanced and less commonly used method of generating Scaladoc.
41+
42+
$ scaladoc src/main/scala/App.scala
43+
model contains 1 documentable templates
44+
45+
This will put the HTML in the current directory. This is probably not what you want. It's preferable to output to a subdirectory. To specify a different target directory, use the `-d` command-line option:
46+
47+
$ scaladoc -d build/ src/main/scala/App.scala
48+
49+
For more information on the `scaladoc` command and what other command-line options it supports, see the [scaladoc man page](https://www.scala-lang.org/files/archive/nightly/docs/manual/html/scaladoc.html).
50+
51+
This command is harder to operate with more complex projects containing both multiple Scala source files and library dependencies. This is why using sbt (see above) is easier and better suited for generating Scaladoc.
52+
53+
The Scaladoc command exists because it preceded the development of sbt, but also because it is useful to the Scala development team with studying bug reports for Scaladoc.
54+
55+
More information on directly using the Scala commands, like `scaladoc`, is discussed at [your first lines of Scala](https://www.scala-lang.org/documentation/your-first-lines-of-scala.html).

_overviews/scaladoc/overview.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ system that lives in the comments of Scala source code and which generates
1717
documentation related to the code structure within which it is written. It is
1818
based on other comment based documentation systems like Javadoc.
1919

20-
There are two flavors of Scaladoc documentation:
20+
There are three aspects of Scaladoc documentation:
2121

2222
- **[Using the Scaladoc interface]({{ site.baseurl }}/overviews/scaladoc/interface.html)** – how to navigate and use generated Scaladoc documentation to learn more about a library.
23-
- **[Generating documentation for your library with Scaladoc]({{ site.baseurl }}/overviews/scaladoc/for-library-authors.html)** – how to use Scaladoc to generate documentation for your library.
23+
- **[Scaladoc for Library Authors]({{ site.baseurl }}/overviews/scaladoc/for-library-authors.html)** – how to add Scaladoc comments to generate documentation for your library.
24+
- **[Generating documentation for your library with Scaladoc]({{ site.baseurl }}/overviews/scaladoc/generate.html)** – how to use Scaladoc to generate documentation for your library.
2425

2526
### Contributing to Scaladoc
2627

0 commit comments

Comments
 (0)