-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Autogenerate the property description for the AppBar #2382
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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; |
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; |
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; |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be here? I mean... shouln't it be where this file is read from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get it. What do you mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Examples is inside the readme file, that means every read me MUST end with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the best practice would be to add a |
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; |
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too maybe?