Skip to content

Commit 4184d7e

Browse files
rtibblesclaude
andcommitted
Remediate JSDoc violations in plugins/learn
Adds typedef imports for Vue Ref/ComputedRef and ContentNode-family types used in composables and progress-tracking; restores typed @returns shapes on useCoreLearn; fills missing block descriptions, @param descriptions, @throws, and @returns declarations across the learn-app composables and views. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 795d81f commit 4184d7e

35 files changed

Lines changed: 252 additions & 169 deletions

kolibri/plugins/learn/frontend/apiResources.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Resource } from 'kolibri/apiResource';
22

33
/**
4-
* Gets all of the Classrooms in which a Learner is enrolled
5-
*
4+
* Gets all of the Classrooms in which a Learner is enrolled.
65
* @example To get Classrooms without assignments and progress:
76
* LearnerClassroomResource.fetchCollection({
87
* getParams: { no_assignments: true },

kolibri/plugins/learn/frontend/composables/__mocks__/useDevices.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* If you need to override some default values from some tests,
99
* you can import a helper function `useDevicesMock` that accepts
1010
* an object with values to be overriden and use it together
11-
* with `mockImplementation` as follows:
11+
* with `mockImplementation`, as shown in the example below.
1212
*
1313
* ```
1414
* // eslint-disable-next-line import-x/named

kolibri/plugins/learn/frontend/composables/__mocks__/useDownloadRequests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* If you need to override some default values from some tests,
99
* you can import a helper function `useDownloadRequestsMock` that accepts
1010
* an object with values to be overriden and use it together
11-
* with `mockImplementation` as follows:
11+
* with `mockImplementation`, as shown in the example below.
1212
*
1313
* ```
1414
* // eslint-disable-next-line import-x/named

kolibri/plugins/learn/frontend/composables/__mocks__/useLearnerResources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* If you need to override some default values from some tests,
99
* you can import a helper function `useLearnerResourcesMock` that accepts
1010
* an object with values to be overriden and use it together
11-
* with `mockImplementation` as follows:
11+
* with `mockImplementation`, as shown in the example below.
1212
*
1313
* ```
1414
* // eslint-disable-next-line import-x/named

kolibri/plugins/learn/frontend/composables/__mocks__/usePinnedDevices.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* If you need to override some default values from some tests,
99
* you can import a helper function `usePinnedDevicesMock` that accepts
1010
* an object with values to be overriden and use it together
11-
* with `mockImplementation` as follows:
11+
* with `mockImplementation`, as shown in the example below.
1212
*
1313
* ```
1414
* // eslint-disable-next-line import-x/named

kolibri/plugins/learn/frontend/composables/useBookmarks.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ const loadingBookmarksMap = reactive({});
2323

2424
/**
2525
* Adds or updates a bookmark in the shared bookmarksMap.
26-
*
27-
* @param {Object} bookmark - A bookmark object with at least `contentnode_id` and `id`.
26+
* @param {object} bookmark - A bookmark object with at least `contentnode_id` and `id`.
2827
*/
2928
export function setBookmark(bookmark) {
3029
set(bookmarksMap, bookmark.contentnode_id, bookmark);
3130
}
3231

3332
/**
3433
* Removes a bookmark from the shared bookmarksMap by contentnode_id.
35-
*
3634
* @param {string} contentnodeId - The content node ID to remove from the map.
3735
*/
3836
export function clearBookmark(contentnodeId) {
@@ -42,7 +40,6 @@ export function clearBookmark(contentnodeId) {
4240
/**
4341
* Creates a bookmark on the server and updates the local bookmarksMap.
4442
* On failure, removes the entry from the map.
45-
*
4643
* @param {string} contentnodeId - The content node ID to bookmark.
4744
* @returns {Promise} Promise that resolves with the created bookmark data.
4845
*/
@@ -71,7 +68,6 @@ export async function createBookmark(contentnodeId) {
7168
/**
7269
* Removes a bookmark from the server and updates the local bookmarksMap.
7370
* On failure, restores the bookmark back into the map.
74-
*
7571
* @param {string} contentnodeId - The content node ID whose bookmark to remove.
7672
* @returns {Promise} Promise that resolves when the bookmark is deleted.
7773
*/
@@ -99,8 +95,7 @@ export async function removeBookmark(contentnodeId) {
9995
export default function useBookmarks() {
10096
/**
10197
* Fetches bookmarks data and saves data to this composable's store.
102-
*
103-
* @param {Object} getParams - Parameters to filter by (e.g. { contentnode_id }).
98+
* @param {object} getParams - Parameters to filter by (e.g. { contentnode_id }).
10499
* @returns {Promise} Promise that resolves with the fetched bookmarks array.
105100
* @public
106101
*/

kolibri/plugins/learn/frontend/composables/useContentLink.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ export default function useContentLink() {
3939
* A function to generate a VueRouter link object that links to
4040
* either a resource or a topic, and generates query parameters
4141
* that allow creating a backlink to the route context in which
42-
* this link is generated
43-
* @param {string} id - the id of the node
44-
* @param {boolean} isResource - whether this is a resource or not
45-
* @return {Object} VueRouter link object
42+
* this link is generated.
43+
* @param {string} id - The id of the node.
44+
* @param {boolean} isResource - Whether this is a resource or not.
45+
* @param {string} [deviceId] - Override for the device id route parameter; defaults
46+
* to the device id on the current route.
47+
* @returns {object} VueRouter link object.
4648
*/
4749
function genContentLinkBackLinkCurrentPage(id, isResource = false, deviceId) {
4850
const query = _getBackLinkQuery();
@@ -69,9 +71,10 @@ export default function useContentLink() {
6971
* while maintaining the conceptual model of a single immersive overlay
7072
* that can be closed out, returning to the originating page that linked
7173
* to the original resource.
72-
* @param {string} id - the id of the node
73-
* @param {boolean} isResource - whether this is a resource or not
74-
* @return {Object} VueRouter link object
74+
* @param {string} id - The id of the node.
75+
* @param {boolean} isResource - Whether this is a resource or not.
76+
* @param {string} [deviceId] - Override for the device id route parameter.
77+
* @returns {object} VueRouter link object.
7578
*/
7679
function genContentLinkKeepCurrentBackLink(id, isResource = false, deviceId) {
7780
const oldQuery = route.query;
@@ -88,8 +91,9 @@ export default function useContentLink() {
8891
* while maintaining the conceptual model of a single immersive overlay
8992
* that can be closed out, returning to the originating page that linked
9093
* to the original parent topic of the resource.
91-
* @param {string} id - the id of the node
92-
* @return {Object} VueRouter link object
94+
* @param {string} id - The id of the node.
95+
* @param {string} [deviceId] - Override for the device id route parameter.
96+
* @returns {object} VueRouter link object.
9397
*/
9498
function genContentLinkKeepPreviousBackLink(id, deviceId) {
9599
const oldQuery = _decodeBackLinkQuery(route.query);

kolibri/plugins/learn/frontend/composables/useContentNodeProgress.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export function setContentNodeProgress(progress) {
3232
export default function useContentNodeProgress() {
3333
/**
3434
* Fetches content node progress data
35-
* and saves data to this composable's store
36-
*
37-
* @param {Object} getParams Parameters to filter by, should be the same as
35+
* and saves data to this composable's store.
36+
* @param {object} getParams - Parameters to filter by, should be the same as
3837
* the contentnodes fetched that we want the progress for.
39-
* @returns {Promise}
38+
* @returns {Promise<void>} Resolves once the progress data has been merged into
39+
* the shared store.
4040
* @public
4141
*/
4242
function fetchContentNodeProgress(getParams) {
@@ -52,12 +52,15 @@ export default function useContentNodeProgress() {
5252
}
5353

5454
/**
55-
* Fetches content node progress data
56-
* and saves data to this composable's store
57-
*
58-
* @param {Object} getParams Parameters to filter by, should be the same as
55+
* Fetches content node tree progress data and saves data to this composable's store.
56+
* @param {object} getParams - Parameters to filter by, should be the same as
5957
* the contentnodes fetched that we want the progress for.
60-
* @returns {Promise}
58+
* @param {string} getParams.id - The id of the parent content node whose tree progress
59+
* should be fetched.
60+
* @param {object} getParams.params - GET parameters forwarded to the tree progress
61+
* endpoint (e.g. pagination state).
62+
* @returns {Promise<void>} Resolves once the progress data has been merged into
63+
* the shared store.
6164
* @public
6265
*/
6366
function fetchContentNodeTreeProgress({ id, params }) {

kolibri/plugins/learn/frontend/composables/useCoreLearn.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import client from 'kolibri/client';
44
import urls from 'kolibri/urls';
55
import plugin_data from 'kolibri-plugin-data';
66

7+
/** @typedef {import('vue').Ref} Ref */
8+
79
/**
810
* Whether the user is in any classes
911
* @type {Ref<boolean>}
@@ -30,9 +32,11 @@ export function prepareLearnApp() {
3032
}
3133

3234
/**
33-
* @return {{
35+
* Returns the learn-app's reactive state flags for classroom membership and download
36+
* permissions.
37+
* @returns {{
3438
* canDownloadExternally: Ref<boolean>, canAddDownloads: Ref<boolean>, inClasses: Ref<boolean>
35-
* }}
39+
* }} Reactive learn-app state.
3640
*/
3741
export default function useCoreLearn() {
3842
return {

kolibri/plugins/learn/frontend/composables/useDevices.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { KolibriStudioId } from '../constants';
1616
import { learnStrings } from '../views/commonLearnStrings';
1717

1818
/**
19-
* The ref is defined in the outer scope so it can be used as a shared store
20-
* @type {Ref<NetworkLocation|null>}
19+
* The ref is defined in the outer scope so it can be used as a shared store.
20+
* @type {import('vue').Ref<?object>}
2121
*/
2222
const currentDevice = ref(null);
2323

@@ -78,9 +78,12 @@ export function setCurrentDevice(id) {
7878
}
7979

8080
/**
81-
* @param {string|null} routingDeviceId
82-
* @param {function(NetworkLocation):*} callback
83-
* @return {ComputedRef<*|null>}
81+
* Build a computed ref that runs `callback` against the current device only when
82+
* the device's `instance_id` matches the routed device id.
83+
* @param {import('vue').Ref<?string>} routingDeviceId - Reactive device id from the route.
84+
* @param {(device: object) => unknown} callback - Selector applied to the matching device.
85+
* @returns {import('vue').ComputedRef<unknown>} Computed ref returning the selector's
86+
* result, or undefined when the current device is not the routed device.
8487
*/
8588
function computedDevice(routingDeviceId, callback) {
8689
return computed(() => {

0 commit comments

Comments
 (0)