Skip to content
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

[core] Fix docs:api silent crash #3808

Merged
merged 6 commits into from Feb 2, 2022
Merged

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Feb 1, 2022

I've noticed that yarn docs:api doesn't update API docs in #3807

It builds only part of the API and the silently crashes, here's the output:

yarn run v1.22.17
$ yarn docs:api:build
$ cross-env BABEL_ENV=development babel-node -i "/node_modules/(?!@mui)/" -x .ts,.tsx,.js ./docs/scripts/api/buildApi.ts
[BABEL] Note: The code generator has deoptimised the styling of /Users/andrew/workspace/material-ui-x/node_modules/typescript/lib/typescript.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /Users/andrew/workspace/material-ui-x/node_modules/lodash/lodash.js as it exceeds the max of 500KB.
Built API docs for GridApi
Built JSON file for GridSelectionApi
Built JSON file for GridFilterApi
Built JSON file for GridSortApi
Built JSON file for GridPaginationApi
Built JSON file for GridCsvExportApi
Built JSON file for GridScrollApi
✨  Done in 26.82s.

I'll work on it to make sure:

@cherniavskii
Copy link
Member Author

The problem

The problem started after merging #3219
Here's the output from CI:

https://app.circleci.com/pipelines/github/mui-org/material-ui-x/12204/workflows/8f208fd4-989c-43f5-a76f-d6512d9fa78e/jobs/71556?invite=true#step-110-2

yarn docs:api
yarn run v1.22.15
$ yarn docs:api:build
$ cross-env BABEL_ENV=development babel-node -i "/node_modules/(?!@mui)/" -x .ts,.tsx,.js ./docs/scripts/api/buildApi.ts
[BABEL] Note: The code generator has deoptimised the styling of /tmp/mui/node_modules/typescript/lib/typescript.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /tmp/mui/node_modules/lodash/lodash.js as it exceeds the max of 500KB.
Built API docs for GridApi
Built JSON file for GridSelectionApi
Built JSON file for GridFilterApi
Built JSON file for GridSortApi
Built JSON file for GridPaginationApi
Built JSON file for GridCsvExportApi
Built JSON file for GridScrollApi
Done in 66.00s.
CircleCI received exit code 0

Output from CI from previous commit
https://app.circleci.com/pipelines/github/mui-org/material-ui-x/12267/workflows/ff57373b-a217-4751-82b1-e9484345c0a2/jobs/71884?invite=true#step-110-2:

yarn run v1.22.15
$ yarn docs:api:build
$ cross-env BABEL_ENV=development babel-node -i "/node_modules/(?!@mui)/" -x .ts,.tsx,.js ./docs/scripts/api/buildApi.ts
[BABEL] Note: The code generator has deoptimised the styling of /tmp/mui/node_modules/typescript/lib/typescript.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /tmp/mui/node_modules/lodash/lodash.js as it exceeds the max of 500KB.
Built API docs for GridApi
Built JSON file for GridSelectionApi
Built JSON file for GridFilterApi
Built JSON file for GridSortApi
Built JSON file for GridPaginationApi
Built JSON file for GridCsvExportApi
Built JSON file for GridScrollApi
Built JSON file for GridEditRowApi
Built JSON file for GridRowGroupingApi
Built JSON file for GridColumnPinningApi
Built JSON file for GridPrintExportApi
Built JSON file for GridDisableVirtualizationApi
Built API docs for GridCellParams
Built API docs for GridRowParams
Built API docs for GridColDef
Built API docs for GridCsvExportOptions
Built API docs for GridPrintExportOptions
Built API docs for GridFilterModel
Built API docs for GridFilterItem
Built API docs for GridFilterOperator
Built API docs for DataGrid
Built API docs for DataGridPro
Built events file
Done in 84.60s.

The problem seems to be with parsing interface symbol for GridEditingApi:
https://github.com/mui-org/material-ui-x/blob/54b45448c8197b6061af39b9c581caaa50d5d912/docs/scripts/api/buildInterfacesDocumentation.ts#L75-L90

sourceFile is undefined in that case.

The fix

I've tried to fix it like this:

diff --git a/packages/grid/_modules_/grid/models/api/index.ts b/packages/grid/_modules_/grid/models/api/index.ts
index 6d7b53c64..a05256371 100644
--- a/packages/grid/_modules_/grid/models/api/index.ts
+++ b/packages/grid/_modules_/grid/models/api/index.ts
@@ -25,5 +25,5 @@ export * from './gridScrollApi';
 export * from './gridColumnPinningApi';
 export * from './gridVirtualScrollerApi';
 
-export type { GridEditingApi };
+export type { GridEditingApi } from './gridEditingApi';
 export type GridEditRowApi = GridEditingApi;

It does not throw the error anymore, but it modifies x-data-grid.exports.json in the following way:

diff --git a/scripts/x-data-grid.exports.json b/scripts/x-data-grid.exports.json
index 22c2bf742..a28ba7b68 100644
--- a/scripts/x-data-grid.exports.json
+++ b/scripts/x-data-grid.exports.json
@@ -65,7 +65,6 @@
   { "name": "GridCellClassFn", "kind": "TypeAlias" },
   { "name": "GridCellClassNamePropType", "kind": "TypeAlias" },
   { "name": "GridCellEditCommitParams", "kind": "Interface" },
-  { "name": "GridCellEditingApi", "kind": "Interface" },
   { "name": "GridCellEventLookup", "kind": "Interface" },
   { "name": "GridCellIdentifier", "kind": "TypeAlias" },
   { "name": "GridCellIndexCoordinates", "kind": "Interface" },
@@ -160,11 +159,11 @@
   { "name": "GridEditCellProps", "kind": "Interface" },
   { "name": "GridEditCellPropsParams", "kind": "Interface" },
   { "name": "GridEditCellValueParams", "kind": "Interface" },
-  { "name": "GridEditingApi", "kind": "Interface" },
-  { "name": "GridEditingSharedApi", "kind": "Interface" },
+  { "name": "GridEditingApi", "kind": "ExportSpecifier" },
   { "name": "GridEditInputCell", "kind": "ExportSpecifier" },
   { "name": "GridEditMode", "kind": "TypeAlias" },
   { "name": "GridEditModes", "kind": "Enum" },
+  { "name": "GridEditRowApi", "kind": "TypeAlias" },
   { "name": "GridEditRowProps", "kind": "TypeAlias" },
   { "name": "GridEditRowsModel", "kind": "TypeAlias" },
   { "name": "gridEditRowsStateSelector", "kind": "Variable" },
@@ -297,7 +296,6 @@
   { "name": "GridRowCount", "kind": "ExportSpecifier" },
   { "name": "gridRowCountSelector", "kind": "Variable" },
   { "name": "GridRowData", "kind": "TypeAlias" },
-  { "name": "GridRowEditingApi", "kind": "Interface" },
   { "name": "GridRowEntry", "kind": "TypeAlias" },
   { "name": "GridRowEventLookup", "kind": "Interface" },

I'm not sure if it's correct though.

@m4theushw can you take a look? Does this output make sense to you?

@m4theushw
Copy link
Member

sourceFile is undefined in that case.

To be more specific moduleSpecifier is null because this export declaration is not specifying from where it will be exported. Actually it shouldn't fall into this while. We could also improve to support export type { XXX }; but it might be trickery. You would need to iterate through all ImportDeclaration to find the correct one and from it get the module specifier. Debugging and using https://ts-ast-viewer.com/ you can see the types found by the compiler.

Does this output make sense to you?

It looks okay. We only need to make sure that GridEditRowApi is still exported.

@mui-bot
Copy link

mui-bot commented Feb 2, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 268.3 536.3 483 422.22 117.525
Sort 100k rows ms 375 897.7 812.3 753.1 194.413
Select 100k rows ms 201.9 343.3 262.3 274.1 48.804
Deselect 100k rows ms 123.8 289.8 194 196.26 56.096

Generated by 🚫 dangerJS against 4a582cd

@cherniavskii cherniavskii marked this pull request as ready for review February 2, 2022 13:27
@cherniavskii cherniavskii merged commit 8c1fcc7 into master Feb 2, 2022
@cherniavskii cherniavskii deleted the docs-api-silent-crash branch February 2, 2022 14:03
@cherniavskii cherniavskii changed the title [code] Fix docs:api silent crash [core] Fix docs:api silent crash Feb 2, 2022
@oliviertassinari oliviertassinari added the core Infrastructure work going on behind the scenes label Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants