-
-
Notifications
You must be signed in to change notification settings - Fork 748
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 JSDoc comments #891
Comments
Are you sure? |
I have no clue for example why fitBounds is not accurate in the docs... Can you explain? |
For /**
* Pans and zooms the map to contain its visible area within the specified geographical bounds.
* This function will also reset the map's bearing to 0 if bearing is nonzero.
*
* @memberof Map#
* @param bounds Center these bounds in the viewport and use the highest
* zoom level up to and including `Map#getMaxZoom()` that fits them in the viewport.
* @param {FitBoundsOptions} [options] Options supports all properties from {@link AnimationOptions} and {@link CameraOptions} in addition to the fields below.
* @param {number | PaddingOptions} [options.padding] The amount of padding in pixels to add to the given bounds.
* @param {boolean} [options.linear=false] If `true`, the map transitions using
* {@link Map#easeTo}. If `false`, the map transitions using {@link Map#flyTo}. See
* those functions and {@link AnimationOptions} for information about options available.
* @param {Function} [options.easing] An easing function for the animated transition. See {@link AnimationOptions}.
* @param {PointLike} [options.offset=[0, 0]] The center of the given bounds relative to the map's center, measured in pixels.
* @param {number} [options.maxZoom] The maximum zoom level to allow when the map view transitions to the specified bounds.
* @param {Object} [eventData] Additional properties to be added to event objects of events triggered by this method.
* @fires movestart
* @fires moveend
* @returns {Map} `this`
* @example
* var bbox = [[-79, 43], [-73, 45]];
* map.fitBounds(bbox, {
* padding: {top: 10, bottom:25, left: 15, right: 5}
* });
* @see [Fit a map to a bounding box](https://maplibre.org/maplibre-gl-js-docs/example/fitbounds/)
*/
fitBounds(bounds: LngLatBoundsLike, options?: FitBoundsOptions, eventData?: any) {
return this._fitInternal(
this.cameraForBounds(bounds, options),
options,
eventData);
} and this is the documentation website: What is not accurate about it? |
IDK, it was any when I looked at it, maybe a refresh was needed. |
Can we leverage the tsdoc format somehow? |
I wonder how to best document string literal types in TypeScript? We introduced some in the TypeScript migration. Related issue: |
@HarelM, things that are grayed out have no documentation comments. For example, the definition of maplibre-gl-js/src/ui/camera.ts Lines 90 to 101 in 3e23fbf
|
Ahh, interesting, thanks! |
Google's TypeScript style guide also says to not document redundant types: https://google.github.io/styleguide/tsguide.html#omit-comments-that-are-redundant-with-typescript |
I find it very confusing that JavaScript + JSDoc basically is TypeScript... |
The docs website uses documentation.js to parse JSDoc comments in the MapLibre GL JS source code. After parsing, all information is written into a file called api.json. This is the responsible command in the docs repo: Batfish, a Mapbox static site generator, consumes api.json and builds the docs website based in its content. |
GL JS might benefit in the long run if we were to migrate the JSDoc comments to the TSDoc format. Currently, we have to manually sync the types in the docs to the source code types. This is error-prone and redundant. The migration to TypeScript #209 introduced many new types which miss documentation. For example, |
I think we should migrate from JSDoc to TSDoc comments, and replace documentation.js with TypeDoc. TypeDoc can output an api.json file, too. We would need to adapt the docs website to consume a differently organized api.json file. |
Sounds like a good idea. |
@wipfli , it sure seems like the right thing to do long term. If this tsdoc .json file happen, I'd be happy to take a swing at adapting our docs. For maintenance reasons, I think we could also benefit of migrate from these mapbox-only tools like batfish and jsxtreme with limited maintenance and docs (ironically) to something more standardized - and it could be part of this too. |
+1 for not using mapbox proprietary stuff. |
I am leaning towards using the existing documentationjs+jsdoc system and adding documentation to types which are not documented yet. Maybe this produces more redundancy than using tsdoc, but I think we can manage it. Rebuilding the docs website on typedoc's output seems to me a much larger task than aligning the existing framework to the changes of #209. |
@wipfli I agree - for now at least. I experimented with generating the .json from typedoc, but it only had a small part of the information we get now with the current setup, and alternatively we could use the tsdoc backed project https://api-extractor.com/, but it doesn't seem that easy to use yet, and it also seems to be tied to the rushstack etc. which is an entirely different story. |
We can leave this issue open if we decide we would like to do this later or close this if we decide that we are not planning to pursue it. Either way works for me. |
Removing parameter types for function signatures only does not seem good, because for typedefs and class constructors we would still need to put them. That would make the JSDoc style inconsistent. I close this issue for now. I thought there would be some easy gains to make. But after looking into alternatives, it seems like the current solution is not all that bad. |
Documentation of function signatures includes the types of the arguments. These type annotations are redundant in TypeScript and are not used by documentation.js, which we use to produce the docs website. I suggest we remove all JSDocs type annotations.
For example:
should be
The text was updated successfully, but these errors were encountered: