documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Declare a class in a namespace using dot

Open ggrossetie opened this issue 5 years ago • 0 comments

If you're reporting a bug, please include input code, output documentation, a description of what you expected to happen, and what happened instead.

  • What version of documentation.js are you using?: 12.1.3
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): no

I'm using the following JSDoc annotated JavaScript file: Input

/**
 * @namespace
 */
const Extensions = {}

/**
 * @class Extensions.Registry
 */
const Registry = Extensions.Registry = {}

/**
 * @memberof Extensions.Registry
 * @inner
 * @function getGroups
 */
Registry.prototype.getGroups = () => {}

As you can see, I want to declare a namespace named Extensions and a class named Registry inside this namespace (using the dot notation).

Here's the result with jsdoc:

Output (using jsdoc) jsdoc

As you can see the class Registry is in the namespace Extensions (as expected)

For reference, here's the result using tsd-jsdoc:

TypeScript Definition (using tsd-jsdoc)

/**
 * @namespace
 */
declare namespace Extensions {
    /**
     * @class Extensions.Registry
     */
    class Registry {
        /**
         * @memberof Extensions.Registry
         * @inner
         * @function getGroups
         */
        getGroups(): void;
    }
}

And now, here's the result using documentation:

Ouput (using documentation build file.js -f html) documentation

As you can see the class Registry is not in the namespace Extensions and the getGroups function is not attached to the Registry class.

Ouput (using documentation lint file.js)

$ documentation lint file.js              
/path/to/file.js
  12:1  warning  @memberof reference to Extensions.Registry not found

⚠ 1 warning

If I replace Extensions.Registry by Extensions/Registry then it's working in documentation but not jsdoc:

Ouput (using documentation build file.js -f html with / as a separator) doc-good-slash

Ouput (using jsdoc with / as a separator) jsdoc-bad

As you can see the class is named Extensions/Registry and is not part of the namespace Extensions.

I think we should use dot as a separator instead of slash to be consistent with JSDoc (or at least support both syntax).

ggrossetie avatar Dec 28 '19 18:12 ggrossetie