Skip to content

Commit

Permalink
[Docs] Remove Transforms from sidebar, add to Style
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Vatne committed May 7, 2015
1 parent 731d4a0 commit debd5b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
9 changes: 5 additions & 4 deletions docs/Style.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ var List = React.createClass({

You can checkout latest support of CSS Properties in following Links.

- [View Properties](http://facebook.github.io/react-native/docs/view.html#style)
- [Image Properties](http://facebook.github.io/react-native/docs/image.html#style)
- [Text Properties](http://facebook.github.io/react-native/docs/text.html#style)
- [Flex Properties](http://facebook.github.io/react-native/docs/flexbox.html#content)
- [View Properties](/react-native/docs/view.html#style)
- [Image Properties](/react-native/docs/image.html#style)
- [Text Properties](/react-native/docs/text.html#style)
- [Flex Properties](/react-native/docs/flexbox.html#content)
- [Transform Properties](/react-native/docs/transforms.html#content)
5 changes: 4 additions & 1 deletion website/server/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ function execute() {
try { value = JSON.parse(value); } catch(e) { }
metadata[key] = value;
}
metadatas.files.push(metadata);

if (metadata.sidebar !== false) {
metadatas.files.push(metadata);
}

if (metadata.permalink.match(/^https?:/)) {
return;
Expand Down
43 changes: 35 additions & 8 deletions website/server/extractDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ function getExample(componentName) {
};
}

// Hide a component from the sidebar by making it return false from
// this function
function shouldDisplayInSidebar(componentName) {
if (componentName === 'Transforms') {
return false;
}

return true;
}

function getNextComponent(i) {
var next;
var filepath = all[i];

if (all[i + 1]) {
var nextComponentName = getNameFromPath(all[i + 1]);

if (shouldDisplayInSidebar(nextComponentName)) {
return slugify(nextComponentName);
} else {
return getNextComponent(i + 1);
}
} else {
return 'network';
}
}

function componentsToMarkdown(type, json, filepath, i, styles) {
var componentName = getNameFromPath(filepath);

Expand All @@ -59,16 +86,19 @@ function componentsToMarkdown(type, json, filepath, i, styles) {
}
json.example = getExample(componentName);

// Put Flexbox into the Polyfills category
var category = (type === 'style' ? 'Polyfills' : type + 's');
var next = getNextComponent(i);

var res = [
'---',
'id: ' + slugify(componentName),
'title: ' + componentName,
'layout: autodocs',
'category: ' + (type === 'style' ? 'Polyfills' : type + 's'),
'category: ' + category,
'permalink: docs/' + slugify(componentName) + '.html',
'next: ' + (all[i + 1] ?
slugify(getNameFromPath(all[i + 1])) :
'network'),
'next: ' + next,
'sidebar: ' + shouldDisplayInSidebar(componentName),
'---',
JSON.stringify(json, null, 2),
].filter(function(line) { return line; }).join('\n');
Expand Down Expand Up @@ -107,16 +137,13 @@ function renderStyle(filepath) {
[docgen.handlers.propTypeHandler]
);

// Remove deprecated style props
// Remove deprecated transform props from docs
if (filepath === "../Libraries/StyleSheet/TransformPropTypes.js") {
['rotation', 'scaleX', 'scaleY', 'translateX', 'translateY'].forEach(function(key) {
delete json['props'][key];
});
}


// console.log(json);

return componentsToMarkdown('style', json, filepath, n++);
}

Expand Down
2 changes: 1 addition & 1 deletion website/server/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ glob('src/**/*.*', function(er, files) {
return;
}
if (response.statusCode != 200) {
reject(new Error('Status ' + response.statusCode + ':\n' + body));
reject(new Error('Status ' + response.statusCode + ':\n' + body));
return;
}
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
Expand Down

0 comments on commit debd5b0

Please sign in to comment.