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

suggestion for @option and @property and indenting #8

Open
tunnckoCore opened this issue Feb 7, 2016 · 0 comments
Open

suggestion for @option and @property and indenting #8

tunnckoCore opened this issue Feb 7, 2016 · 0 comments

Comments

@tunnckoCore
Copy link

consider following example

/**
 * > Strip all code comments, but not these that are
 * marked as "ignored" like (`//!` and `/*!`).
 * Pass `opts.preserve: false` to remove even them.
 *
 * **Example**
 *
 * ```js
 * const fs = require('fs')
 * const strip = require('acorn-strip-comments')
 *
 * const str = fs.readFileSync('./index.js', 'utf8')
 * const output = strip(str, {})
 * // => modified and cleaned string
 * ```
 *
 * @name  acornStripComments
 * @param  {String} `<input>` string from which to get comments
 * @param  {Object} `opts` optional options, passed to `acorn-extract-comments` and `acorn`
 * @param {Boolean} `opts.ast` if `true` the ast is added to the resulting array
 * @param {Boolean} `opts.line` if `false` get only block comments, default `true`
 * @param {Boolean} `opts.block` if `false` get line comments, default `true`
 * @param {Function} `opts.ignore` check function, default check comment starts with `!`
 * @param {Boolean} `opts.preserve` if `true` keep comments that are ignored (that pass the `opts.ignore` check)
 * @param {Boolean} `opts.locations` if `true` result will include `acorn/esprima` format comment location object
 * @param {Number} `opts.ecmaVersion` defaults to `6`, acorn parsing version
 * @return {String} modified string
 * @api public
 */
exports = module.exports = function stripAllComments (input, opts) {
  opts = extend({line: true, block: true, preserve: true}, opts)
  return acornStripComments(input, opts)
}

I think this should work as do it currently by using @option or @property, which btw both of them do some strange things with identation.

For example, doing it currently and correctly like that

/**
 * > Strip all code comments, but not these that are
 * marked as "ignored" like (`//!` and `/*!`).
 * Pass `opts.preserve: false` to remove even them.
 *
 * **Example**
 *
 * ```js
 * const fs = require('fs')
 * const strip = require('acorn-strip-comments')
 *
 * const str = fs.readFileSync('./index.js', 'utf8')
 * const output = strip(str, {})
 * // => modified and cleaned string
 * ```
 *
 * @name  acornStripComments
 * @param  {String} `<input>` string from which to get comments
 * @param  {Object} `opts` optional options, passed to `acorn-extract-comments` and `acorn`
 *   @option {Boolean} [opts] `ast` if `true` the ast is added to the resulting array
 *   @option {Boolean} [opts] `line` if `false` get only block comments, default `true`
 *   @option {Boolean} [opts] `block` if `false` get line comments, default `true`
 *   @option {Function} [opts] `ignore` check function, default check comment starts with `!`
 *   @option {Boolean} [opts] `preserve` if `true` keep comments that are ignored (that pass the `opts.ignore` check)
 *   @option {Boolean} [opts] `locations` if `true` result will include `acorn/esprima` format comment location object
 *   @option {Number} [opts] `ecmaVersion` defaults to `6`, acorn parsing version
 * @return {String} modified string
 * @api public
 */
exports = module.exports = function stripAllComments (input, opts) {
  opts = extend({line: true, block: true, preserve: true}, opts)
  return acornStripComments(input, opts)
}

adds options as sublist but with huge indent and adds one line more above the returns which is with same indent as options sublist

### [acornStripComments](index.js#L43)
> Strip all code comments, but not these that are marked as "ignored" like (`//!` and `/*!`). Pass `opts.preserve: false` to remove even them.

**Params**

* `<input>` **{String}**: string from which to get comments    
* `opts` **{Object}**: optional options, passed to `acorn-extract-comments` and `acorn`  
        - `ast` **{Boolean}**: if `true` the ast is added to the resulting array
        - `line` **{Boolean}**: if `false` get only block comments, default `true`
        - `block` **{Boolean}**: if `false` get line comments, default `true`
        - `ignore` **{Function}**: check function, default check comment starts with `!`
        - `preserve` **{Boolean}**: if `true` keep comments that are ignored (that pass the `opts.ignore` check)
        - `locations` **{Boolean}**: if `true` result will include `acorn/esprima` format comment location object
        - `ecmaVersion` **{Number}**: defaults to `6`, acorn parsing version

* `returns` **{String}**: modified string  
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

No branches or pull requests

1 participant