Skip to content

Commit

Permalink
Remove examples from API/Components
Browse files Browse the repository at this point in the history
Summary:
These examples used to be part of the UIExplorer app, which will be renamed to RNTester in facebook#13606. These bits of code have not been treated as examples for a long time, and are actually part of our testing infra. Let's remove them altogether from the API/Components docs.
Closes facebook#13664

Differential Revision: D4960725

Pulled By: hramos

fbshipit-source-id: a4ec19b81d992aff89c0c93e35a1b80fbbd5e454
  • Loading branch information
hramos authored and thotegowda committed May 7, 2017
1 parent 30d0bdf commit 4ff1a70
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 93 deletions.
36 changes: 0 additions & 36 deletions website/layout/AutodocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,41 +813,6 @@ var Autodocs = React.createClass({
);
},

renderExample: function(example, metadata) {
if (!example) {
return;
}

return (
<div>
<HeaderWithGithub
title={example.title || 'Examples'}
level={example.title ? 4 : 3}
path={example.path}
metadata={metadata}
/>
<div className="example-container">
<Prism>
{example.content.replace(/^[\s\S]*?\*\//, '').trim()}
</Prism>
</div>
</div>
);
},

renderExamples: function(docs, metadata) {
if (!docs.examples || !docs.examples.length) {
return;
}

return (
<div>
{(docs.examples.length > 1) ? <Header level={3}>Examples</Header> : null}
{docs.examples.map(example => this.renderExample(example, metadata))}
</div>
);
},

render: function() {
var metadata = this.props.metadata;
var docs = JSON.parse(this.props.children);
Expand All @@ -867,7 +832,6 @@ var Autodocs = React.createClass({
{content}
<Footer path={metadata.path} />
{this.renderFullDescription(docs)}
{this.renderExamples(docs, metadata)}
<div className="docs-prevnext">
{metadata.previous && <a className="docs-prev" href={'docs/' + metadata.previous + '.html#content'}>&larr; Prev</a>}
{metadata.next && <a className="docs-next" href={'docs/' + metadata.next + '.html#content'}>Next &rarr;</a>}
Expand Down
57 changes: 0 additions & 57 deletions website/server/extractDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,50 +64,6 @@ function getPlatformFromPath(filepath) {
return CROSS_SUFFIX;
}

function getExamplePaths(componentName, componentPlatform) {
const componentExample = '../Examples/UIExplorer/js/' + componentName + 'Example.';
const pathsToCheck = [
componentExample + 'js',
componentExample + componentPlatform + '.js',
];
if (componentPlatform === CROSS_SUFFIX) {
pathsToCheck.push(
componentExample + IOS_SUFFIX + '.js',
componentExample + ANDROID_SUFFIX + '.js'
);
}
const paths = [];
pathsToCheck.map((p) => {
if (fs.existsSync(p)) {
paths.push(p);
}
});
return paths;
}

function getExamples(componentName, componentPlatform) {
const paths = getExamplePaths(componentName, componentPlatform);
if (paths) {
const examples = [];
paths.map((p) => {
const platform = p.match(/Example\.(.*)\.js$/);
let title = '';
if ((componentPlatform === CROSS_SUFFIX) && (platform !== null)) {
title = platform[1].toUpperCase();
}
examples.push(
{
path: p.replace(/^\.\.\//, ''),
title: title,
content: fs.readFileSync(p).toString(),
}
);
});
return examples;
}
return;
}

// Add methods that should not appear in the components documentation.
const methodsBlacklist = [
// Native methods mixin.
Expand All @@ -132,17 +88,6 @@ function filterMethods(method) {
return method.name[0] !== '_' && methodsBlacklist.indexOf(method.name) === -1;
}

// Determines whether a component should have a link to a runnable example

function isRunnable(componentName, componentPlatform) {
const paths = getExamplePaths(componentName, componentPlatform);
if (paths && paths.length > 0) {
return true;
} else {
return false;
}
}

// Hide a component from the sidebar by making it return false from
// this function
const HIDDEN_COMPONENTS = [
Expand Down Expand Up @@ -195,7 +140,6 @@ function componentsToMarkdown(type, json, filepath, idx, styles) {
if (styles) {
json.styles = styles;
}
json.examples = getExamples(componentName, componentPlatform);

if (json.methods) {
json.methods = json.methods.filter(filterMethods);
Expand All @@ -220,7 +164,6 @@ function componentsToMarkdown(type, json, filepath, idx, styles) {
'next: ' + next,
'previous: ' + previous,
'sidebar: ' + shouldDisplayInSidebar(componentName),
'runnable:' + isRunnable(componentName, componentPlatform),
'path:' + json.filepath,
'---',
JSON.stringify(json, null, 2),
Expand Down

0 comments on commit 4ff1a70

Please sign in to comment.