jonschlinkert / parse-comments

Parse JavaScript code comments. Works with block and line comments, and should work with CSS, LESS, SASS, or any language with the same comment formats.
https://github.com/jonschlinkert
MIT License
66 stars 23 forks source link

should detect `@example`, `@public` and `@private` #6

Open tunnckoCore opened 8 years ago

tunnckoCore commented 8 years ago

Currently it won't work if you just give @public, instead of @api public. Same applies for examples which works if it find **Example** in codeblock, but not works if find @example

this works as expected

/**
 * Will try to promisify `fn` with native Promise,
 * otherwise will use `Bluebird` or you can give
 * different promise module as `Prome`, for example `q` or `promise` or `pinkie`.
 *
 * **Example**
 *
 * ```js
 * const fs = require('fs')
 * const request = require('request')
 * const redolent = require('redolent')
 *
 * redolent(fs.readFile)('package.json', 'utf-8').then(data => {
 *   console.log(JSON.parse(data).name)
 * })
 *
 * // handles multiple arguments by default
 * redolent(request)('http://www.tunnckocore.tk/').then(result => {
 *   const [httpResponse, body] = result
 * })
 * ```
 *
 * @name   redolent
 * @param  {Function} `<fn>` callback-style function to promisify
 * @param  {Function} `[Prome]` custom Promise module to use, e.g. `Q`
 * @return {Function} promisified function
 * @api public
 */
module.exports = function redolent (fn, Prome) {
  if (typeof fn !== 'function') {
    throw new TypeError('redolent expect a function')
  }

I'm not sure if the issue is exactly for here, I can't remember but I think this module is behind verb-ish things and behind my apidocs-cli which use helper-apidocs.

Another ugly thing is that it adds one line from where codeblock ends, means that tools on top of this module will show and create link to line where is the if statement and not where the module.exports is which requires you to add empty line above the module.exports which in some cases aren't good. For example, recently I've just tried https://inch-ci.org/, which seems to read jsdoc comments to create "documentation analytics". So it assumes that the code comment starts right before the function or in case module.exports. It also assumes using @example.

tunnckoCore commented 8 years ago

@jonschlinkert bump.

I understand that adding +1 on where "the code starts" is because you write comments two lines above the code and not just right before the code as in above example, but.. That's not make sense for me, and I don't know why you do it like that, when docblocker (sublime) completes automatically code comments if you type "/**" just above/before the function/module.exports.

jonschlinkert commented 8 years ago

completes automatically code comments if you type "/**" just above/before the function/module.exports.

mine adds a line between the comment and code. we can easily change this in the refactor I'm working on.