Skip to content

Commit

Permalink
removing comment parser in favour of react-docgen. Library has been m…
Browse files Browse the repository at this point in the history
…ade react specific
  • Loading branch information
markmur committed Mar 26, 2017
1 parent 1a5f631 commit 4d1ebe0
Show file tree
Hide file tree
Showing 25 changed files with 3,689 additions and 405 deletions.
Binary file added .DS_Store
Binary file not shown.
60 changes: 60 additions & 0 deletions .eslintrc
@@ -0,0 +1,60 @@
{ "extends": ["eslint-config-airbnb"],
"env": {
"browser": false,
"node": true,
"mocha": true
},
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"import/default": 0,
"import/no-duplicates": 0,
"import/named": 0,
"import/namespace": 0,
"import/no-unresolved": 0,
"import/extensions": 0,
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": 0,
"comma-dangle": 0,
"indent": [2, 2, {"SwitchCase": 1}],
"no-alert": 0,
"strict": 0,
"arrow-parens": 0,
"class-methods-use-this": 0,
"newline-per-chained-call": 0,
"no-underscore-dangle": 0,
"no-trailing-spaces": 0,

// OFF
"global-require": 0,
"no-console": 0,
"eol-last": 0,

// ERRORS
"arrow-body-style": [2, "as-needed"],
"no-confusing-arrow": [2, {"allowParens": true}],
"import/no-named-as-default": 2,

// WARNINGS
"padded-blocks": 1,
"quotes": 1,
"quote-props": 1,
"semi": 1,
"no-multiple-empty-lines": 1,
"no-unused-vars": 1
},
"plugins": [
"import"
],
"settings": {
"import/parser": "babel-eslint",
"import/resolve": {
"moduleDirectory": ["node_modules", "."]
}
},
"globals": {
"__DEVELOPMENT__": true
}
}
62 changes: 41 additions & 21 deletions README.md
@@ -1,40 +1,60 @@
# Docky
Auto-Generate JavaScript documenation.
# <p align="center">Docky</p>

## CLI Usage

Install docky globally:
<p align="center">Auto-Generate JavaScript documenation.</p>

`npm install -g docky`

Run docky:

`docky <filename>.js`
## CLI Usage

## Programmatic Usage
Install docky globally:

`npm install --save-dev docky`
```shell
npm install -g docky
```

```javascript
const docky = require('docky');
Run docky on a single file or entire folder:

docky('filename.js', {
readme: '../README.md'
});
```shell
docky src/components/**/*.js
```

## Options
```shell

Usage: docky <file> [options]
```shell
Usage: docky <files> [options]

Options:

-h, --help output usage information
-v, --version output the version number
-r, --readme <readme> Specify a README file
-w, --watch run on file change


```

## Contributing

Docky uses Pug (formally known as Jade) and SASS for template generation. The files can be found under the `template` directory.

There is a `components` directory which contains some example React components for testing. You can run docky over the local folder by running:

```shell
npm run docs
```

or

```shell
./bin/docky.js components/**/*.js
```

To compile the sass, run:
```shell
npm run sass
```

## Scripts
Compile the template SASS:
`npm run sass`
Alternatively, you can add a `:watch` flag to auto-generate on change:

```shell
npm run sass:watch
```
29 changes: 29 additions & 0 deletions babylon.js
@@ -0,0 +1,29 @@
const babylon = require('babylon');

const options = {
sourceType: 'module',
strictMode: false,
locations: true,
ranges: true,
ecmaVersion: 7,
features: {
'es7.classProperties': true,
'es7.decorators': true,
'es7.comprehensions': true,
'es7.asyncFunctions': true,
'es7.exportExtensions': true,
'es7.trailingFunctionCommas': true,
'es7.objectRestSpread': true,
'es7.doExpressions': true,
'es7.functionBind': true,
},
plugins: ['jsx']
};

module.exports = {
parse(src) {
const file = babylon.parse(src, options);
file.program.comments = file.comments;
return file.program;
}
};
53 changes: 34 additions & 19 deletions bin/docky.js
@@ -1,23 +1,38 @@
#!/usr/bin/env node

var program = require('commander');
var package = require('../package.json');
var Docky = require('../index.js');

require('colors');

program
.version(package.version, '-v, --version')
.usage('<file> [options]')
.arguments('<file>')
.option('-r, --readme <readme>', 'Specify a README file')
.action(function (file, options) {
Docky(file, options);
})
.parse(process.argv);

if (!program.args.length) {
console.log('You must specify at least one file to run docky.'.red);
program.help();
const Docky = require('../index.js');

const options = {
watch: false
};

const flags = {
watch: ['-w', '--watch']
};

if (process.argv.length < 3) {
console.error('\nNo file(s) specified.\n'.red);
process.exit(1);
}

const args = process.argv.slice(2);

const files =
Object.keys(flags)
.map(flag => (
args.map(arg => {
if (flags[flag].indexOf(arg) > -1) {
options[flag] = true;
return null;
}

return arg;
}).filter(x => x)
))[0];

if (!files || !files.length) {
console.error('\nNo file(s) specified.\n'.red);
process.exit(1);
}

Docky(files, options);

0 comments on commit 4d1ebe0

Please sign in to comment.