Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override detected code with jsdoc directives? #179

Open
trusktr opened this issue May 16, 2016 · 3 comments
Open

Override detected code with jsdoc directives? #179

trusktr opened this issue May 16, 2016 · 3 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented May 16, 2016

It's been a while, but I'll be coming back to dox!

Question: does dox look at the comments when it can't infer from the code? Can we make it prioritize the comments over the code?

For example, I have

/**
 * This is the HTML entry point. This is what fires the app running.
 *
 * @class app
 *
 * @example
 * <app />
 */
angular.module('app').directive('app', function() {
  return {
    template: require('./app.html'),
    restrict: 'E', // custom element only, not attribute directive.
    scope: {}, // use isolate scope for custom elements.
    transclude: false, // if true, means the custom element can have children. Place the children anywhere inside the template using ng-transclude.
    controller: AppCtrl,
    controllerAs: 'app',
    bindToController: true, // always bind to controller with isolate-scope element directives.
  };
});

Since Angular directives aren't a standard JS thing, I thought I'd just use the @class jsdoc directive to document it (in Angular 2 they are classes anyways). I'm using dox 0.8.1 in dox-foundation, but the class docs don't show up. For example, here's what an actual ES6 class doc looks like in dox-foundation:

screen shot 2016-05-15 at 7 16 44 pm

But, here's what happens with the above sample code:

screen shot 2016-05-15 at 7 17 22 pm

which leads me to believe that the JSON that dox returns to dox-foundation is different in that case, which is why dox-foundation renders it differently. Is there (maybe we can add) an option to prioritize comments over code?

@Twipped
Copy link
Collaborator

Twipped commented May 16, 2016

If a tag is defined in the comment which matches something we infer, it absolutely should override the inferred meaning. So if that's not happening then something's wrong.

I would have to see the actual json being produced to chase down that issue, tho.

@trusktr
Copy link
Contributor Author

trusktr commented May 16, 2016

Well, in my case, the tag doesn't match the inferred thing, so it's ignored. So, what I mean is (what I would like), if I say something is a @class in the jsdoc-style comment, then dox should just trust my comment, and ignore the code (not make inference).

As with the above example, dox seems to ignore it because (as you said) the @class doesn't match with what's inferred.

I think it's a good case to prioritize comments over code because in reality there's no way we can infer all code cases (as in my example, but there are many more).

(I'm also not sure @class is the best choice for my example, but I'm not sure what else to pick, if any).

@trusktr
Copy link
Contributor Author

trusktr commented May 16, 2016

I guess what I'd want in my case is to write @directive, but have that behave like @class, so that (based on the above screenshot) the blue "class" label would instead contain "directive", and perhaps then my template can place <myDirective /> instead of new myDirective() next to the label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants