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

feat: allows evergreen documentation #186

Merged
merged 2 commits into from
Apr 16, 2020
Merged

feat: allows evergreen documentation #186

merged 2 commits into from
Apr 16, 2020

Conversation

zero0Halo
Copy link
Contributor

@zero0Halo zero0Halo commented Feb 8, 2020

chore(package.json): new script, build:for-docs

chore(docs/package.json): local reference to anchor build

fix(docs/Page, docs/index): ThemeProvider pulled from xstyled

Before submitting a pull request, please make sure the following is done:

I have done all of the following:

  • Added a top level class to all my components '.anchor-[COMPONENT NAME]'.
  • Used conventional commits for all work.
  • Tested my solution on Mobile & Tablet.
  • Wrote unit tests for states and all behavior (npm test) and passed coverage thresholds.
  • Updated snapshots for all permutations (npm test -- -u).
  • Accounted for hover, focus, blur, visited, & error states because they are not edge cases.
  • Created TODOs for known edge cases.
  • Documented all of my changes (inline & doc site).
  • Made sure that all accessibility errors are resolved.
  • Added stories with knobs for all possible configurations.
  • De-linted and ran prettier (npm run pretty) on my code.
  • Added name to OWNERS file for all new components
  • If adding a new component, add its export to the rollup config
  • package.json version is bumped (if necessary)

Outline your feature or bug-fix below

What?
Makes the @retailmenot/anchor reference in the docs site point to a local build, making it possible for the doc site to be synced with Anchor.

How?
yarn build works as before, except as a last step it also calls a new script, build:for-docs. This copies the esm, commonjs, ts folders, and package.json into an untracked folder, for-docs. Running yarn within the docs folder will then pull in this local build of Anchor from the for-docs folder.

Why?
I tried a lot before landing on this solution. Trying to locally add Anchor from docs did not work without the intermediate step of copying the npm files to the for-docs folder. Gatsby would always choke and die because the entire contents of Anchor would be imported rather than just the necessary esm, commonjs, ts and package.json.

I tried modifying our build process in Anchor to output to a build folder and instead pull that in, but that approach doesn't work because package.json would still need to exist in that build folder, and the pathing would get messed up (i.e. within Anchor it would correctly point to /build/esm/ etc, but within the build folder the copied package.json would not have a build/esm path.).

Creating an untracked for-docs lets us keep the current build process and make everything transparent. The only step to remember to take is when done working on a component, running yarn build before going into docs and running gatsby develop/build.

Gotchas
The lint step on Travis is failing because the for-docs folder is untracked which causes the yarn build process w/in the docs folder to fail. Adding steps to run build from Anchor first should take care of that, I think.

The only other one I've run into so far is that somehow this local reference is causing some small TypeScript highlight warnings/errors w/in the doc site. They're very minor and it doesn't prevent building. With a little more time, we can probably sort that out.

@zero0Halo
Copy link
Contributor Author

Fixed issue with Travis build failing.

@zero0Halo
Copy link
Contributor Author

Steps to try this out for the first time:

cd anchor
yarn build
cd docs
yarn
gatsby develop

Then if you want make a change to an Anchor component, to see it reflected on the doc site:

yarn build
cd docs
rm -rf node_modules
yarn
gatsby develop

Because this local folder is treated like any other package, that means that if you want to make a change to Anchor you'll have to either upgrade the version number, or delete the @retailmenot/anchor folder in the doc site's node_modules folder.

chore(package.json): new script, build:for-docs

chore(docs/package.json): local reference to anchor build

fix(docs/Page, docs/index): ThemeProvider pulled from xstyled

chore: added build step
@zero0Halo zero0Halo marked this pull request as ready for review April 8, 2020 21:23
@zero0Halo zero0Halo changed the title [WIP] feat: allows evergreen documentation feat: allows evergreen documentation Apr 8, 2020
Copy link
Contributor

@brandonlilly brandonlilly left a comment

Choose a reason for hiding this comment

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

Neat!

@zero0Halo zero0Halo merged commit 0ba6c14 into master Apr 16, 2020
@zero0Halo zero0Halo deleted the feat/evergreen-docs branch April 16, 2020 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants