Skip to content
This repository was archived by the owner on Aug 10, 2018. It is now read-only.

Many new features (v1.1?) #3

Merged
merged 37 commits into from
Aug 5, 2015
Merged

Many new features (v1.1?) #3

merged 37 commits into from
Aug 5, 2015

Conversation

theogravity
Copy link
Contributor

screenshot

(That example code you see is actually auto-generated!)

We (@marcello3d and I) are trying to build an atomic framework for component development and decided that react-styleguide-generator + react-docgen would be great as a canvas for doing direct development and documentation.

In trying out RSG, we've had some of our own requirements, one of which was we wanted to be able to specify multiple examples for a single example component (rather than having repeats of the same component) and integrate react-docgen directly.

Additions made:

  • Adds react-docgen to document component props
  • Multiple examples can be defined in a single example component and is displayed via tabbed sections
  • Automatic example code generation using props for multiple examples if code is not filled in
  • Adds watchify support to reduce repackage times (if you wanted to use the guide as the platform to test out your components)
  • Adds grunt usage example
  • Adds bunyan logging (was sometimes hard to debug issues without logging)

How prop documentation works:

  • react-docgen parses these files and stores the generated JSON metadata in lib/rsg.js under this.reactPropMetas[<displayName>], which is exposed as window.RSG.propMetas
  • rendering occurs in app/components/Section/index.js using app/utils/react-docgen-to-md.js

How automatic code generation works:

  • The sample component defines styleguide.examples[], where properties tabTitle, props, and code can be defined.
  • If es6, styleguide.componentExample must be defined with a react component to use for rendering the concrete example
  • If code is not defined and props is, then renderAutoCode() is involed in app/components/Section/index.js
  • Attempts to figure out how to render the properties based on the property type and returns HTML that represents an example of the react component to use + the props that was used in the rendered concrete example
  • Children react components are not supported at the moment
  • react-docgen support example

properties

see src/Text input.js for example

  • Automatic code generation example

autodoc

see:
example/ReactDocgen/Text input example.js (es5)
example/components/Panels/Basic example.js (es6)

  • Refactored panel example to use multi-examples w/ automatic code generation

panel

Theo Gravity added 14 commits July 15, 2015 18:01
- Adds the reactDocGenRefId propType to reference a property meta
- Adds the examples propType to give a set of examples via a set of props
 - if you have defualt props but they're not defined in proptypes, will not give error
 - example props were doing typeof on the key rather than the value, resulting in improper type being returned
- Rewrote how code generation worked
- Update documentation
- Made sure es5/es6 examples works
@theogravity theogravity changed the title Many new features Many new features (v1.1?) Jul 20, 2015
"react": "^0.13.3",
"react-bootstrap": "^0.23.5",
"react-bootstrap": "0.23.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pinned down the react-bootstrap version here because the current examples (which I have not really touched) break on the latest version.

@theogravity
Copy link
Contributor Author

@pocotan001
Copy link
Owner

@theogravity That's great idea, thanks. But it does't work... 😢

Output is:

$ node -v

v0.10.33

$ npm run styleguide

> [email protected] styleguide /react-styleguide-generator
> node bin/rsg 'example/**/*.js' -c 'styleguide.json' -v | bunyan -o short

dyld: lazy symbol binding failed: Symbol not found: _node_module_register
  Referenced from: /react-styleguide-generator/node_modules/watchify/node_modules/chokidar/node_modules/fsevents/build/Release/fse.node
  Expected in: dynamic lookup

dyld: Symbol not found: _node_module_register
  Referenced from: /react-styleguide-generator/node_modules/watchify/node_modules/chokidar/node_modules/fsevents/build/Release/fse.node
  Expected in: dynamic lookup
$ node -v

v0.12.1

$ npm run styleguide

> [email protected] styleguide /react-styleguide-generator
> node bin/rsg 'example/**/*.js' -c 'styleguide.json' -v | bunyan -o short

[BABEL] Note: The code generator has deoptimised the styling of "/react-styleguide-generator/styleguide/src/contents-inter.js" as it exceeds the max of "100KB".
19:03:33.280Z ERROR rsg/rsg-lib: Unexpected token (2:7) while parsing /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js while parsing file: /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js
    SyntaxError: Unexpected token (2:7) while parsing /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js while parsing file: /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js
        at DestroyableTransform.end [as _flush] (/react-styleguide-generator/node_modules/browserify/node_modules/insert-module-globals/index.js:75:21)
        at DestroyableTransform.<anonymous> (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js:135:12)
        at DestroyableTransform.g (events.js:199:16)
        at DestroyableTransform.emit (events.js:104:17)
        at prefinish (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:450:12)
        at finishMaybe (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:458:7)
        at endWritable (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
        at DestroyableTransform.Writable.end (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
        at DestroyableTransform.onend (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
        at DestroyableTransform.g (events.js:199:16)
19:03:33.281Z ERROR rsg/bin: Unexpected token (2:7) while parsing /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js while parsing file: /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js
    SyntaxError: Unexpected token (2:7) while parsing /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js while parsing file: /react-styleguide-generator/example/node_modules/react-styleguide-generator/node_modules/es6-promise/lib/es6-promise.umd.js
        at DestroyableTransform.end [as _flush] (/react-styleguide-generator/node_modules/browserify/node_modules/insert-module-globals/index.js:75:21)
        at DestroyableTransform.<anonymous> (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js:135:12)
        at DestroyableTransform.g (events.js:199:16)
        at DestroyableTransform.emit (events.js:104:17)
        at prefinish (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:450:12)
        at finishMaybe (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:458:7)
        at endWritable (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
        at DestroyableTransform.Writable.end (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
        at DestroyableTransform.onend (/react-styleguide-generator/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
        at DestroyableTransform.g (events.js:199:16)

@theogravity
Copy link
Contributor Author

Hi, @pocotan001

It seems that what you're seeing is an OS X build tools issue. Is your command line tools up to date? I am on OS X Yosemite (10.10.4) with the latest version of the build tools.

http://railsapps.github.io/xcode-command-line-tools.html

http://stackoverflow.com/questions/22920497/git-mountain-lion-dyld-lazy-symbol-binding-failed-symbol-not-found-str

Also you will want to pull the project again as I've fixed a failing unit test.

@theogravity
Copy link
Contributor Author

@pocotan001

Here is my output, I used nvm to switch to v0.12.1 (was running iojs on 2.3.3) and removed/reinstalled node_modules:

theogravity:react-styleguide-generator theo$ node -v
v0.12.1
theogravity:react-styleguide-generator theo$ npm i
npm WARN engine [email protected]: wanted: {"node":"~0.10"} (current: {"node":"0.12.1","npm":"2.5.1"})

> [email protected] install /Volumes/sixfive-cs/react-styleguide-generator/node_modules/babel/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node: Finished
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/fse.node: Finished

> [email protected] install /Volumes/sixfive-cs/react-styleguide-generator/node_modules/watchify/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node: Finished
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/fse.node: Finished

> [email protected] install /Volumes/sixfive-cs/react-styleguide-generator/node_modules/cssnext/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node: Finished
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/fse.node: Finished

> [email protected] install /Volumes/sixfive-cs/react-styleguide-generator/node_modules/bunyan/node_modules/dtrace-provider
> node scripts/install.js


> [email protected] postinstall /Volumes/sixfive-cs/react-styleguide-generator/node_modules/cssnext/node_modules/caniuse-api
> node -e "require('shelljs/global');if(test('-d', 'dist'))exec('node dist/generate-features.js')"

[email protected] node_modules/object-assign

[email protected] node_modules/rimraf

[email protected] node_modules/minimist

[email protected] node_modules/marked

[email protected] node_modules/mustache

[email protected] node_modules/react-simpletabs
└── [email protected]

[email protected] node_modules/fs-extra
├── [email protected]
└── [email protected]

[email protected] node_modules/page
└── [email protected] ([email protected])

[email protected] node_modules/mocha
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected])

[email protected] node_modules/highlight.js

[email protected] node_modules/glob
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

[email protected] node_modules/react-bootstrap
└── [email protected]

[email protected] node_modules/uglify-js
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/gh-pages
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/react-docgen
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/browserify
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

[email protected] node_modules/react
└── [email protected] ([email protected], [email protected])

[email protected] node_modules/standard
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/watchify
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/babel-eslint
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/babelify
├── [email protected]
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/babel
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/bunyan
├── [email protected]
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected])

[email protected] node_modules/cssnext
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
theogravity:react-styleguide-generator theo$ npm run styleguide

> [email protected] styleguide /Volumes/sixfive-cs/react-styleguide-generator
> node bin/rsg 'example/**/*.js' -c 'styleguide.json' -v | bunyan -o short

20:10:47.251Z  INFO rsg/bin: Styleguide generation complete
    outputDir: /Volumes/sixfive-cs/react-styleguide-generator/styleguide

And using 0.10.33 (after removing node_modules and performing npm i):

theogravity:react-styleguide-generator theo$ node -v
v0.10.33
theogravity:react-styleguide-generator theo$ npm run styleguide

> [email protected] styleguide /Volumes/sixfive-cs/react-styleguide-generator
> node bin/rsg 'example/**/*.js' -c 'styleguide.json' -v | bunyan -o short

20:17:57.660Z  INFO rsg/bin: Styleguide generation complete
    outputDir: /Volumes/sixfive-cs/react-styleguide-generator/styleguide

@pocotan001
Copy link
Owner

@theogravity

I'd love to accept it but could you please consider dividing this PR?

I can see some of your code will directly improve this tool but some of them seem makes a little bit not-so-good from where I stand.

For example I like:

  • Multiple examples can be defined in a single example component and is displayed via tabbed sections
  • Automatic example code generation using props for multiple examples if code is not filled in
  • Adds watchify support to reduce repackage times (if you wanted to use the guide as the platform to test out your components)
  • Adds grunt usage example
  • Adds bunyan logging (was sometimes hard to debug issues without logging)

On the other hand I don't like:

  • Adds react-docgen support (es5 only) to document component props

We're hoping to keep this tool as simple as possible.
The thing that made us concerned when we actually tried the added features is the fact that the documentation procedures got complicated. In particular, we feel that the integration with react-docgen is making things more difficult.

@theogravity
Copy link
Contributor Author

@pocotan001 the developer for react-docgen has implemented es6 support today and will most likely do an updated release tomorrow, which will allow support for classes with RSG. If that is possible, can react-docgen be kept?

For the documentation procedures, is having to define the reactDocgen field is what is complex? When es6 support is in for react-docgen, we can probably remove the reactDocgen property from configuration.

Also how would you like the PR broken up?

Theo Gravity added 2 commits July 24, 2015 20:15
- Remove un-needed react-docgen specific examples
- Remove requirement of the rsg-mixin
@theogravity
Copy link
Contributor Author

@pocotan001 react-docgen has been updated to parse es6.

Changes I've made:

  • Removed rsg-mixin
  • Removed the ReactDocgen/ and src/ example to reduce confusion
  • Updated the Panel example to use react-docgen
  • react-docgen is enabled by default, and is not required to be specified in styleguide.json
  • Updated the readme to remove the es5/6 references since react-docgen now supports es6
  • Updated the PR text to reflect the changes
  • Slight performance enhancements

I hope this helps you!

screenshot

@ygoto3
Copy link
Collaborator

ygoto3 commented Jul 29, 2015

@theogravity

@pocotan001 and I (a collaborator of his) appreciate that you'd added es6 react-docgen support. We'd like to keep react-docgen.

Now you don't need to break up the PR, but we'd like you to make some modifications before we merge it.

  1. We'd like no tab to be displayed when examples field is not specified.
  2. We'd like you to update the samples in the README to emphasize that most of the fields you've added are optional. We'd like to keep samples as simple as possible.

Plus, @pocotan001 will probably make some minor changes to the CSS later, but when you finish these 2 modifications above, we would like to merge the PR.

@theogravity
Copy link
Contributor Author

@ygoto3 @pocotan001

  • Removed tabs if no examples array defined
  • Updated the readme and separated out the additional tabs into its own example

@ygoto3
Copy link
Collaborator

ygoto3 commented Aug 4, 2015

@theogravity Thank you for updating tabs and the readme.

We found a bug: When you move from / to Tooltip, the highlighter doesn't work (like the animated GIF image below). Could you fix it?

fixme

@theogravity
Copy link
Contributor Author

@ygoto3 @pocotan001 Fixed! Thanks for testing.

@pocotan001
Copy link
Owner

@theogravity Thank you for your prompt response.

@pocotan001
Copy link
Owner

The minor changes have been completed.

preview

I'll probably release this new features tomorrow 🍻

@marcello3d
Copy link

looks awesome! great work y'all

@theogravity
Copy link
Contributor Author

👍

pocotan001 added a commit that referenced this pull request Aug 5, 2015
@pocotan001 pocotan001 merged commit 273b373 into pocotan001:master Aug 5, 2015
@pocotan001
Copy link
Owner

@theogravity @marcello3d
I've released v1.1.0. Thanks for the PR!

@theogravity
Copy link
Contributor Author

yay! thanks

@theogravity theogravity deleted the react-docgen-impl branch December 14, 2015 00:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants