cbou / markdox

Markdox is a documentation generator based on Dox and Markdown. It parse Javascript and even Coffeescript.
http://cbou.github.com/markdox
230 stars 27 forks source link

Method name appears twice #15

Closed IonicaBizau closed 10 years ago

IonicaBizau commented 10 years ago

I have this test content:

/**
 * foo
 * foo's description
 *
 * @name foo
 * @function
 * @param {String} a Foo
 * @param {String} b Another foo
 * @param {Number} c Some number
 * @param {Object} d Just another foo
 * @return {Boolean} Returns true
 */
function foo (a, b, c, d) {
    return true;
}

markdox generated a markdown file containing:

<!-- Start test.js -->

## foo(a, b, c, d)

foo
foo's description

### Params: 

* **String** *a* Foo
* **String** *b* Another foo
* **Number** *c* Some number
* **Object** *d* Just another foo

### Return:

* **Boolean** Returns true

<!-- End test.js -->

I don't want \nfoo there. Instead of:

## foo(a, b, c, d)

foo

I need

## foo(a, b, c, d)

Is there any way to configure markdox to do this?

cbou commented 10 years ago

You could write a custom template that remove the first line of the comment when it the matches the function name...

IonicaBizau commented 9 years ago

@cbou Can you help me writing one?

IonicaBizau commented 9 years ago

I did it!

<? docfiles.forEach(function(doc) { -?>
  <? doc.javadoc.forEach(function(comment) { -?>
    <? if (!comment.ignore) { -?>
      <? if (comment.name) { -?>
        <? if (comment.isMethod || comment.isFunction) { -?>
          ## `<?= comment.name -?>(<?= comment.paramStr -?>)`
        <? } else { -?>
          ## <?= comment.name ?>
        <? } -?>
      <? } -?>

        <? if (comment.description.split("\n")[0] == comment.name) { -?>
            <? comment.description = comment.description.split("\n").slice(1).join("\n"); -?>
        <? } -?>
        <?= comment.description -?>

        <? if (comment.deprecated) { ?>
          **Deprecated**
        <? } ?>

        <? if (comment.author) { ?>
          Author: <?- comment.author ?>
        <? } ?>

        <? if (comment.version) { ?>
          Version: <?= comment.version ?>
        <? } ?>

        <? if (comment.see) { ?>
          See: <?= comment.see ?>
        <? } ?>

      <? if (comment.paramTags.length > 0) { ?>
        ### Params: <? comment.paramTags.forEach(function(paramTag) { ?>
          * **<?= paramTag.joinedTypes ?>** `<?= paramTag.name ?>`: <?= paramTag.description ?><? }) ?>
      <? } ?>

      <? if (comment.returnTags.length > 0) { ?>
        ### Return:
        <? comment.returnTags.forEach(function(returnTag) { -?>
          * **<?= returnTag.joinedTypes ?>** <?= returnTag.description ?>
        <? }) ?>
      <? } ?>
    <? } ?>
  <? }) ?>
<? }) ?>