Skip to content

all comments added#360

Open
Joishee05 wants to merge 1 commit into
mainfrom
213-jsdoc-comments
Open

all comments added#360
Joishee05 wants to merge 1 commit into
mainfrom
213-jsdoc-comments

Conversation

@Joishee05
Copy link
Copy Markdown
Collaborator

Closes #213

Add JSDoc-compliant comments to files that lack sufficient documentation.

@Joishee05 Joishee05 self-assigned this Apr 24, 2026
@Joishee05 Joishee05 linked an issue Apr 24, 2026 that may be closed by this pull request
3 tasks
@leandrumartin leandrumartin requested a review from Copilot May 2, 2026 17:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds/updates JSDoc-compliant documentation across templates/js to improve developer onboarding and make function/class intent, parameters, and return types clearer (per #213).

Changes:

  • Added/expanded JSDoc blocks for key exported functions and several internal helpers (including @param/@returns).
  • Improved inline documentation for UI modules (sidebar, search, navigation, quiz).
  • Added type documentation for shared data structures (e.g., imageCaptions map).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/js/viewer.js Adds missing @returns and improves parameter doc for viewer display helpers.
templates/js/sidebar.js Adds JSDoc for async sidebar/help-button initialization functions.
templates/js/search.js Adds JSDoc for search initialization and internal search/navigation helpers.
templates/js/quiz.js Adds class/method JSDoc for quiz manager behavior and return types.
templates/js/navigation.js Documents navigation setup and helper functions with parameter/return types.
templates/js/main.js Adds JSDoc for populateSubboneDropdown (but currently has a malformed/duplicated block).
templates/js/imageDisplay.js Adds JSDoc for image rendering helpers and transform utilities.
templates/js/imageCaptions.js Documents exported caption lookup map type/shape.
templates/js/dropdowns.js Adds JSDoc for image stage helpers, image-loading helper, and dropdown wiring.
templates/js/description.js Adds JSDoc for GitHub-backed description loader.
templates/js/coloredRegionsOverlay.js Adds missing @returns tags for clear helpers.
templates/js/api.js Adds JSDoc for API fetch functions including throws/return details.
templates/js/annotationOverlay.js Adds JSDoc for overlay lifecycle and annotation rendering/loading helpers (one doc mismatch with implementation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/js/main.js
Comment on lines +115 to +117
/**
* Populates the subbone `<select>` element with options for the given subbone IDs.
* Inserts a placeholder option and disables the dropdown if no subbones are provided.
Comment on lines +82 to +87
* Reads normalized geometry and slide dimensions from the JSON to map PowerPoint
* EMU coordinates onto the displayed pixel size of the container.
* @param {HTMLElement} container - The element to draw annotations into.
* @param {Object} annotationsJson - Annotation data from the API, containing:
* `annotations` {Array}, `normalized_geometry` {Object}, `slide_width` {number},
* and `slide_height` {number}.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correct—this function expects the fields normalized_geometry and either annotations or text_annotations. Although really I think that's a bit messy...why is this function expecting two possible formats, when really only one should exist? The line where it's checking for either annotations or text_annotations should be modified such that it's only looking for one of the two—whichever one actually is expected to exist.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also: The expected properties should be listed in the format documented here: https://jsdoc.app/tags-param#parameters-with-properties
You've already done this correctly with imageDisplay.applyRotation

/**
* Clear all colored region overlays from a container
* @param {HTMLElement} container - The container element
* @returns {void}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For what it's worth, adding @returns {void} isn't really necessary, but it's fine that's it's here. No action needs to be taken on this.

const GITHUB_RAW_URL = "https://raw.githubusercontent.com/oss-slu/DigitalBonesBox/data/data/descriptions/";

/**
* Fetches the description JSON for the given bone/subbone ID from GitHub and
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since we're transitioning away from fetching our data from GitHub, this should no longer explicitly say that the data is coming from there. In fact, it should not specify where the data is coming from at all, since we're planning on refactoring this to go through other functions anyway.

Comment thread templates/js/dropdowns.js
/** Helper: fetch images for a bone/sub-bone and render them
* @param {string} boneId - The bone or subbone ID to load images for.
* @param {Object} [options={}] - Options forwarded to `displayBoneImages`, e.g.
* `{ annotationsUrl: string, boneId: string, isBonesetSelection: boolean }`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't include the example of the options here. If the options that displayBoneImages expects are changed, it would be really easy to miss updating this bit of documentation here.

/** ---- Empty-state / clearing ------------------------------------------- */
/**
* Renders the empty-state placeholder message inside the image container
* and clears all annotations, colored regions, and captions.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clarify that "annotations" refers to text annotations specifically. (In some parts of the repo, we also use "annotation" to refer to the colored region annotations, or other image modifications entirely, so we want to be specific when referring to text annotations.)

}

/**
* Clears all images, annotations, colored regions, and captions from the image container.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above: "annotations" → "text annotations"

* Applies a CSS rotation (and optional horizontal flip) to an image element
* based on the PowerPoint rotation template for the given view.
* @param {HTMLImageElement} imgEl - The image element to transform.
* @param {Object} [options={}] - Rotation parameters.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This incorrectly lists the default value for options

}

/**
* Decrements the current subbone index (moves to the previous subbone), if possible.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"if possible" should be clarified to "if greater than 0"

}

/**
* Increments the current subbone index (moves to the next subbone), if possible.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above--clarify conditions for "if possible"

Comment thread templates/js/quiz.js

/**
* Generate wrong answer choices from the master pool
* Picks `count` distractor names from the master pool, excluding the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this sounds a bit unclear, and that the original comment made the function's overall purpose a bit more understandable by saying "generate wrong answer choices." I just don't like the term "distractor name," so maybe this could be reworded to clarify a bit by clarifying that this is for selecting wrong answer choices to display to the user.

Comment thread templates/js/quiz.js
/**
* Display answer choice buttons
* Renders the answer choice buttons for the given question.
* @param {{allAnswers: string[], correctAnswer: string}} question - The
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The structure of question would be better documented as outlined here: https://jsdoc.app/tags-param#parameters-with-properties. This would ensure that IDEs and other tools would parse this documentation correctly.

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.

JSDoc Comments

3 participants