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

[docs] Automatically generate API docs #1529

Merged
merged 58 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
96233ea
add description for all events
m4theushw May 6, 2021
eb92e48
update constant value
m4theushw May 6, 2021
7e7453c
typos
m4theushw May 6, 2021
4fe7c21
first implementation of the docs generator
m4theushw Apr 30, 2021
083fd67
wip
m4theushw May 3, 2021
b643312
cleanup
m4theushw May 3, 2021
09b2fad
prettier
m4theushw May 3, 2021
9e20f5b
generate GridColDef
m4theushw May 3, 2021
fbacfce
throw error if reflection was not found
m4theushw May 3, 2021
a7281e1
generate more pages
m4theushw May 3, 2021
0927892
add support for literal types
m4theushw May 3, 2021
365d9db
parse links in the interface description
m4theushw May 3, 2021
e42508a
escape description
m4theushw May 3, 2021
ca5570e
filter out properties with @ignore
m4theushw May 4, 2021
a1935c4
add helper to render indexedAccess
m4theushw May 4, 2021
d0b3ecd
generate events file
m4theushw May 5, 2021
cedd400
add events page
m4theushw May 5, 2021
f72fc5b
restore x-grid page
m4theushw May 5, 2021
170b2da
prettier
m4theushw May 5, 2021
41458a1
better organize pages
m4theushw May 5, 2021
630d2dd
use my fork
m4theushw May 5, 2021
d757f17
fix output path
m4theushw May 5, 2021
717b4c9
parse markdown in event descriptions
m4theushw May 6, 2021
f601416
generate docs
m4theushw May 6, 2021
81f4e0f
do not exclude node_modules/@material-ui
m4theushw May 6, 2021
91abb7c
small changes
m4theushw May 6, 2021
628646d
generate docs
m4theushw May 6, 2021
24ae4e3
adjust title
m4theushw May 10, 2021
9f440a4
do not add import for GridApi in @material-ui/data-grid
m4theushw May 10, 2021
676eeeb
add pro icon
m4theushw May 10, 2021
9646a18
fix event naming
m4theushw May 10, 2021
8023fd3
mark optional properties
m4theushw May 10, 2021
0a82883
show default column only if necessary
m4theushw May 10, 2021
8742a5c
update monorepo
m4theushw May 10, 2021
33db81a
generate docs
m4theushw May 10, 2021
7c9080a
move dependencies to devDependencies
m4theushw May 10, 2021
3f5ae84
Merge branch 'master' into generate-docs
m4theushw May 24, 2021
5cd6b8a
yarn
m4theushw May 24, 2021
0699a53
fix path
m4theushw May 24, 2021
d1c22e2
apply suggestion
m4theushw May 24, 2021
bbbfcd7
embed api into markdown
m4theushw May 25, 2021
1d70a7b
check if docs are up-to-date
m4theushw May 25, 2021
6fb8cae
generate JSON only for members of GridApi
m4theushw May 25, 2021
5c20c5c
Merge branch 'master' into generate-docs
m4theushw May 26, 2021
a5102cb
fix exports
m4theushw May 26, 2021
9d24bd0
generate docs
m4theushw May 26, 2021
1fdd8bf
Merge branch 'master' into generate-docs
m4theushw May 27, 2021
73d2132
hide descriptions on mobile
m4theushw May 27, 2021
1af0e1b
add missing default values
m4theushw May 27, 2021
e41721b
updates pages
m4theushw May 27, 2021
1900783
fix links in the API section
m4theushw May 28, 2021
be91ef9
Merge branch 'master' into generate-docs
m4theushw May 31, 2021
0608ace
update monorepo
m4theushw May 31, 2021
9bf4c92
generate docs
m4theushw Jun 1, 2021
5c3b2fe
remove conflict comment
m4theushw Jun 1, 2021
1a68240
add slash at end of urls
m4theushw Jun 1, 2021
edfbf87
generate api with slash at the end of urls
m4theushw Jun 1, 2021
074076a
formatting
m4theushw Jun 1, 2021
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
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ jobs:
- run:
name: Lint JSON
command: yarn jsonlint
- run:
name: Generate the documentation
command: yarn docs:api
- run:
name: '`yarn docs:api` changes committed?'
command: git diff --exit-code
test_browser:
<<: *defaults
docker:
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@material-ui/docs": "^4.0.0-beta.3",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/monorepo": "https://github.com/mui-org/material-ui.git#master",
"@material-ui/monorepo": "https://github.com/m4theushw/material-ui.git#generate-docs",
m4theushw marked this conversation as resolved.
Show resolved Hide resolved
"@trendmicro/react-interpolate": "^0.5.5",
"@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.0",
Expand Down
15 changes: 15 additions & 0 deletions docs/pages/api-docs/data-grid/grid-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';

const pageFilename = 'api/grid-api';
const requireRaw = require.context('!raw-loader!./', false, /\/grid-api\.md$/);

export default function Page({ docs }) {
return <MarkdownDocs docs={docs} />;
}

Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
96 changes: 96 additions & 0 deletions docs/pages/api-docs/data-grid/grid-api.md

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions docs/pages/api-docs/data-grid/grid-cell-params.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';

const pageFilename = 'api/grid-cell-params';
const requireRaw = require.context('!raw-loader!./', false, /\/grid-cell-params\.md$/);

export default function Page({ docs }) {
return <MarkdownDocs docs={docs} />;
}

Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
28 changes: 28 additions & 0 deletions docs/pages/api-docs/data-grid/grid-cell-params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# GridCellParams Interface

<p class="description">Object passed as parameter in the column <a href="/api/data-grid/grid-col-def">GridColDef</a> cell renderer.</p>

## Import

```js
import { GridCellParams } from '@material-ui/x-grid';
// or
import { GridCellParams } from '@material-ui/data-grid';
```

## Properties

| Name | Type | Description |
| :------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | :--------------------------------------------------------------- |
| <span class="prop-name">api</span> | <span class="prop-type">any</span> | GridApi that let you manipulate the grid. |
| <span class="prop-name">cellMode</span> | <span class="prop-type">GridCellMode</span> | The mode of the cell. |
| <span class="prop-name">colDef</span> | <span class="prop-type">any</span> | The column of the row that the current cell belongs to. |
| <span class="prop-name">field</span> | <span class="prop-type">string</span> | The column field of the cell that triggered the event |
| <span class="prop-name">formattedValue</span> | <span class="prop-type">GridCellValue</span> | The cell value formatted with the column valueFormatter. |
| <span class="prop-name">getValue</span> | <span class="prop-type">(id: GridRowId, field: string) =&gt; GridCellValue</span> | Get the cell value of a row and field. |
| <span class="prop-name">hasFocus</span> | <span class="prop-type">boolean</span> | If true, the cell is the active element. |
| <span class="prop-name">id</span> | <span class="prop-type">GridRowId</span> | The grid row id. |
| <span class="prop-name optional">isEditable<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | If true, the cell is editable. |
| <span class="prop-name">row</span> | <span class="prop-type">GridRowData</span> | The row model of the row that the current cell belongs to. |
| <span class="prop-name">tabIndex</span> | <span class="prop-type">0 \| -1</span> | the tabIndex value. |
| <span class="prop-name">value</span> | <span class="prop-type">GridCellValue</span> | The cell value, but if the column has valueGetter, use getValue. |
15 changes: 15 additions & 0 deletions docs/pages/api-docs/data-grid/grid-col-def.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';

const pageFilename = 'api/grid-col-def';
const requireRaw = require.context('!raw-loader!./', false, /\/grid-col-def\.md$/);

export default function Page({ docs }) {
return <MarkdownDocs docs={docs} />;
}

Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
41 changes: 41 additions & 0 deletions docs/pages/api-docs/data-grid/grid-col-def.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# GridColDef Interface

<p class="description">Column Definition interface.</p>

## Import

```js
import { GridColDef } from '@material-ui/x-grid';
// or
import { GridColDef } from '@material-ui/data-grid';
```

## Properties

| Name | Type | Default | Description |
| :---------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------- | :---------------------------------------------------------------------------------------------------- |
| <span class="prop-name optional">align<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">GridAlignment</span> | | Allows to align the column values in cells. |
| <span class="prop-name optional">cellClassName<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">GridCellClassNamePropType</span> | | Class name that will be added in cells for that column. |
| <span class="prop-name optional">description<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">string</span> | | The description of the column rendered as tooltip if the column header name is not fully displayed. |
| <span class="prop-name optional">disableClickEventBubbling<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | | Allows to disable the click event in cells. |
| <span class="prop-name optional">disableColumnMenu<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | | If `true`, the column menu is disabled for this column. |
| <span class="prop-name optional">editable<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | <span class="prop-default">true<br /></span> | If `true`, the cells of the column are editable. |
| <span class="prop-name">field</span> | <span class="prop-type">string</span> | | The column identifier. It's used to map with GridRowData values. |
| <span class="prop-name optional">filterOperators<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">GridFilterOperator[]</span> | | Allows setting the filter operators for this column. |
| <span class="prop-name optional">filterable<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | <span class="prop-default">true<br /></span> | If `true`, the column is filterable. |
| <span class="prop-name optional">flex<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">number</span> | | If set, it indicates that a column has fluid width. Range [0, ∞). |
| <span class="prop-name optional">headerAlign<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">GridAlignment</span> | | Header cell element alignment. |
| <span class="prop-name optional">headerClassName<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">string \| string[]</span> | | Class name that will be added in the column header cell. |
| <span class="prop-name optional">headerName<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">string</span> | | The title of the column rendered in the column header cell. |
| <span class="prop-name optional">hide<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | <span class="prop-default">false<br /></span> | If `true`, hide the column. |
| <span class="prop-name optional">hideSortIcons<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | | Toggle the visibility of the sort icons. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off topic

Shouldn't all the boolean types have a default value?

diff --git a/packages/grid/_modules_/grid/models/colDef/gridColDef.ts b/packages/grid/_modules_/grid/models/colDef/gridColDef.ts
index ea855319..808aa13c 100644
--- a/packages/grid/_modules_/grid/models/colDef/gridColDef.ts
+++ b/packages/grid/_modules_/grid/models/colDef/gridColDef.ts
@@ -113,6 +113,7 @@ export interface GridColDef {
   headerAlign?: GridAlignment;
   /**
    * Toggle the visibility of the sort icons.
+   * @default false
    */
   hideSortIcons?: boolean;
   /**

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

| <span class="prop-name optional">renderCell<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">(params: GridCellParams) =&gt; ReactElement&lt;any, string \| JSXElementConstructor&lt;any&gt;&gt;</span> | | Allows to override the component rendered as cell for this column. |
| <span class="prop-name optional">renderEditCell<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">(params: GridCellParams) =&gt; ReactElement&lt;any, string \| JSXElementConstructor&lt;any&gt;&gt;</span> | | Allows to override the component rendered in edit cell mode for this column. |
| <span class="prop-name optional">renderHeader<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">(params: GridColumnHeaderParams) =&gt; ReactElement&lt;any, string \| JSXElementConstructor&lt;any&gt;&gt;</span> | | Allows to render a component in the column header cell. |
| <span class="prop-name optional">resizable<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | <span class="prop-default">true<br /></span> | If `true`, the column is resizable. |
| <span class="prop-name optional">sortComparator<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">GridComparatorFn</span> | | A comparator function used to sort rows. |
| <span class="prop-name optional">sortable<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">boolean</span> | <span class="prop-default">true<br /></span> | If `true`, the column is sortable. |
| <span class="prop-name optional">type<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">string</span> | <span class="prop-default">'string'<br /></span> | Type allows to merge this object with a default definition [GridColDef](/api/data-grid/grid-col-def). |
| <span class="prop-name optional">valueFormatter<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">(params: GridValueFormatterParams) =&gt; GridCellValue</span> | | Function that allows to apply a formatter before rendering its value. |
| <span class="prop-name optional">valueGetter<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">(params: GridValueGetterParams) =&gt; GridCellValue</span> | | Function that allows to get a specific data instead of field to render in the cell. |
| <span class="prop-name optional">width<sup><abbr title="optional">?</abbr></sup></span> | <span class="prop-type">number</span> | <span class="prop-default">100<br /></span> | Set the width of the column. |
47 changes: 47 additions & 0 deletions docs/pages/api-docs/data-grid/grid-filter-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "GridFilterApi",
"description": "The filter API interface that is available in the grid apiRef.",
"properties": [
{
"name": "applyFilter",
"description": "Applies a GridFilterItem on alls rows. If no <code>linkOperator</code> is given, the &quot;and&quot; operator is used.",
"type": "(item: GridFilterItem, linkOperator?: GridLinkOperator) => void"
},
{
"name": "applyFilterLinkOperator",
"description": "Changes the GridLinkOperator used to connect the filters.",
"type": "(operator: GridLinkOperator) => void"
},
{
"name": "applyFilters",
"description": "Applies all filters on all rows.",
"type": "() => void"
},
{
"name": "deleteFilter",
"description": "Deletes a GridFilterItem.",
"type": "(item: GridFilterItem) => void"
},
{
"name": "getVisibleRowModels",
"description": "Returns a sorted <code>Map</code> containing only the visible rows.",
"type": "() => Map<GridRowId, GridRowData>"
},
{ "name": "hideFilterPanel", "description": "Hides the filter panel.", "type": "() => void" },
{
"name": "setFilterModel",
"description": "Sets the filter model to the one given by <code>model</code>.",
"type": "(model: GridFilterModelState) => void"
},
{
"name": "showFilterPanel",
"description": "Shows the filter panel. If <code>targetColumnField</code> is given, a filter for this field is also added.",
"type": "(targetColumnField?: string) => void"
},
{
"name": "upsertFilter",
"description": "Updates or inserts a GridFilterItem.",
"type": "(item: GridFilterItem) => void"
}
]
}
15 changes: 15 additions & 0 deletions docs/pages/api-docs/data-grid/grid-row-params.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';

const pageFilename = 'api/grid-row-params';
const requireRaw = require.context('!raw-loader!./', false, /\/grid-row-params\.md$/);

export default function Page({ docs }) {
return <MarkdownDocs docs={docs} />;
}

Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
Loading