Skip to content

Commit

Permalink
license added & improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pvasek committed May 8, 2016
1 parent 412a347 commit 70dd448
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 29 deletions.
8 changes: 8 additions & 0 deletions LICENSE.md
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Pavel Vasek

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 changes: 49 additions & 1 deletion README.md
@@ -1,16 +1,64 @@
# react-docgen-typescript

Simple parser for react properties defined in typescript instead of propTypes.
A simple parser for react properties defined in typescript instead of propTypes.

It can be used with [react-styleguidist](https://github.com/sapegin/react-styleguidist).

## Installation

```
npm install --save-dev react-docgen-typescript
```

## react-styleguidist integration

Include following line in your `styleguide.config.js`:

```javascript
propsParser: require('react-docgen-typescript').parse
```
## Example

In the example folder you can see react-styleguidist integration.

The component [`Column.tsx`](./example/react-styleguidist-example/components/Column.tsx)

```javascript
import * as React from 'react';
import { Component } from 'react';

/**
* Column properties.
*/
export interface IColumnProps {
/** prop1 description */
prop1?: string;
/** prop2 description */
prop2: number;
/**
* prop3 description
*/
prop3: () => void;
/** prop4 description */
prop4: 'option1' | 'option2' | 'option3';
}

/**
* Form column.
*/
export class Column extends Component<IColumnProps, {}> {

render() {
return <div>Test</div>;
}
}

export default Column;
```

Will generate the following stylesheet:
![Stylesheet example](./stylesheet-example.png "Stylesheet example")


## Thanks
The integration with reac-styleguidist wouldn't be possible without [Vyacheslav Slinko](https://github.com/vslinko) pull request [#118](https://github.com/sapegin/react-styleguidist/pull/118) react-styleguidist.
24 changes: 12 additions & 12 deletions examples/react-styleguidist-example/components/Column.tsx
Expand Up @@ -5,25 +5,25 @@ import { Component } from 'react';
* Column properties.
*/
export interface IColumnProps {
/** simple class name */
className?: string;
/** super simple property */
prop1: number;
/** callback property */
prop2: () => void;
/** Enum props */
prop3: 'option1' | 'option2' | "option3";
/** prop1 description */
prop1?: string;
/** prop2 description */
prop2: number;
/**
* prop3 description
*/
prop3: () => void;
/** prop4 description */
prop4: 'option1' | 'option2' | 'option3';
}

/**
* Form column.
*/
export class Column extends Component<IColumnProps, {}> {

render() {
return (
<div>test</div>
);
return <div>Test</div>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/react-styleguidist-example/styleguide.config.js
Expand Up @@ -11,7 +11,7 @@ module.exports = {
},
resolver: require('react-docgen').resolver.findAllComponentDefinitions,

propsParser: require('../../temp/propTypesParser').parse,
propsParser: require('../../lib/propTypesParser').parse,

updateWebpackConfig: function(webpackConfig, env) {
var dir = path.resolve(__dirname, 'lib');
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "react-docgen-typescript",
"version": "1.0.0",
"version": "0.0.1",
"description": "",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
16 changes: 2 additions & 14 deletions src/__tests__/data/Column.tsx
@@ -1,6 +1,5 @@
import * as React from 'react';
import { Component, PropTypes, Children, EventHandler, KeyboardEvent } from 'react';
import * as classNames from 'classnames';
import { Component } from 'react';

/**
* Column properties.
Expand All @@ -22,20 +21,9 @@ export interface IColumnProps {
* Form column.
*/
export class Column extends Component<IColumnProps, {}> {

static propTypes: any = {
/** Additional class name that will be included on the element. */
className: PropTypes.string,
}

render() {

const { className } = this.props;
return (
<div className={classNames('st-col', className)}>
{this.props.children}
</div>
);
return <div>Test</div>;
}
}

Expand Down
Binary file added stylesheet-example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70dd448

Please sign in to comment.