mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 23:55:23 +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>
|
<Marked>
|
||||||
{content.description}
|
{content.description}
|
||||||
</Marked>
|
</Marked>
|
||||||
<H level={3}>Props</H>
|
|
||||||
|
<HeaderWithGithub
|
||||||
|
title="Props"
|
||||||
|
path={content.filepath}
|
||||||
|
/>
|
||||||
{this.renderProps(content.props, content.composes)}
|
{this.renderProps(content.props, content.composes)}
|
||||||
</div>
|
</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({
|
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() {
|
render: function() {
|
||||||
var metadata = this.props.metadata;
|
var metadata = this.props.metadata;
|
||||||
var docs = JSON.parse(this.props.children);
|
var docs = JSON.parse(this.props.children);
|
||||||
@ -264,9 +300,7 @@ var Autodocs = React.createClass({
|
|||||||
<a id="content" />
|
<a id="content" />
|
||||||
<h1>{metadata.title}</h1>
|
<h1>{metadata.title}</h1>
|
||||||
{content}
|
{content}
|
||||||
<Marked>
|
{this.renderFullDescription(docs)}
|
||||||
{docs.fullDescription}
|
|
||||||
</Marked>
|
|
||||||
<div className="docs-prevnext">
|
<div className="docs-prevnext">
|
||||||
{metadata.previous && <a className="docs-prev" href={metadata.previous + '.html#content'}>← Prev</a>}
|
{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>}
|
{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.fullDescription = fs.readFileSync(docFilePath).toString();
|
||||||
}
|
}
|
||||||
json.type = type;
|
json.type = type;
|
||||||
|
json.filepath = filepath.replace(/^\.\.\//, '');
|
||||||
|
json.componentName = componentName;
|
||||||
if (styles) {
|
if (styles) {
|
||||||
json.styles = styles;
|
json.styles = styles;
|
||||||
}
|
}
|
||||||
|
@ -964,6 +964,11 @@ div[data-twttr-id] iframe {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-github {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: normal;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
||||||
display: none;
|
display: none;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user