Skip to content

Commit 011d553

Browse files
committed
docs: improve scaladocs for TastyFormat
The main motivation behind this is to improve the reader experience when looking at the TastyFormat docs on https://scala-lang.org/api/3.x/dotty/tools/tasty/TastyFormat$.html since in its current format all spacing is lost. This instead utilizes code blocks in a valid scaladoc to ensure the spacing is kept. You can see what this should look like by looking at https://scala-lang.org/api/3.x/scala/quoted/Quotes$reflectModule.html which uses the same approach. Addresses lampepfl/dotty-feature-requests#273
1 parent 17d2f45 commit 011d553

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tasty/src/dotty/tools/tasty/TastyFormat.scala

+13-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ lower case letter*_ are for explanation of semantic content only, they
1010
can be dropped without changing the grammar.
1111
1212
Micro-syntax:
13-
13+
```none
1414
LongInt = Digit* StopDigit -- big endian 2's complement, value fits in a Long w/o overflow
1515
Int = LongInt -- big endian 2's complement, fits in an Int w/o overflow
1616
Nat = LongInt -- non-negative value, fits in an Int without overflow
1717
Digit = 0 | ... | 127
1818
StopDigit = 128 | ... | 255 -- value = digit - 128
19+
```
1920
2021
Macro-format:
21-
22+
```none
2223
File = Header majorVersion_Nat minorVersion_Nat experimentalVersion_Nat VersionString UUID
2324
nameTable_Length Name* Section*
2425
Header = 0x5CA1AB1F
@@ -48,13 +49,14 @@ Macro-format:
4849
// If positive, this is a NameRef for the fully qualified name of a term parameter.
4950
5051
NameRef = Nat // ordinal number of name in name table, starting from 1.
52+
```
5153
5254
Note: Unqualified names in the name table are strings. The context decides whether a name is
5355
a type-name or a term-name. The same string can represent both.
5456
5557
5658
Standard-Section: "ASTs" TopLevelStat*
57-
59+
```none
5860
TopLevelStat = PACKAGE Length Path TopLevelStat* -- package path { topLevelStats }
5961
Stat
6062
@@ -220,22 +222,23 @@ Standard-Section: "ASTs" TopLevelStat*
220222
| CONTRAVARIANT
221223
222224
Annotation = ANNOTATION Length tycon_Type fullAnnotation_Term -- An annotation, given (class) type of constructor, and full application tree
225+
```
223226
224227
Note: The signature of a SELECTin or TERMREFin node is the signature of the selected symbol,
225228
not the signature of the reference. The latter undergoes an asSeenFrom but the former
226229
does not.
227230
228231
Note: Tree tags are grouped into 5 categories that determine what follows, and thus allow to compute the size of the tagged tree in a generic way.
229-
232+
```none
230233
Category 1 (tags 1-59) : tag
231234
Category 2 (tags 60-89) : tag Nat
232235
Category 3 (tags 90-109) : tag AST
233236
Category 4 (tags 110-127): tag Nat AST
234237
Category 5 (tags 128-255): tag Length <payload>
235-
238+
```
236239
237240
Standard-Section: "Positions" LinesSizes Assoc*
238-
241+
```none
239242
LinesSizes = Nat Nat* // Number of lines followed by the size of each line not counting the trailing `\n`
240243
241244
Assoc = Header offset_Delta? offset_Delta? point_Delta?
@@ -251,15 +254,17 @@ Standard-Section: "Positions" LinesSizes Assoc*
251254
SOURCE = 4 // Impossible as header, since addr_Delta = 0 implies that we refer to the
252255
// same tree as the previous one, but then hasStartDiff = 1 implies that
253256
// the tree's range starts later than the range of itself.
257+
```
254258
255259
All elements of a position section are serialized as Ints
256260
257261
258262
Standard Section: "Comments" Comment*
259-
263+
```none
260264
Comment = Length Bytes LongInt // Raw comment's bytes encoded as UTF-8, followed by the comment's coordinates.
265+
```
261266
262-
267+
* @syntax markdown
263268
**************************************************************************************/
264269

265270
object TastyFormat {

0 commit comments

Comments
 (0)