-
Notifications
You must be signed in to change notification settings - Fork 75
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
Update the documentation in src/map.js. #698
Conversation
Only the first 1/3 has been done, mainly to get feedback if this is what we want. I've removed a few bits of vestigial code -- map.scale and map.maxZoom were unused. The pan event claimed it included more information than it did, and included an extra empty element. We could get rid of the map.origin() code -- we don't use it or test it other than simple coverage. Perhaps we should have a more central place to document datatypes used in the documentation -- many are in the mapInteractor code.
@jbeezley and @aashish24 Here is my first take on trying to update map.js's documentation. I've only done the first 1/3 of the file or so, since I want to make sure we are happy with how things are being done. I have questions about how jsdoc generates event documentation (see my comment on issue #448). |
Codecov Report
@@ Coverage Diff @@
## master #698 +/- ##
==========================================
- Coverage 95.28% 95.28% -0.01%
==========================================
Files 83 83
Lines 8990 8988 -2
==========================================
- Hits 8566 8564 -2
Misses 424 424
Continue to review full report at Codecov.
|
I've moved the typedefs in map and mapInteractor to their own file. In principle, the documentation in src/map.js is done (barring typos). I've fixed some documentation that was missing or wrong. I rearranged some of the private inner functions to group them together and keep them above the initialization code.
a7066c0
to
340b2d3
Compare
I've gone through all of src/map.js. Criticism welcome. |
src/map.js
Outdated
* the new view. | ||
* @returns {Object|geo.map} | ||
* @param {boolean|'limited'} [ignoreClampBounds] if true ignore the | ||
* clampBounds* options when determining the new view. When 'limited', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why star after clampBounds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shortened form of clampBoundsX and clampBoundsY options
. Obviously not clear enough, so I shouldn't use the shortened form
src/map.js
Outdated
@@ -596,8 +597,9 @@ var map = function (arg) { | |||
/** | |||
* Remove layer from the map | |||
* | |||
* @param {geo.layer} layer that should be removed from the map | |||
* @return {geo.map} | |||
* @param {geo.layer?} layer layer that should be removed from the map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was ? intended?
@@ -835,7 +819,9 @@ var map = function (arg) { | |||
|
|||
//////////////////////////////////////////////////////////////////////////// | |||
/** | |||
* Manually force to render map | |||
* Redraw the map and all its layers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looking reasonable to me but I may have missed few things. I think the new doc is much better than the last version.
@@ -667,12 +669,13 @@ var map = function (arg) { | |||
|
|||
//////////////////////////////////////////////////////////////////////////// | |||
/** | |||
* Resize map (deprecated) | |||
* Resize map in pixels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to consider this deprecated? I don't know that calling this with x or y nonzero actually works. If so, we should add a @deprecated
and remove it on the next breaking change release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this function when the window is resized via the resizeSelf
function. We don't do anything with x and y (just with width and height).
Since prior to this PR, it has been labelled deprecated for a while, we could remove the function and roll the needed functionality into resizeSelf
. We could remove x and y from the geo.event.resize
event properties, too.
src/map.js
Outdated
* @param {number} y y-offset in display space | ||
* @param {number} w width in display space | ||
* @param {number} h height in display space | ||
* @fires geo.event.resize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, the link doesn't work for this declaration. The same is true for a number of events added in this file.
src/map.js
Outdated
* clampBoundsX and clampBoundsY options when determining the new view. | ||
* When 'limited', the clampBoundsX and clampBoundsY options are | ||
* selectively enforced so that the map will not end up more out of bounds | ||
* than its current state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In places like this where there are literals used in prose (e.g. true
, 'limited'
, and clampBoundsX
), I think it reads better to display them in monospace. This follows the style used in the openlayers documentation as well. You can use markdown syntax to accomplish it. Should we add this convention to the checklist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
src/map.js
Outdated
@@ -357,14 +341,18 @@ var map = function (arg) { | |||
/** | |||
* Get/Set zoom level of the map | |||
* | |||
* @param {number} val if undefined, return the current zoom level. | |||
* @param {number} [val] if undefined, return the current zoom level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our parameter descriptions are inconsistent with regard to capitalization and ending in a period. I don't know which we should prefer, but ideally it would the same everywhere. For comparison, openlayers uses a capital letter and period for all parameter descriptions (even those that aren't complete sentences).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us do that, too. I'd say the only exception is when the first word is a literal, in which case it can be in monospace.
src/map.js
Outdated
* @param {string|object} [readerOrName]: undefined to get the current | ||
* reader, an instance of a file reader to set the reader, or a name to | ||
* create a file reader. | ||
* @param {object} [opts]: options for creating a file reader when the reader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to change the output here, but for consistency it would be good to remove the :
in these declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to remove the :
.
All parameter descriptions are capitalized and end with punctuation. All events are defined. Literals are mark-down quoted to be monospace. Fixed some wording.
@jbeezley Short of refactoring or removing |
src/map.js
Outdated
* instead of cancelAnimationFrame). Any other truthy value moves the | ||
* callback to the end of the list. | ||
* @returns {integer} An integer as returned by window.requestAnimationFrame. | ||
* @param {function} Xallback function to call during the animation frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
src/map.js
Outdated
* @param {object} [arg] The zoom range. | ||
* @param {number} [arg.min] The minimum zoom level. | ||
* @param {number} [arg.max] The maximum zoom level. | ||
* @param {boolean} [noRefresh] if `true`, don't update the map if the zoom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalize and end in a period.
src/map.js
Outdated
@@ -1750,7 +1750,7 @@ var map = function (arg) { | |||
* callbacks will be called in a single time slice, providing better | |||
* synchronization. | |||
* | |||
* @param {function} Xallback function to call during the animation frame. | |||
* @param {function} Callback function to call during the animation frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name is "callback", so this should be "callback Function".
🎉 |
Only the first 1/3 has been done, mainly to get feedback if this is what we want.
I've removed a few bits of vestigial code -- map.scale and map.maxZoom were unused. The pan event claimed it included more information than it did, and included an extra empty element.
We could get rid of the map.origin() code -- we don't use it or test it other than simple coverage.
Perhaps we should have a more central place to document datatypes used in the documentation -- many are in the mapInteractor code.