Skip to content

Commit

Permalink
[docs] Show inherited components (#7846)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored and Sebastian Sebald committed Aug 23, 2017
1 parent b9cdff3 commit 5599e36
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/scripts/buildApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function buildDocs(options) {
reactAPI.name = path.parse(componentPath).name;
reactAPI.styles = styles;
reactAPI.pagesMarkdown = pagesMarkdown;
reactAPI.src = src;
let markdown;
try {
markdown = generateMarkdown(reactAPI);
Expand Down
22 changes: 22 additions & 0 deletions docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { parse as parseDoctrine } from 'doctrine';
import recast from 'recast';
import kebabCase from 'lodash/kebabCase';
import { pageToTitle } from './helpers';

function getDeprecatedInfo(type) {
Expand Down Expand Up @@ -196,6 +197,26 @@ you need to use the following style sheet name: \`${reactAPI.styles.name}\`.`
: '';
}

const inheritedComponentRegexp = /\/\/ @inheritedComponent (.*)/;

function generateInheritance(reactAPI) {
const inheritedComponent = reactAPI.src.match(inheritedComponentRegexp);

if (!inheritedComponent) {
return '';
}

const component = inheritedComponent[1];

return `
## Inheritance
The properties of the [<${component} />](/api/${kebabCase(
component,
)}) component are also available.
`;
}

function generateDemos(reactAPI) {
const pagesMarkdown = reactAPI.pagesMarkdown.reduce((accumulator, page) => {
if (page.components.includes(reactAPI.name)) {
Expand Down Expand Up @@ -224,6 +245,7 @@ export default function generateMarkdown(reactAPI: Object) {
`${generateProps(reactAPI)}\n` +
'Any other properties supplied will be spread to the root element.\n' +
`${generateClasses(reactAPI)}\n` +
`${generateInheritance(reactAPI)}` +
`${generateDemos(reactAPI)}\n`
);
}
4 changes: 4 additions & 0 deletions pages/api/app-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiAppBar`.

## Inheritance

The properties of the [<Paper />](/api/paper) component are also available.

## Demos

- [App Bar](/demos/app-bar)
4 changes: 4 additions & 0 deletions pages/api/bottom-navigation-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiBottomNavigationButton`.

## Inheritance

The properties of the [<ButtonBase />](/api/button-base) component are also available.

## Demos

- [Bottom Navigation](/demos/bottom-navigation)
4 changes: 4 additions & 0 deletions pages/api/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiButton`.

## Inheritance

The properties of the [<ButtonBase />](/api/button-base) component are also available.

## Demos

- [Buttons](/demos/buttons)
4 changes: 4 additions & 0 deletions pages/api/card-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiCardHeader`.

## Inheritance

The properties of the [<CardContent />](/api/card-content) component are also available.

## Demos

- [Cards](/demos/cards)
4 changes: 4 additions & 0 deletions pages/api/card.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
Any other properties supplied will be spread to the root element.


## Inheritance

The properties of the [<Paper />](/api/paper) component are also available.

## Demos

- [Cards](/demos/cards)
4 changes: 4 additions & 0 deletions pages/api/icon-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiIconButton`.

## Inheritance

The properties of the [<ButtonBase />](/api/button-base) component are also available.

## Demos

- [Buttons](/demos/buttons)
Expand Down
4 changes: 4 additions & 0 deletions pages/api/mobile-stepper.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiMobileStepper`.

## Inheritance

The properties of the [<Paper />](/api/paper) component are also available.

## Demos

- [Stepper](/demos/stepper)
4 changes: 4 additions & 0 deletions pages/api/tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ If using the `overrides` key of the theme as documented
[here](/customization/themes#customizing-all-instances-of-a-component-type),
you need to use the following style sheet name: `MuiTab`.

## Inheritance

The properties of the [<ButtonBase />](/api/button-base) component are also available.

## Demos

- [Tabs](/demos/tabs)
4 changes: 4 additions & 0 deletions pages/api/text-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
Any other properties supplied will be spread to the root element.


## Inheritance

The properties of the [<FormControl />](/api/form-control) component are also available.

## Demos

- [Autocomplete](/demos/autocomplete)
Expand Down
1 change: 1 addition & 0 deletions src/AppBar/AppBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// @inheritedComponent Paper

import React from 'react';
import type { Element } from 'react';
Expand Down
1 change: 1 addition & 0 deletions src/BottomNavigation/BottomNavigationButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow weak
// @inheritedComponent ButtonBase

import React, { Component, cloneElement, isValidElement } from 'react';
import PropTypes from 'prop-types';
Expand Down
1 change: 1 addition & 0 deletions src/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// @inheritedComponent ButtonBase

import React from 'react';
import type { Element } from 'react';
Expand Down
1 change: 1 addition & 0 deletions src/Card/Card.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// @inheritedComponent Paper

import React from 'react';
import Paper from '../Paper';
Expand Down
1 change: 1 addition & 0 deletions src/Card/CardHeader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// @inheritedComponent CardContent

import React from 'react';
import type { Element } from 'react';
Expand Down
1 change: 1 addition & 0 deletions src/GridList/GridListTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import withStyles from '../styles/withStyles';
export const styles = {
root: {
boxSizing: 'border-box',
flexShrink: 0,
},
tile: {
position: 'relative',
Expand Down
1 change: 1 addition & 0 deletions src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow weak
// @inheritedComponent ButtonBase

import React, { Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
Expand Down
1 change: 1 addition & 0 deletions src/MobileStepper/MobileStepper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow weak
// @inheritedComponent Paper

import React from 'react';
import PropTypes from 'prop-types';
Expand Down
1 change: 1 addition & 0 deletions src/Tabs/Tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow weak
// @inheritedComponent ButtonBase

import React, { Component, isValidElement } from 'react';
import PropTypes from 'prop-types';
Expand Down
1 change: 1 addition & 0 deletions src/TextField/TextField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// @inheritedComponent FormControl

import React from 'react';
import type { Element } from 'react';
Expand Down

0 comments on commit 5599e36

Please sign in to comment.