Skip to content

Fix docs #1024

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

Merged
merged 5 commits into from
Nov 17, 2020
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"log": "react-native log-ios | grep 'ethan -'",
"docs:install": "(cd ./uilib-docs && rm -rf node_modules && rm -rf package-lock.json && npm install)",
"docs:deploy": "(cd ./uilib-docs && gatsby build --prefix-paths && gh-pages -d public --branch gh-pages)",
"docs:build": "(cd ./uilib-docs && gatsby build --prefix-paths)",
"docs:build": "(cd ./uilib-docs && npm install && gatsby build --prefix-paths && gh-pages -d public --branch gh-pages)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this deploy each time we build the docs (you removed that part from the notes)?
Also, is the CI calling npm run docs:build? Or should it be added to the build phase?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see I scratch that in the PR description.
At first I called docs:build from the build script.
But it seems to not work and require more investigation.. so I dropped it for now.
docs:build is not being used at the moment.. but that should be the script we will want to run in CI once we'll make it work.

"docs:develop": "(cd ./uilib-docs && gatsby develop)",
"bump:patch": "npm version patch",
"demo": "./scripts/demo.sh",
Expand Down
2 changes: 1 addition & 1 deletion src/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": ["@babel/preset-typescript" /* , "@babel/preset-react" */],
"plugins": ["babel-plugin-typescript-to-proptypes"],
"plugins": [["babel-plugin-typescript-to-proptypes", {"comments": true}]],
"compact": false,
"minified": false
}
9 changes: 6 additions & 3 deletions uilib-docs/configurations/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const componentsDocgenPlugin = [
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/../../src/components/`
path: `${__dirname}/../../src/components/`,
ignore: ['**/\*.tsx']
}
}
];
Expand All @@ -39,7 +40,8 @@ const incubatorComponentsDocgenPlugin = [
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/../../src/incubator/`
path: `${__dirname}/../../src/incubator/`,
ignore: ['**/\*.tsx']
}
}
];
Expand All @@ -49,7 +51,8 @@ const nativeComponentsDocgenPlugin = [
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/../../lib/components/`
path: `${__dirname}/../../lib/components/`,
ignore: ['**/\*.tsx']
}
}
];
Expand Down
2 changes: 1 addition & 1 deletion uilib-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Kyle Mathews <[email protected]>",
"dependencies": {
"classnames": "^2.2.6",
"gatsby": "2.23.22-static-query-template.8",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this on production?
We have this open bug: gatsbyjs/gatsby#26038
(They want us to validate something but I haven't gotten around to it...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work now.
The current docs were generated from this branch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it has been, locally I had Button and I don't see it in production.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe someone had deployed the docs from master and "broke" it :/
I just triggered docs again from this branch and now you can see the Button

"gatsby": "^2.0.0",
"gatsby-image": "^2.0.34",
"gatsby-plugin-layout": "^1.3.10",
"gatsby-plugin-manifest": "^2.0.24",
Expand Down
32 changes: 18 additions & 14 deletions uilib-docs/src/components/navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,35 @@ class Navbar extends Component {
getCurrentPage = () => {
if (typeof window !== 'undefined') {
const path = window.location.href;
return _.chain(path)
.split('/')
.filter(item => !_.isEmpty(item))
.last()
.value();

return _.flow(
p => _.split(p, '/'),
items => _.filter(items, i => !_.isEmpty(i)),
_.last,
)(path);
}
};

getMarkdownPages(data) {
const markdownPages = data.allFile.edges;
const pages = _.chain(markdownPages)
.map(({node}) => node.childMarkdownRemark.frontmatter)
.sortBy('index')
.value();
const pages = _.flow(pages =>
_.map(
pages,
({node}) => node.childMarkdownRemark.frontmatter,
items => _.sortBy(items, 'index')
)
)(markdownPages);

return pages;
}

getNavbarComponents(data) {
const components = data.allComponentMetadata.edges;
const filteredComponents = _.chain(components)
.filter(component => component.node.displayName !== 'IGNORE')
.uniqBy('node.displayName')
.sortBy('node.displayName')
.value();
const filteredComponents = _.flow(
components => _.filter(components, component => component.node.displayName !== 'IGNORE'),
components => _.uniqBy(components, 'node.displayName'),
components => _.sortBy(components, 'node.displayName')
)(components);

return filteredComponents;
}
Expand Down
8 changes: 4 additions & 4 deletions uilib-docs/src/templates/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export default class ComponentTemplate extends Component {
const {pageContext} = this.props;
const allComponents = pageContext.components;

const extendedComponents = _.chain(componentInfo.extends)
.replace(/ /g, '')
.split(',')
.value();
const extendedComponents = _.flow(
text => _.replace(text, / /g, ''),
text => _.split(text, ',')
)(componentInfo.extends);

return _.map(extendedComponents, (component, index) => {
const isLast = index === _.size(extendedComponents) - 1;
Expand Down