-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2382 from oliviertassinari/doc-autogenerated
[Doc] Autogenerate the property description fo the AppBar
- Loading branch information
Showing
16 changed files
with
1,002 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ icon-builder/jsx | |
|
||
# Exclude IDE project folders | ||
.idea | ||
*.sublime-project | ||
*.sublime-workspace | ||
|
||
# OS files | ||
.DS_STORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import AppBar from 'material-ui/lib/app-bar'; | ||
|
||
const AppBarExampleIcon = React.createClass({ | ||
render() { | ||
return ( | ||
<AppBar | ||
title="Title" | ||
iconClassNameRight="muidocs-icon-navigation-expand-more" | ||
/> | ||
); | ||
}, | ||
}); | ||
|
||
export default AppBarExampleIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import AppBar from 'material-ui/lib/app-bar'; | ||
import IconButton from 'material-ui/lib/icon-button'; | ||
import NavigationClose from 'material-ui/lib/svg-icons/navigation/close'; | ||
import FlatButton from 'material-ui/lib/flat-button'; | ||
|
||
function handleTouchTap() { | ||
alert('onTouchTap triggered on the title component'); | ||
} | ||
|
||
const styles = { | ||
title: { | ||
cursor: 'pointer', | ||
}, | ||
}; | ||
|
||
const AppBarExampleIconButton = React.createClass({ | ||
render() { | ||
return ( | ||
<AppBar | ||
title={<span style={styles.title} onTouchTap={handleTouchTap}>Title</span>} | ||
iconElementLeft={<IconButton><NavigationClose /></IconButton>} | ||
iconElementRight={<FlatButton label="Save" />} | ||
/> | ||
); | ||
}, | ||
}); | ||
|
||
export default AppBarExampleIconButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import AppBar from 'material-ui/lib/app-bar'; | ||
import IconButton from 'material-ui/lib/icon-button'; | ||
import NavigationClose from 'material-ui/lib/svg-icons/navigation/close'; | ||
import IconMenu from 'material-ui/lib/menus/icon-menu'; | ||
import MoreVertIcon from 'material-ui/lib/svg-icons/navigation/more-vert'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
const AppBarExampleIconMenu = React.createClass({ | ||
render() { | ||
return ( | ||
<AppBar | ||
title="Title" | ||
iconElementLeft={<IconButton><NavigationClose /></IconButton>} | ||
iconElementRight={ | ||
<IconMenu | ||
iconButtonElement={ | ||
<IconButton><MoreVertIcon /></IconButton> | ||
} | ||
targetOrigin={{horizontal:'right', vertical:'top'}} | ||
anchorOrigin={{horizontal:'right', vertical:'top'}} | ||
> | ||
<MenuItem primaryText="Refresh" /> | ||
<MenuItem primaryText="Help" /> | ||
<MenuItem primaryText="Sign out" /> | ||
</IconMenu> | ||
} | ||
/> | ||
); | ||
}, | ||
}); | ||
|
||
export default AppBarExampleIconMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## AppBar | ||
|
||
App bars are a collection of components placed as a static header for an application. | ||
It is used for navigation, search branding, and actions. | ||
An app bar is also referred to as the primary toolbar or action bar for Android. | ||
|
||
### Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import marked from 'marked'; | ||
import PureRenderMixin from 'react-addons-pure-render-mixin'; | ||
|
||
require('./mui-github-markdown.css'); | ||
|
||
const styles = { | ||
root: { | ||
marginBottom: 14, | ||
padding: '0 10px', | ||
}, | ||
}; | ||
|
||
const MarkdownElement = React.createClass({ | ||
propTypes: { | ||
text: React.PropTypes.string, | ||
}, | ||
mixins: [ | ||
PureRenderMixin, | ||
], | ||
getDefaultProps() { | ||
return { | ||
text: '', | ||
}; | ||
}, | ||
|
||
componentWillMount() { | ||
marked.setOptions({ | ||
gfm: true, | ||
tables: true, | ||
breaks: false, | ||
pedantic: false, | ||
sanitize: false, | ||
smartLists: true, | ||
smartypants: false, | ||
highlight: function(code, lang) { | ||
return require('highlight.js').highlight(lang, code).value; | ||
}, | ||
}); | ||
}, | ||
|
||
render() { | ||
const { | ||
text, | ||
} = this.props; | ||
|
||
/* eslint-disable */ | ||
return ( | ||
<div | ||
style={styles.root} | ||
className="markdown-body" | ||
dangerouslySetInnerHTML={{__html: marked(text)}} | ||
/> | ||
); | ||
/* eslint-enable */ | ||
}, | ||
}); | ||
|
||
export default MarkdownElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import {parse} from 'react-docgen'; | ||
import PureRenderMixin from 'react-addons-pure-render-mixin'; | ||
import MarkdownElement from './MarkdownElement'; | ||
|
||
function generatePropType(type) { | ||
switch (type.name) { | ||
case 'func': | ||
return 'function'; | ||
|
||
case 'custom': | ||
return type.raw; | ||
|
||
default: | ||
return type.name; | ||
} | ||
} | ||
|
||
const PropTypeDescription = React.createClass({ | ||
propTypes: { | ||
code: React.PropTypes.string, | ||
}, | ||
mixins: [ | ||
PureRenderMixin, | ||
], | ||
render() { | ||
const { | ||
code, | ||
} = this.props; | ||
|
||
let text = `### Properties | ||
| Name | Type | Default | Description| | ||
|:-----|:-----|:-----|:-----|\n`; | ||
|
||
const componentInfo = parse(code); | ||
|
||
for (let key in componentInfo.props) { | ||
const prop = componentInfo.props[key]; | ||
|
||
let defaultValue = ''; | ||
|
||
if (prop.defaultValue) { | ||
defaultValue = prop.defaultValue.value; | ||
} | ||
|
||
const description = (prop.required ? '**required**' : '*optional*') + | ||
'. ' + prop.description.replace(/\n/g, '<br>'); | ||
|
||
text += `| ${key} | ${generatePropType(prop.type)} |`; | ||
text += `${defaultValue} |${description} |\n`; | ||
} | ||
|
||
return ( | ||
<MarkdownElement text={text} /> | ||
); | ||
}, | ||
}); | ||
|
||
export default PropTypeDescription; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.