google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

Add comments for better code completion (IntelliSense)

Open majkel89 opened this issue 11 years ago • 4 comments

API lacks some code comments that enables IDEs to properly hint code.

Example:

$service = new Google_Service_Analytics(/* ... */);
$accounts = $service->management_accounts->listManagementAccounts([ /* parameters */]);
//                                        ^
//                                        |
//                                        \--- no auto compliteation here
//
$total = $accounts->getTotalResults();
//                 ^
//                 |
//                 \--- no auto compliteation here

Adding south comment would fix the problem.

class Google_Service_Analytics {
    // ...
    /**
     * @var Google_Service_Analytics_ManagementAccounts_Resource
     */
    public $management_accounts;
    // ...
}

Generally code completion:

  • improves productivity
  • shortens learning time for newcomers
  • prevents typo errors that result in fatal errors

I'm willing to update code accordingly.

majkel89 avatar Jan 01 '15 22:01 majkel89

:+1:

SDKiller avatar Jan 02 '15 03:01 SDKiller

All those classes are generated unfortunately, so it needs a change to the templates rather than to the classes in the repo. Its a good idea though, and should be fairly straightforward.

ianbarber avatar Jan 02 '15 19:01 ianbarber

I have already started writing parser to add those comments automatically :8ball:

https://github.com/majkel89/misc/blob/master/GoogleApiPhpClient/GoogleApiAddHints.php

PS: It would be nice to have snippets of documentation as well.

majkel89 avatar Jan 02 '15 23:01 majkel89

This would be highly appreciated. Trying to figure out what classes a method can return is rather cumbersome.

tyteen4a03 avatar Aug 26 '16 09:08 tyteen4a03