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

Fix documentation lint issues #1544

Merged
merged 3 commits into from
Aug 31, 2017
Merged

Conversation

rmloveland
Copy link
Contributor

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other

Description of change

Modify prebid.js to address issues found by running the documentation lint command.

In particular I needed to change the variable name from cmd to command in the function starting on this line in order to address the fact that using cmd as the variable name and as the array on the global object was confusing JSDoc.

https://github.com/prebid/Prebid.js/compare/fix-documentation-lint-issues?expand=1#diff-f8e049a1b6d4f9aa96fca41d2f7aa11dR781

I ran gulp test and everything passed, but I wanted to call that out just in case.

Other information

Next baby step towards #1408

Copy link
Contributor

@dbemiller dbemiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

One thing I'll note is that I don't think documentation lint is running on folders recursively. So there are likely to be lots of other errors in modules, src, etc.

No reason that that should hold up these changes, though.

src/prebid.js Outdated
* @property {function} defaults.bidsBackHandler
* @property {number} defaults.timeout
* @property {Array} defaults.adUnits
* @property {Array} defaults.adUnitCodes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive, but... is this generating the right docs? I wouldn't expect to see @property used in this way.

A sample call would look something like:

pbjs.requestBids({
  timeout: ...,
  adUnits: ...,
  adUnitCodes: ...,
  bidsBackHandler: function(bids) { ... }
});

If so, then cool ^^.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to figure that out - mostly I wanted to shut up the linter. I don't think (?) it's generating the right docs - it's generating the following:

### requestBids

**Parameters**

-   `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**  (optional, default `{}`)
    -   `$0.bidsBackHandler`  
    -   `$0.timeout`  
    -   `$0.adUnits`  
    -   `$0.adUnitCodes`  
-   `bidsBackHandler`  
-   `timeout`  
-   `adUnits`  
-   `adUnitCodes`  

I don't know if that is the right doc structure b/c I don't understand what this way of referring to arguments means:

requestBids = function ({ bidsBackHandler, timeout, adUnits, adUnitCodes } = {})

Does it mean that:

  1. This defaults to an empty object?
  2. That providing the object with the right keys as input is optional? Because it doesn't seem optional. (?)
  3. Something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested a bit... I think what you want is to swap the property tags here with param. That makes more reasonable docs (screenshotted below)

screen shot 2017-08-30 at 9 21 14 am

See also: http://usejsdoc.org/tags-param.html#parameters-with-properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense after reading the doc. OK, just switched back to param.

After changing back to param, documentation lint still throwing one warning, but the message reads like its parser just isn't smart enough to understand the code/JSDoc, not like there is an actual problem, so it seems like we can safely ignore it:

warning  An explicit parameter named defaults was specified but didn't match inferred information $0

Copy link
Contributor

@dbemiller dbemiller Aug 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that's super annoying...

That sounds like an error meant to prevent mismatched names, like this:

/**
 * @param e ...
 */
function handleError(error) { ... }

I looked around a bit, and found this: documentationjs/documentation#270

Sounds like $0 is just the placeholder value they assign because the fancy ES6 syntax doesn't actually give the param a name.

src/prebid.js Outdated
* @param timeout
* @param adUnits
* @param adUnitCodes
* @param {Object} defaults
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call this something else? Like requestOptions or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - changed to requestOptions.

@@ -473,9 +473,9 @@ $$PREBID_GLOBAL$$.onEvent = function (event, handler, id) {
};

/**
* @param {String} event the name of the event
* @param {string} event the name of the event
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so confused with the lowercase string and uppercase Object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know! The change is based on the output of documentation lint, and also in the Google Closure Compiler JSDoc guidelines FWIW.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why linters exist in the first place :).

Sometimes it's for consistency. Sometimes it's because your code is subtly incorrect.

My guess is that they were expecting to support Classes in the newer versions of JS, and the general principle was "primitives are lowercase. Classes are uppercase." Just speculation though.

@dbemiller dbemiller merged commit a5d8130 into master Aug 31, 2017
@dbemiller dbemiller deleted the fix-documentation-lint-issues branch August 31, 2017 14:54
ptomasroos pushed a commit to happypancake/Prebid.js that referenced this pull request Sep 1, 2017
* Fix `documentation lint` issues

* Switch JSDoc tags from `property` to `param`

* Call param `requestOptions` based on feedback
philipwatson pushed a commit to mbrtargeting/Prebid.js that referenced this pull request Sep 18, 2017
* Fix `documentation lint` issues

* Switch JSDoc tags from `property` to `param`

* Call param `requestOptions` based on feedback
outoftime pushed a commit to Genius/Prebid.js that referenced this pull request Sep 18, 2017
* tag '0.28.0' of https://github.com/prebid/Prebid.js: (27 commits)
  Prebid 0.28.0 Release
  Revert "Upgrade sinon to 3.x (prebid#1491)" (prebid#1563)
  add () for correct order of operations in scaling increments for currency (prebid#1559)
  AppnexusAst adapter update: Added source and version to request payload (prebid#1555)
  remove unnecessary spread operator (prebid#1561)
  Adxcg adapter (prebid#1554)
  Upgrade sinon to 3.x (prebid#1491)
  Rename vastPayload to vastXml (prebid#1556)
  Single-size sizes array now can be taken, too (prebid#1535)
  Updated the istanbul-instrumenter-loader (prebid#1550)
  Add AerServ Adapter (prebid#1538)
  Fixed imports and made adform support aliasing (prebid#1518)
  Custom granularity fix (prebid#1546)
  Fix `documentation lint` issues (prebid#1544)
  Yieldbot adunit bidder params slot name usage fix (prebid#1394)
  Update serverbid adapter to use smartsync (prebid#1324)
  Add improvedigitalBidAdapter (prebid#1381)
  Fix prebid#1533 spring server typo (prebid#1542)
  userSync is off by default (prebid#1543)
  currency module (prebid#1374)
  ...
jbAdyoulike pushed a commit to jbAdyoulike/Prebid.js that referenced this pull request Sep 21, 2017
* Fix `documentation lint` issues

* Switch JSDoc tags from `property` to `param`

* Call param `requestOptions` based on feedback
vzhukovsky added a commit to aol/Prebid.js that referenced this pull request Oct 12, 2017
….28.0 to aolgithub-master

* commit '4d9ade3df767750743f8888ed9efd6c77f8d0050': (26 commits)
  Added changelog entry.
  Added new aol partners ids.
  Prebid 0.28.0 Release
  Revert "Upgrade sinon to 3.x (prebid#1491)" (prebid#1563)
  add () for correct order of operations in scaling increments for currency (prebid#1559)
  AppnexusAst adapter update: Added source and version to request payload (prebid#1555)
  remove unnecessary spread operator (prebid#1561)
  Adxcg adapter (prebid#1554)
  Upgrade sinon to 3.x (prebid#1491)
  Rename vastPayload to vastXml (prebid#1556)
  Single-size sizes array now can be taken, too (prebid#1535)
  Updated the istanbul-instrumenter-loader (prebid#1550)
  Add AerServ Adapter (prebid#1538)
  Fixed imports and made adform support aliasing (prebid#1518)
  Custom granularity fix (prebid#1546)
  Fix `documentation lint` issues (prebid#1544)
  Yieldbot adunit bidder params slot name usage fix (prebid#1394)
  Update serverbid adapter to use smartsync (prebid#1324)
  Add improvedigitalBidAdapter (prebid#1381)
  Fix prebid#1533 spring server typo (prebid#1542)
  ...
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* Fix `documentation lint` issues

* Switch JSDoc tags from `property` to `param`

* Call param `requestOptions` based on feedback
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

Successfully merging this pull request may close these issues.

3 participants