You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/usage/scala3doc/docComments.md
+35-9Lines changed: 35 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,42 @@ title: API Documentation
4
4
5
5
# {{ page.title }}
6
6
7
-
Scala3doc main feature is to create API documentation based on [doc comments](https://docs.scala-lang.org/style/scaladoc.html) known from scaladoc as well well as new syntax introduced in Scala 3.
7
+
Scala3doc's main feature is creating API documentation from code comments.
8
8
9
-
## New syntax
9
+
By default, the code comments are understood as Markdown, though we also support
10
+
Scaladoc's old [Wiki syntax](https://docs.scala-lang.org/style/scaladoc.html).
10
11
11
-
### Links
12
+
##Syntax
12
13
13
-
The goal with the link syntax was to be as Scaladoc-compatible as possible,
14
-
while also making the links a bit more pleasant to type and read.
15
-
For the time being, Scala3doc mostly keeps Scaladoc's definition link syntax. We
16
-
did, however, implement some improvements to it:
14
+
### Definition links
15
+
16
+
Our definition link syntax is quite close to Scaladoc's syntax, though we have made some
17
+
quality-of-life improvements.
18
+
19
+
#### Basic syntax
20
+
21
+
A definition link looks as follows: `[[scala.collection.immutable.List]]`.
22
+
23
+
Which is to say, a definition link is a sequence of identifiers separated by
24
+
`.`. The identifiers can be separated with `#` as well for Scaladoc compatibility.
25
+
26
+
By default, an identifier `id` references the first (in source order) entity
27
+
named `id`. An identifier can end with `$`, which forces it to refer to a value
28
+
(an object, a value, a given); an identifier can also end with `!`, which forces
29
+
it to refer to a type (a class, a type alias, a type member).
30
+
31
+
The links are resolved relative to the current location in source. That is, when
32
+
documenting a class, the links are relative to the entity enclosing the class (a
33
+
package, a class, an object); the same applies to documenting definitions.
34
+
35
+
Special characters in links can be backslash-escaped, which makes them part of
36
+
identifiers instead. For example, `` [[scala.collection.immutable\.List]] ``
37
+
references the class named `` `immutable.List` `` in package `scala.collection`.
38
+
39
+
#### New syntax
40
+
41
+
We have extended Scaladoc definition links to make them a bit more pleasant to
42
+
write and read in source. The new syntax features are:
17
43
18
44
1.`package` can be used as a prefix to reference the enclosing package
19
45
Example:
@@ -51,7 +77,7 @@ did, however, implement some improvements to it:
51
77
Scaladoc required backslash-escaping to reference such identifiers. Instead,
52
78
Scala3doc allows using the familiar Scala backtick quotation.
53
79
54
-
### Why keep the Wiki syntax?
80
+
#### Why keep the Wiki syntax for links?
55
81
56
82
There are a few reasons why we've kept the Wiki syntax for documentation links
57
83
instead of reusing the Markdown syntax. Those are:
@@ -67,4 +93,4 @@ instead of reusing the Markdown syntax. Those are:
67
93
68
94
None of these make it completely impossible to use the standard Markdown link
69
95
syntax, but they make it much more awkward and ugly than it needs to be. On top
70
-
of that, Markdown link syntax doesn't even save any characters.
96
+
of that, Markdown link syntax doesn't even save any characters.
Scala3doc extends markdown with some unique behaviors such as linking to API. This can be used from within static documentation and blog posts to provide blend-in content.
7
+
Scala3doc extends Markdown with additional features, such as linking
8
+
to API definitions. This can be used from within static documentation and blog
9
+
posts to provide blend-in content.
8
10
9
11
## Linking to API
10
12
11
-
If you for instance, want to link to `scala.collection.immutable.Seq` in a
12
-
markdown file, you can simply use the canonical path in your url:
13
-
14
-
```markdown
15
-
[Seq](scala.collection.immutable.Seq)
16
-
```
17
-
18
-
Linking to members is done in the same fashion:
19
-
20
-
```markdown
21
-
[Seq](scala.collection.immutable.Seq.isEmpty)
22
-
```
23
-
24
-
Scala3doc denotes objects by ending their names in "$". To select `List.range`
0 commit comments