jsdoc2md / dmd

The default output template for jsdoc2md
MIT License
39 stars 49 forks source link

@typicalname separation for any parent #66

Closed klasjersevi closed 4 years ago

klasjersevi commented 5 years ago

When using typicalName in a class, the typical name gets applied to the instance, and the name gets applied which is beautiful. However, I wonder why this type of is limited to parents of class kind? There are many other scenarios where this would be applied nicely exactly the same way.

Simplified example of how I want jsdoc2md to work

/**
 * @exports myFunction
 * @typicalname otherFunction
 */
var myFunction = function() {
    /**
     * Documented as otherFunction.instanceMember
     * @member instanceMember
     * @memberof myFunction
     */
    this.instanceMember = 1;
};

/**
 * Should be documented as myFunction.defaultValue
 * @name defaultValue
 * @memberof myFunction
 */
myFunction.defaultValue = 2;

// then using the function somewhere else without having it as a class nor using `new`
var otherFunction = function() {};
myFunction.apply(otherFunction)

So, there would be scenarios for most parents to have the instance typical name separation. My suggestion is to remove the limit to the class parents. Otherwise another tag @instanceName could be added that works for all parents. It could also be extended with @staticName & @innerName.

For now, I just forked and removed the class parent check, which works perfectly for all my cases. I could make a PR if you like.

75lb commented 5 years ago

Yes, submit a PR please - I'll take a look..

klasjersevi commented 5 years ago

I think this was due to something else which will remain unknown. It seems to work fine as intended now with my current configuration and documentation. Keep calm and carry on.

klasjersevi commented 5 years ago

I did some further research and found out that it was actually still a valid issue when having anything that is not a class but can make use of instance members, such as a function or mixin.

75lb commented 4 years ago

Sorry, closing. Merging this would enable the feature for all users and I'm not convinced there's a strong enough use case, that it's a feature all users need.