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

Getting error for @undefined tag #26

Closed
0x-r4bbit opened this issue Apr 7, 2014 · 10 comments
Closed

Getting error for @undefined tag #26

0x-r4bbit opened this issue Apr 7, 2014 · 10 comments

Comments

@0x-r4bbit
Copy link
Contributor

I have a doc that basically looks like this:

/**
 * @method foo
 * @memberof bar
 * ...
*/

Using this annotation (which actually seems pretty reasonable) I'm getting this error:

error:   Error: "@undefined" tag found on non-undefined document in file "node_modules/sofa-basket-service/src/sofa.basketService.js" at line 71
    at module.exports.transformFn (/Users/pp/projects/sofa/node_modules/dgeni-packages/jsdoc/tag-defs/index.js:20:15)
    at /Users/pp/projects/sofa/node_modules/dgeni-packages/jsdoc/lib/extract-tags.js:55:30
    at Function.forEach (/Users/pp/projects/sofa/node_modules/lodash/dist/lodash.js:3297:15)
    at /Users/pp/projects/sofa/node_modules/dgeni-packages/jsdoc/lib/extract-tags.js:8:7
    at /Users/pp/projects/sofa/node_modules/dgeni-packages/jsdoc/processors/tag-extractor.js:22:7
    at Function.forEach (/Users/pp/projects/sofa/node_modules/lodash/dist/lodash.js:3297:15)
    at module.exports.process (/Users/pp/projects/sofa/node_modules/dgeni-packages/jsdoc/processors/tag-extractor.js:20:7)
    at invoke (/Users/pp/projects/sofa/node_modules/dgeni/node_modules/di/lib/injector.js:75:15)
    at processingPromise.then.catch.error.message (/Users/pp/projects/sofa/node_modules/dgeni/lib/doc-processor.js:117:31)
    at _fulfilled (/Users/pp/projects/sofa/node_modules/dgeni/node_modules/q/q.js:798:54)

I know that it comes from the tag definition of the memberof tag in the jsdoc package. But according to the source (which looks like this):

...
transformFn: function (doc, tag) {
  if (!(doc.docType === 'event' || doc.docType === 'property' || doc.docType === 'method')) {
    throw new Error( ... )
  }
}
...

The error shouldn't be thrown. Is this a bug or am I doing something wrong?

@0x-r4bbit
Copy link
Contributor Author

If I'm getting this right, there seems to be a conflict with the defaultFn and the transformFn. Here, we can see, that a @method doc actually requires a @memberof tag. https://github.com/angular/dgeni-packages/blob/master/jsdoc/tag-defs/index.js#L12-L22

@petebacondarwin
Copy link
Member

So what this is saying is that @memberOf must and can only appear on docs that have docType of property, method or event. In your example, providing the @method tag does not set the docType.

Arguably this is an ngdoc specific thing. So we should move this check into that package

@0x-r4bbit
Copy link
Contributor Author

So how do one set a doctype?

@petebacondarwin
Copy link
Member

With @ngdoc :-(
On 9 Apr 2014 09:36, "Pascal Precht" notifications@github.com wrote:

So how do one set a doctype?

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-39940380
.

@0x-r4bbit
Copy link
Contributor Author

m( ... okay. So does that also mean that the docType is an ngdoc specific thing in general? I mean the entire mechanism that works with docType.

@0x-r4bbit
Copy link
Contributor Author

Sorry man, I was confused. I think I can close this now.

@0x-r4bbit
Copy link
Contributor Author

Okay, I think I have to get back to this issue. So, setting the docType happens through annotations like:

/**
 * @ngdoc service // or module, class, method etc.
 *
**/

This seems to be possible, because in the ngdoc package, the tag definition for @ngdoc tags looks like this:

{
  name: 'ngdoc',
  required: true,
  docProperty: 'docType'
}

Now, if I wanna have a custom tag that behaves the same, my tag definition has to look like this right? Is there anything else that has to be done, so that the error doesn't occur?

The reason why I'm asking is, that I wanna make our @sofadoc tag behave the same. It should set the docType like @sofadoc method, or @sofadoc class. I don't understand why, but in cases where the docType is class everything works fine. When I say @sofadoc method in combination with @memberof sofa, I still get the error. It turns out that docType is undefined.

Any idea @petebacondarwin ?

@petebacondarwin
Copy link
Member

The order of the typedefs is important
On 11 Apr 2014 14:18, "Pascal Precht" notifications@github.com wrote:

Okay, I think I have to get back to this issue. So, setting the docTypehappens through annotations like:

/** * @ngdoc service // or module, class, method etc. ***/

This seems to be possible, because in the ngdoc package, the tag
definition for @ngdoc tags looks like this:

{
name: 'ngdoc',
required: true,
docProperty: 'docType'}

Now, if I wanna have a custom tag that behaves the same, my tag definition
has to look like this right? Is there anything else that has to be done, so
that the error doesn't occur?

The reason why I'm asking is, that I wanna make our @sofadoc tag behave
the same. It should set the docType like @sofadoc method, or @sofadoc
class. I don't understand why, but in cases where the docType is classeverything works fine. When I say @sofadoc
method in combination with @memberof sofa, I still get the error. It
turns out that docType is undefined.

Any idea @petebacondarwin https://github.com/petebacondarwin ?

Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-40202068
.

@0x-r4bbit
Copy link
Contributor Author

Typedefs? Or do you mean tag defs, if so, how does the order have to be? Sorry, I don't wanna annoy you with this topic, but I really try to get my head around it.

@petebacondarwin
Copy link
Member

TagDefs!
The tag-extractor processor just runs through each tagDef one at a time and processes them. If you need one tagDef to provide a property that is checked in a later tag def then they need to be in the right order

This is one of the reasons for the separation of tag-parsing from tag-extracting. Tags appear in a doc in an undefined order, when they are parsed, but they need to be extracted in a well defined order.

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