mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
Add Edit on Github link on pages. cc @DMortens
This commit is contained in:
parent
ed7b5cb187
commit
536b4669a3
@ -145,7 +145,11 @@ var ComponentDoc = React.createClass({
|
||||
<Marked>
|
||||
{content.description}
|
||||
</Marked>
|
||||
<H level={3}>Props</H>
|
||||
|
||||
<HeaderWithGithub
|
||||
title="Props"
|
||||
path={content.filepath}
|
||||
/>
|
||||
{this.renderProps(content.props, content.composes)}
|
||||
</div>
|
||||
);
|
||||
@ -248,7 +252,39 @@ var APIDoc = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
var HeaderWithGithub = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<H level={3} toSlug={this.props.title}>
|
||||
<a
|
||||
className="edit-github"
|
||||
href={'https://github.com/facebook/react-native/blob/master/' + this.props.path}>
|
||||
Edit on GitHub
|
||||
</a>
|
||||
{this.props.title}
|
||||
</H>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var Autodocs = React.createClass({
|
||||
renderFullDescription: function(docs) {
|
||||
if (!docs.fullDescription) {
|
||||
return;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<HeaderWithGithub
|
||||
title="Description"
|
||||
path={'docs/' + docs.componentName + '.md'}
|
||||
/>
|
||||
<Marked>
|
||||
{docs.fullDescription}
|
||||
</Marked>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var metadata = this.props.metadata;
|
||||
var docs = JSON.parse(this.props.children);
|
||||
@ -264,9 +300,7 @@ var Autodocs = React.createClass({
|
||||
<a id="content" />
|
||||
<h1>{metadata.title}</h1>
|
||||
{content}
|
||||
<Marked>
|
||||
{docs.fullDescription}
|
||||
</Marked>
|
||||
{this.renderFullDescription(docs)}
|
||||
<div className="docs-prevnext">
|
||||
{metadata.previous && <a className="docs-prev" href={metadata.previous + '.html#content'}>← Prev</a>}
|
||||
{metadata.next && <a className="docs-next" href={metadata.next + '.html#content'}>Next →</a>}
|
||||
|
@ -33,6 +33,8 @@ function componentsToMarkdown(type, json, filepath, i, styles) {
|
||||
json.fullDescription = fs.readFileSync(docFilePath).toString();
|
||||
}
|
||||
json.type = type;
|
||||
json.filepath = filepath.replace(/^\.\.\//, '');
|
||||
json.componentName = componentName;
|
||||
if (styles) {
|
||||
json.styles = styles;
|
||||
}
|
||||
|
@ -964,6 +964,11 @@ div[data-twttr-id] iframe {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.edit-github {
|
||||
font-size: 15px;
|
||||
font-weight: normal;
|
||||
float: right;
|
||||
}
|
||||
|
||||
#content {
|
||||
display: none;
|
||||
|
Loading…
x
Reference in New Issue
Block a user