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

How to group methods by classes? #412

Open
anselmbradford opened this issue Apr 28, 2016 · 7 comments
Open

How to group methods by classes? #412

anselmbradford opened this issue Apr 28, 2016 · 7 comments

Comments

@anselmbradford
Copy link
Contributor

anselmbradford commented Apr 28, 2016

https://github.com/documentationjs/documentation-theme-light/blob/master/screenshot.png shows the methods in the sidebar grouped by JS classes. I run the default theme or theme-light and all I get in the sidebar is all the methods across the codebase dumped out as one long list (creating, e.g., a long line of init entries). How do I group the methods by their associated classes and/or modules? I'm feeding all the JS files in the codebase into the documentation build command, if that matters. Also the --github, --format, and --output options are added. Thanks!

@anselmbradford
Copy link
Contributor Author

@tmcw do you happen to know the answer to this?

@pago
Copy link
Contributor

pago commented May 18, 2016

Had the same question. It works if you add documentation to the members of a class. Without associated documentation it just puts them into the global scope.

So:

class Foo {
    hello() {}
}

will put hello into the global scope but

/** foo */
class Foo {
    /** bar */
    hello() {}
}

will probably work.

@anselmbradford
Copy link
Contributor Author

Awesome, thanks @pago, I'll try it out!

@anselmbradford
Copy link
Contributor Author

@pago Do you see an issue with this class? I realized I already have the nesting you showed, but it's still not working.

@froamer
Copy link

froamer commented Jun 29, 2016

Hi, how can I nest this type of code?...

/**
 * Authentication controller for negotiating with OAuth2
 * @class App.controller.Authentication
 */

Ext.define('PKB.controller.Authentication', {
    extend: 'Ext.app.Controller',

    /**
     * Redirect to the server OAuth2 login form.
     * @method login
     */
    login: function(){
        ...
    }
});

This just lists the login function at the same level as the App.controller.Authentication.

Many thanks for any help.

@anatoliyarkhipov
Copy link

Hi, @froamer! We are using Dojo and it has a similar class definition syntax. I found a way to correctly place methods of the class with a namespace:

/**
 * Test Class
 *
 * @class SelectionEngine
 * @memberof Bar.Baz
 */
const SelectionEngine = declare(null, {

    /**
     * @memberof Bar.Baz.SelectionEngine // <-- Note, it must be `@memberof`, NOT `@memberOf`. 
     * @instance
     *
     * @param foo
     * @param bar
     * @param baz
     */
    expandColsTo: function(foo, bar, baz) {

    },
})

I think it should work for you too. But as you can see on the screenshot, it doesn't render namespace of the class, but only its name. I see two downsides in it:

  1. Classes are not grouped by the package in which they are placed. It makes them hard to search
  2. A rare case: if you have two classes with the same name and the same methods in different namespace, achnors will be broken (see the screenshot, I clicke on the bottom, but the top was opened).

image

Is there any way to render the whole name of the class, with its namespace?

@tmcw
Copy link
Member

tmcw commented Apr 25, 2017

Sorry for the delay: there are a few questions here, I can answer one at this point:

For frameworks / libraries that construct 'classes' by calling a function, the key is @lends. For instance:

/**
 * The engine that does selection...
 */
const SelectionEngine = declare(
  null,
  /** @lends SelectionEngine */ {
    /**
     * @instance
     * @param foo
     * @param bar
     * @param baz
     */
    expandColsTo: function(foo, bar, baz) {}
  }
);

I'll add a note about this to docs.

tmcw added a commit that referenced this issue Apr 25, 2017
This tag is useful for documenting class factories in libraries and frameworks

Refs #412
tmcw added a commit that referenced this issue Apr 25, 2017
This tag is useful for documenting class factories in libraries and frameworks

Refs #412
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

5 participants