docs: Refactor docs to include parameters type

This commit is contained in:
Mani Maghsoudlou 2017-03-08 21:58:11 -08:00
parent e46b820dc5
commit fc5fca9be1
24 changed files with 100 additions and 20 deletions

View File

@ -2,12 +2,14 @@
Copy a file or directory. The directory can have contents. Like `cp -r`.
## Options:
- overwrite (boolean): overwrite existing file or directory, default is `true`. _Note that the copy operation will silently fail if you set this to `false` and the destination exists._ Use the `errorOnExist` option to change this behavior.
- errorOnExist (boolean): when `overwrite` is `false` and the destination exists, throw an error. Default is `false`.
- dereference (boolean): dereference symlinks, default is `false`.
- preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`.
- filter: Function to filter copied files. Return `true` to include, `false` to exclude. This can also be a RegExp, however this is deprecated (See [issue #239](https://github.com/jprichardson/node-fs-extra/issues/239) for background).
- `src` `<String>`
- `dest` `<String>`
- `options` `<Object>`
- `overwrite` `<boolean>`: overwrite existing file or directory, default is `true`. _Note that the copy operation will silently fail if you set this to `false` and the destination exists._ Use the `errorOnExist` option to change this behavior.
- `errorOnExist` `<boolean>`: when `overwrite` is `false` and the destination exists, throw an error. Default is `false`.
- `dereference` `<boolean>`: dereference symlinks, default is `false`.
- `preserveTimestamps` `<boolean>`: will set last modification and access times to the ones of the original source files, default is `false`.
- `filter` `<Function>`: Function to filter copied files. Return `true` to include, `false` to exclude. This can also be a RegExp, however this is deprecated (See [issue #239](https://github.com/jprichardson/node-fs-extra/issues/239) for background).
## Example:

View File

@ -2,12 +2,15 @@
Copy a file or directory. The directory can have contents. Like `cp -r`.
## Options:
- overwrite (boolean): overwrite existing file or directory, default is `true`. _Note that the copy operation will silently fail if you set this to `false` and the destination exists._ Use the `errorOnExist` option to change this behavior.
- errorOnExist (boolean): when `overwrite` is `false` and the destination exists, throw an error. Default is `false`.
- dereference (boolean): dereference symlinks, default is `false`.
- preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`.
- filter: Function to filter copied files. Return `true` to include, `false` to exclude. This can also be a RegExp, however this is deprecated (See [issue #239](https://github.com/jprichardson/node-fs-extra/issues/239) for background).
- `src` `<String>`
- `dest` `<String>`
- `options` `<Object>`
- `overwrite` `<boolean>`: overwrite existing file or directory, default is `true`. _Note that the copy operation will silently fail if you set this to `false` and the destination exists._ Use the `errorOnExist` option to change this behavior.
- `errorOnExist` `<boolean>`: when `overwrite` is `false` and the destination exists, throw an error. Default is `false`.
- `dereference` `<boolean>`: dereference symlinks, default is `false`.
- `preserveTimestamps` `<boolean>`: will set last modification and access times to the ones of the original source files, default is `false`.
- `filter` `<Function>`: Function to filter copied files. Return `true` to include, `false` to exclude. This can also be a RegExp, however this is deprecated (See [issue #239](https://github.com/jprichardson/node-fs-extra/issues/239) for background).
- `callback` `<Function>`
## Example:

View File

@ -4,6 +4,8 @@ Ensures that a directory is empty. Deletes directory contents if the directory i
**Alias:** `emptydirSync()`
- `dir` `<String>`
## Example:
```js

View File

@ -4,6 +4,9 @@ Ensures that a directory is empty. Deletes directory contents if the directory i
**Alias:** `emptydir()`
- `dir` `<String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -4,6 +4,8 @@ Ensures that the directory exists. If the directory structure does not exist, it
**Aliases:** `mkdirsSync()`, `mkdirpSync()`
- `dir` `<String>`
## Example:
```js

View File

@ -4,7 +4,8 @@ Ensures that the directory exists. If the directory structure does not exist, it
**Aliases:** `mkdirs()`, `mkdirp()`
**Sync:** `ensureDirSync()`, `mkdirsSync()`, `mkdirpSync()`
- `dir` `<String>`
- `callback` `<Function>`
## Example:

View File

@ -4,6 +4,8 @@ Ensures that the file exists. If the file that is requested to be created is in
**Alias:** `createFileSync()`
- `file` `<String>`
## Example:
```js

View File

@ -4,6 +4,9 @@ Ensures that the file exists. If the file that is requested to be created is in
**Alias:** `createFile()`
- `file` `<String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -2,6 +2,9 @@
Ensures that the link exists. If the directory structure does not exist, it is created.
- `srcpath` `<String>`
- `dstpath` `<String>`
## Example:
```js

View File

@ -2,6 +2,10 @@
Ensures that the link exists. If the directory structure does not exist, it is created.
- `srcpath` `<String>`
- `dstpath` `<String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -2,6 +2,10 @@
Ensures that the symlink exists. If the directory structure does not exist, it is created.
- `srcpath` `<String>`
- `dstpath` `<String>`
- `type` `<String>`
## Example:
```js

View File

@ -2,6 +2,11 @@
Ensures that the symlink exists. If the directory structure does not exist, it is created.
- `srcpath` `<String>`
- `dstpath` `<String>`
- `type` `<String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -2,8 +2,10 @@
Moves a file or directory, even across devices.
## Options:
- overwrite (boolean): overwrite existing file or directory, default is `false`
- `src` `<String>`
- `dest` `<String>`
- `options` `<Object>`
- `overwrite` `<boolean>`: overwrite existing file or directory, default is `false`.
## Example:
@ -13,6 +15,8 @@ const fs = require('fs-extra')
fs.moveSync('/tmp/somefile', '/tmp/does/not/exist/yet/somefile')
```
**Using `overwrite` option**
```js
const fs = require('fs-extra')

View File

@ -2,8 +2,11 @@
Moves a file or directory, even across devices.
## Options:
- overwrite (boolean): overwrite existing file or directory, default is `false`
- `src` `<String>`
- `dest` `<String>`
- `options` `<Object>`
- `overwrite` `<boolean>`: overwrite existing file or directory, default is `false`.
- `callback` `<Function>`
## Example:
@ -17,6 +20,8 @@ fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', err => {
})
```
**Using `overwrite` option**
```js
const fs = require('fs-extra')

View File

@ -2,6 +2,10 @@
Almost the same as `writeFileSync` (i.e. it [overwrites](http://pages.citebite.com/v2o5n8l2f5reb)), except that if the parent directory does not exist, it's created. `file` must be a file path (a buffer or a file descriptor is not allowed). `options` are what you'd pass to [`fs.writeFileSync()`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options).
- `file` `<String>`
- `data` `<String> | <Buffer> | <Uint8Array>`
- `options` `<Object> | <String>`
## Example:
```js

View File

@ -2,6 +2,11 @@
Almost the same as `writeFile` (i.e. it [overwrites](http://pages.citebite.com/v2o5n8l2f5reb)), except that if the parent directory does not exist, it's created. `file` must be a file path (a buffer or a file descriptor is not allowed). `options` are what you'd pass to [`fs.writeFile()`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback).
- `file` `<String>`
- `data` `<String> | <Buffer> | <Uint8Array>`
- `options` `<Object> | <String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -1,10 +1,14 @@
# outputJsonSync(file, data, [options])
# outputJsonSync(file, object, [options])
Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the directory does not exist, it's created.
`options` are what you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-jsonfile#writefilesyncfilename-obj-options).
**Alias:** `outputJSONSync()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
## Example:
```js

View File

@ -1,11 +1,14 @@
# outputJson(file, data, [options], callback)
# outputJson(file, object, [options], callback)
Almost the same as [`writeJson`](writeJson.md), except that if the directory does not exist, it's created.
`options` are what you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
**Alias:** `outputJSON()`
**Sync:** `outputJsonSync()`, `outputJSONSync()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
- `callback` `<Function>`
## Example:

View File

@ -5,6 +5,9 @@ that you'd pass to [`jsonFile.readFileSync`](https://github.com/jprichardson/nod
**Alias:** `readJSONSync()`
- `file` `<String>`
- `options` `<Object>`
## Example:
```js

View File

@ -5,6 +5,10 @@ that you'd pass to [`jsonFile.readFile`](https://github.com/jprichardson/node-js
**Alias:** `readJSON()`
- `file` `<String>`
- `options` `<Object>`
- `callback` `<Function>`
## Example:
```js

View File

@ -2,6 +2,8 @@
Removes a file or directory. The directory can have contents. Like `rm -rf`.
- `dir` `<String>`
## Example:
```js

View File

@ -2,6 +2,9 @@
Removes a file or directory. The directory can have contents. Like `rm -rf`.
- `dir` `<String>`
- `callback` `<Function>`
## Example:
```js

View File

@ -5,6 +5,10 @@ you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-
**Alias:** `writeJSONSync()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
## Example:
```js

View File

@ -5,6 +5,11 @@ you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-json
**Alias:** `writeJSON()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
- `callback` `<Function>`
## Example:
```js