This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244918 - Add support for JSDoc's @typedef to describe object properties
Summary: Add support for JSDoc's @typedef to describe object properties
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal with 4 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-05 22:12 UTC by dharkness
Modified: 2014-10-06 13:06 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dharkness 2014-06-05 22:12:51 UTC
I'm trying to document Facebook's response objects, but NetBeans doesn't seem to understand @typedef or @property. Here's the documentation:

    /**
     * Passed to Facebook event and request callbacks.
     *
     * @typedef {Object} FB.Response
     * @property {string} status One of "unknown", "not_authorized", or "connected"
     * @property {FB.AuthResponse} authResponse Present when status is "connected"
     */

    /**
     * Embedded in the responses when the user is "connected".
     *
     * @typedef {Object} FB.AuthResponse
     * @property {string} userID Unique user identifier (seems to hold an integer as a string)
     * @property {string} accessToken May be used to make API calls on the user's behalf
     * @property {string} signedRequest Some opaque value not described in the documentation
     * @property {int} expiresIn Time in seconds after which the access token and signed request will expire
     */

I'd like to see code-completion on "response" below:

    /**
     * Handles the response from a Facebook status request.
     *
     * @param {FB.Response} response Received from Facebook
     */
    function handleResponse(response) {
        response.[ctrl-tab]
    }

My current work-around is to create a fake object in another file that doesn't get executed:

    FB.Response = {
        status: 'unknown',
        authResponse: {
            userID: '123',
            accessToken: 'foo',
            signedRequest: 'bar',
            expiresIn: 123
        }
    };
Comment 1 Martin Fousek 2014-06-20 05:59:52 UTC
That would have definitely sense to support it in the future. Petre don't you know whether there would be necessary anything else from the documentation? Probably something like?
JsObject getDefinedObjects()
Comment 2 Petr Pisl 2014-06-23 08:35:48 UTC
IMHO JsDocumentationHolder can have a support of this. Probably something like getTypeDefinitions(). It will be per file and an ast node independent. The method getTypeDefinitions should not return directly the JsObject implementation, the object should be created in the model itself and the documentation provider / holder can just provide the information.

Another way is to obtain all documentation blocks and tags from them. The model can go through the doc blocks and build the types from the blocks.