Skip to content
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

Remove examples from API/Components #13664

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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