documentationjs / documentation

:book: documentation for modern JavaScript
http://documentation.js.org/
Other
5.79k stars 481 forks source link

@file is applied to following element instead of the file itself #1178

Open Malvineous opened 5 years ago

Malvineous commented 5 years ago

If you use the @file statement to provide a description for your file in a header, it gets applied as a duplicate block to whichever element comes first in the file.

Example code:

/**
 * @file Example file.
 */

/**
 * Example class.
 */
class Example {
    /**
     * Example function.
     */
    a() {
    }
};

Here, the @file block should effectively be ignored, however documentation currently applies it to the following item, so in this case the Example class is duplicated.

I think if a docblock contains @file it should be ignored, or at least attached to the file and not to whatever element follows the block.

Here is the output of the above code, with the duplicate Example class:

### Table of Contents

-   [Example][1]
    -   [a][2]
-   [Example][3]
    -   [a][4]

## Example

Example file.

### a

Example function.

## Example

Example class.

### a

Example function.

[1]: #example

[2]: #a

[3]: #example-1

[4]: #a-1

Running 8.1.2 via CLI.

Zearin commented 4 years ago

Same issue. (Although I prefer the alias @fileOverview, for anyone reading this and starting a fix. ☻)