angular / dgeni-packages

A collection of dgeni packages for generating documentation from source code.
MIT License
142 stars 106 forks source link

Feature proposal: enhance tagDefs #298

Open lmores opened 3 years ago

lmores commented 3 years ago

As emerged during the discussion of PR #295 some jsdoc tags (like @module, @typedef and @callback) should not be attatched to specific code nodes but rather they should provide information to other parts of the code documentation.

In broad terms a possible approach could be to extend the tagDefs with something like

module.exports = function( ... ) {
  return {
    name: 'myTag',
    global: true,
    globalTransforms: [ ... ],
    ...
  };
};

Where globalTransforms is an array of services (similar to the already implemented transforms property) that should be run after all the other jsdoc tags have been collected.

However there might be some difficulties: one is the folllowing (outlined by @petebacondarwin). Consider the following code:

/**
 * @module
 */

/**
 * Description of foo().
 */
  function foo() {}

Then I think that both comment blocks will be processed with respect to a single doc that has the foo() function as its codeNode. We need to find a good way to distinguish JSDOC comments that should not apply to code nodes (but rather to the file, the whole doc collection or something else...).

What do you think?