Skip to content

Commit aaec84d

Browse files
authored
Merge pull request #10155 from grzegorz-bielski/scala3doc/btns-for-default-values
Scala3doc: Added filters for default keywords
2 parents 9a47067 + 5f7d2b8 commit aaec84d

File tree

18 files changed

+2697
-169
lines changed

18 files changed

+2697
-169
lines changed

scala3doc/README.md

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ We're aiming to support all the features Scaladoc did, plus new and exciting one
2020
Use the following commands to generate documentation for this project and for Dotty, respectively:
2121

2222
```
23-
sbt generateSelfDocumentation
24-
sbt generateDottyLibDocumentation
23+
sbt scala3doc/generateSelfDocumentation
24+
sbt scala3doc/generateScala3Documentation
2525
```
2626

2727
To actually view the documentation, the easiest way is to run the following in project root:
@@ -41,15 +41,16 @@ the documentation won't work completely if you don't.
4141
## CLI Documentation
4242

4343
CLI command for running our tool is in form: `sbt main -n <name> -o <output> -t <tasty-files> -cp <classpath> -s { <sources> } -d <documentation> ` where:
44-
- `<name>`: name of module in generated documentation
45-
- `<output>`: location where documentation should be created
46-
- `<tasty-files>`: is list of dirs or jars that contains tasty files that should be documented
47-
- `<classpath>`: classpath that was used to generate tasty files
48-
- `<sources>`: links to source files of module that are used to link symbols on pages to their source file. They need to be supplied in form:
49-
`local_dir=remote_dir#line_suffix` e.g. `src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L`
50-
- `<documentation>`: directory of static documentation that you would like to render with API documentation. This feature is provided by dokka-site plugin:
51-
- [GitHub](https://github.com/VirtusLab/dokka-site)
52-
- [Documentation](https://virtuslab.github.io/dokka-site/index.html)
44+
45+
- `<name>`: name of module in generated documentation
46+
- `<output>`: location where documentation should be created
47+
- `<tasty-files>`: is list of dirs or jars that contains tasty files that should be documented
48+
- `<classpath>`: classpath that was used to generate tasty files
49+
- `<sources>`: links to source files of module that are used to link symbols on pages to their source file. They need to be supplied in form:
50+
`local_dir=remote_dir#line_suffix` e.g. `src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L`
51+
- `<documentation>`: directory of static documentation that you would like to render with API documentation. This feature is provided by dokka-site plugin:
52+
- [GitHub](https://github.com/VirtusLab/dokka-site)
53+
- [Documentation](https://virtuslab.github.io/dokka-site/index.html)
5354

5455
## Developing
5556

@@ -59,49 +60,35 @@ work on the project.
5960
For every PR, we build documentation for Scala3doc and Dotty. For example, for
6061
PR 123 you can find them at:
6162

62-
+ <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-123/self/main/index.html>
63-
+ <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-123/stdLib/main/index.html>
63+
- <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-123/self/main/index.html>
64+
- <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-123/stdLib/main/index.html>
6465

6566
Note that these correspond to the contents of `output` directory - that's
6667
precisely what they are.
6768

6869
You can also find the result of building the same sites for latest `master` at:
6970

70-
+ <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-master/self/main/index.html>
71-
+ <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-master/stdLib/main/index.html>
71+
- <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-master/self/main/index.html>
72+
- <https://scala3doc.s3.eu-central-1.amazonaws.com/pr-master/stdLib/main/index.html>
7273

7374
### Testing
7475

75-
To implement integration tests that inspects state of the model on different stages of
76-
documentation generation one can use [ScaladocTest](src/test/scala/dotty/dokka/ScaladocTest.scala#L15).
77-
This class requires providing the name of the test and a the list of assertions.
78-
79-
Name of the test is used to extract symbols that should be included in given test run from
80-
the TASTY files. All test data is located in [scala3doc-testcases module](../scala3doc-testcases/src).
81-
It is compiled together with the rest of modules. This solves lots of potential problems with
82-
invoking the compiler in a separate process such as mismatching versions. Every test is using
83-
only symbols defined in the package with the same name as the test located inside top level `tests`
84-
package (including subpackages). This restriction may be relaxed in the future.
85-
86-
Assertions of each test are defined as list of [Assertion enum](src/test/scala/dotty/dokka/ScaladocTest.scala#L63)
87-
instances. Each of them represents a callback that is invoked in corresponding phase of
88-
documentation generation. Those callback can inspect the model, log information and raise errors
89-
using `reportError` method.
90-
91-
#### Signature tests
76+
Most tests rely on comparing signatures (of classes, methods, objects etc.) extracted from the generated documentation
77+
to signatures found in source files. Such tests are defined using [MultipleFileTest](test/dotty/dokka/MultipleFileTest.scala) class
78+
and its subtypes (such as [SingleFileTest](test/dotty/dokka/SingleFileTest.scala))
9279

93-
Some of the tests rely on comparing signatures (of classes, methods, objects etc.) extracted from
94-
the generated documentation to signatures found in source files. Such tests are defined using
95-
[SignatureTest](src/test/scala/dotty/dokka/SignatureTest.scala#L16) class, that is a subclass of
96-
`ScaladocTest` and uses exactly tha same mechanism to find input symbols in the TASTY files.
80+
WARNING: As the classes mentioned above are likely to evolve, the description below might easily get out of date.
81+
In case of any discrepancies rely on the source files instead.
9782

98-
Signature tests by default assume that sources that were used to generate used TASTY files are
99-
located in the file with the same name as the name of the test. If this is not the case optional
100-
parameter `sourceFiles` can be used to pass list of source file names (without `.scala` extension).
101-
102-
Those tests also requires specifying kinds of ignatures from source files (corresponding to
103-
keywords used to declare them like `def`, `class`, `object` etc.) whose presence in the generated
104-
documentation will be checked (other signatures, when missing, will be ignored).
83+
`MultipleFileTest` requires that you specify the names of the files used to extract signatures,
84+
the names of directories containing corresponding TASTY files
85+
and the kinds of signatures from source files (corresponding to keywords used to declare them like `def`, `class`, `object` etc.)
86+
whose presence in the generated documentation will be checked (other signatures, when missing, will be ignored).
87+
The mentioned source files should be located directly inside `src/main/scala/tests` directory
88+
but the file names passed as parameters should contain neither this path prefix nor `.scala` suffix.
89+
The TASTY folders are expected to be located in `target/${dottyVersion}/classes/tests` (after successful compilation of the project)
90+
and similarly only their names relative to this path should be provided as tests' parameters.
91+
For `SingleFileTest` the name of the source file and the TASTY folder are expected to be the same.
10592

10693
By default it's expected that all signatures from the source files will be present in the documentation
10794
but not vice versa (because the documentation can contain also inherited signatures).
@@ -129,7 +116,6 @@ instead of
129116
def foo(): Int
130117
```
131118

132-
133119
Because of the way how signatures in source are parsed, they're expected to span until the end of a line (including comments except those special ones mentioned above, which change the behaviour of tests) so if a definition contains an implementation, it should be placed in a separate line, e.g.
134120

135121
```
@@ -150,8 +136,9 @@ Otherwise the implementation would be treated as a part of the signature.
150136
1. Replace Dottydoc as the dedicated tool for documenting Dotty code
151137

152138
This includes:
153-
+ supporting Dotty's doc pages
154-
+ releasing together with Dotty as the dedicated documentation tool
139+
140+
- supporting Dotty's doc pages
141+
- releasing together with Dotty as the dedicated documentation tool
155142

156143
1. Support all kinds of Dotty definition and generate documentation for the
157144
standard library

scala3doc/e2e/.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"trailingComma": "all",
7+
"bracketSpacing": true,
8+
"arrowParens": "avoid"
9+
}

scala3doc/e2e/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## scala3doc e2e test suite
2+
3+
### Prerequisites
4+
5+
- install Node.js
6+
- run `npm i`
7+
8+
### Running tests
9+
10+
- generate the test docs: `sbt scala3doc/generateTestcasesDocumentation`
11+
- run the web server in the `output` directory: `python3 -m http.server 8080`
12+
- run `npm run cypress:open` to see the cypress UI or `npm run cypress:run` to run tests heedlessly

scala3doc/e2e/cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)