Skip to content

Scala3doc: Add build step for FE resources #10187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/scala3doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ jobs:

- name: Generate testcases documentation
run: ./project/scripts/sbt scala3doc/generateTestcasesDocumentation

- name: Install node
uses: actions/setup-node@v2-beta
with:
node-version: 12
check-latest: true

- name: Run e2e tests
run: |
npm --prefix ./scala3doc/e2e ci
npm --prefix ./scala3doc/e2e run ci

- name: Generate Scala 3 documentation
run: ./project/scripts/sbt scala3doc/generateScala3Documentation
Expand Down
4 changes: 4 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,10 @@ object Build {

def asScala3doc: Project = {
def generateDocumentation(targets: String, name: String, outDir: String, ref: String, params: String = "") = Def.taskDyn {
val frontEndDir = baseDirectory.value / "resources"
runProcess(Seq("npm", "install"), wait = true, directory = Some(frontEndDir))
runProcess(Seq("npm", "run", "build"), wait = true, directory = Some(frontEndDir))

val projectVersion = version.value
val sourcesAndRevision = s"-s github://lampepfl/dotty --revision $ref --projectVersion $projectVersion"
val cmd = s""" -d $outDir -t $targets -n "$name" $sourcesAndRevision $params"""
Expand Down
8 changes: 7 additions & 1 deletion scala3doc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# root where we generate documentation
output
output

# generated resources
resources/dotty_res/scripts/bundle.js
resources/dotty_res/styles/main.css

e2e/cypress/videos
12 changes: 12 additions & 0 deletions scala3doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ respectively.
It's not strictly necessary to go through an HTTP server, but because of CORS
the documentation won't work completely if you don't.

## Building frontend

Make sure you have installed `node`

Frontend resources should be built automatically after running any `sbt` task that uses
`generateDocumentation`, such as `sbt scala3/generateTestcasesDocumentation`

You can also do it manually by running `npm i` and `npm run build`in the `resources` folder.
To see the changes you still need to copy sources to `output` folder, this is normally done automatically by the `sbt` task.

You might want to turn on sourcemaps for local development.

## CLI Documentation

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:
Expand Down
6 changes: 3 additions & 3 deletions scala3doc/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
- install Node.js
- run `npm i`

### Running tests
### Running tests locally

- generate the test docs: `sbt scala3doc/generateTestcasesDocumentation`
- run the web server in the `output` directory: `python3 -m http.server 8080`
- run `npm run cypress:open` to see the cypress UI or `npm run cypress:run` to run tests heedlessly
- run the web server: `npm run serve`
- run `npm run cypress:open` to see the cypress UI or `npm run cypress:run` to run tests headlessly
4 changes: 3 additions & 1 deletion scala3doc/e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"video": false
}
17 changes: 14 additions & 3 deletions scala3doc/e2e/cypress/integration/filter-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('filter-bar', () => {
const testTable: TestTable = [
['Visibility', ['public', 'protected']],
['Keywords', ['no keywords', 'abstract', 'case', 'final', 'sealed']],
['Inherited', ['Not inherited', 'FilterTestBase', 'FilterTestBaseTrait']],
['Extension', ['Standard member', 'from tests']],
];

Expand All @@ -32,6 +33,7 @@ describe('filter-bar', () => {
const testTable: TestTable = [
['Visibility', ['public', 'protected']],
['Keywords', ['no keywords']],
['Inherited', ['Not inherited', 'FilterTestBase']],
['Extension', ['Standard member']],
];

Expand Down Expand Up @@ -71,7 +73,7 @@ describe('filter-bar', () => {
});

it(`'Standard member'`, () => {
new FilterBarFixture().toggle().group(2).toggleFilter('Standard member');
new FilterBarFixture().toggle().group(3).toggleFilter('Standard member');

new TabsFixture().definitionTypes.should('not.be.visible');
});
Expand All @@ -91,8 +93,17 @@ describe('filter-bar', () => {
new TabsFixture().definitionTypes.should('not.be.visible');
});

it('all inherited options', () => {
new FilterBarFixture()
.toggle()
.group(2)
.toggleFilter('Not inherited', 'FilterTestBase', 'FilterTestBaseTrait');

new TabsFixture().definitionTypes.should('not.be.visible');
});

it('all extension options', () => {
new FilterBarFixture().toggle().group(2).toggleFilter('Standard member', 'from tests');
new FilterBarFixture().toggle().group(3).toggleFilter('Standard member', 'from tests');

new TabsFixture().definitionTypes.should('not.be.visible');
});
Expand Down Expand Up @@ -288,7 +299,7 @@ class BatchSelectionFixture {
}

function openPage() {
cy.visit('http://localhost:8080/testcases/api/tests/-filter-test/index.html');
cy.visit('http://localhost:8080/testcases/-scala3doc%20testcases/tests/-filter-test/index.html');
}

type TestTable = [string, string[]][];
Expand Down
Loading