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

Update the documentation in src/map.js. #698

Merged
merged 7 commits into from
Jun 5, 2017
Merged

Conversation

manthey
Copy link
Contributor

@manthey manthey commented May 19, 2017

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.

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.
@manthey
Copy link
Contributor Author

manthey commented May 19, 2017

@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-io
Copy link

codecov-io commented May 19, 2017

Codecov Report

Merging #698 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/mapInteractor.js 96.12% <ø> (ø) ⬆️
src/index.js 100% <ø> (ø) ⬆️
src/event.js 100% <ø> (ø) ⬆️
src/map.js 98.78% <100%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 276bb52...8fbac1d. Read the comment docs.

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.
@manthey manthey force-pushed the map-class-documentation branch from a7066c0 to 340b2d3 Compare May 24, 2017 15:37
@manthey
Copy link
Contributor Author

manthey commented May 24, 2017

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',
Copy link
Member

Choose a reason for hiding this comment

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

why star after clampBounds?

Copy link
Contributor Author

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
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

@aashish24 aashish24 left a 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.

@aashish24
Copy link
Member

@jbeezley @manthey should we have a style doc somewhere that can summarize @jbeezley suggestions?

@@ -667,12 +669,13 @@ var map = function (arg) {

////////////////////////////////////////////////////////////////////////////
/**
* Resize map (deprecated)
* Resize map in pixels.
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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).

Copy link
Contributor Author

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
Copy link
Contributor

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.

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 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.
@manthey
Copy link
Contributor Author

manthey commented May 30, 2017

@jbeezley Short of refactoring or removing resize, I've addressed your comments. I'll note that resize is also called from the size method, so it might make more sense to move its code there and have resizeSelf call size.

@aashish24
Copy link
Member

@manthey I am fine with changes, although I wish we had a doc style checker. Manually checking doc changes seems harder than it looks.

@jbeezley are we still waiting on changes?

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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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".

@manthey manthey merged commit e57e648 into master Jun 5, 2017
@manthey manthey deleted the map-class-documentation branch June 5, 2017 12:30
@aashish24
Copy link
Member

🎉

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.

4 participants