Skip to content

Commit 117d0e8

Browse files
authored
Merge pull request #1135 from mathjax/refactor/more_jsdoc
Documentation cleanup
2 parents 3778b16 + 433f7fc commit 117d0e8

87 files changed

Lines changed: 319 additions & 272 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 0 additions & 45 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ export default tseslint.config({
2020
ignores: ["**/*.d.ts", "**/*.js"],
2121
"rules": {
2222
"@typescript-eslint/no-explicit-any": "off",
23-
"@typescript-eslint/explicit-module-boundary-types": "off",
24-
"@typescript-eslint/no-empty-function": "off",
25-
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
23+
"@typescript-eslint/no-unused-vars": ["error",
24+
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_",
25+
"caughtErrorsIgnorePattern": "^_" }
26+
],
2627
"@typescript-eslint/no-empty-object-type": ["error", {"allowInterfaces": "with-single-extends"}],
27-
"no-inner-declarations": "off",
2828
"prefer-const": ["error", {"destructuring": "all"}],
29-
"jsdoc/tag-lines": ["warn", "always", {"count": 0, "startLines": 1}],
30-
"jsdoc/require-param-type": "off",
31-
"jsdoc/require-returns-type": "off"
29+
"jsdoc/tag-lines": ["warn", "always", {"count": 0, "startLines": 1}]
3230
}
3331
});
3432

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { Explorer, AbstractExplorer } from './Explorer.js';
3333
import { ExplorerPool } from './ExplorerPool.js';
3434
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
3535
import { honk, InPlace } from '../speech/SpeechUtil.js';
36+
import { GeneratorPool } from '../speech/GeneratorPool.js';
3637
import { Sre } from '../sre.js';
3738

3839
/**
@@ -121,9 +122,9 @@ export class SpeechExplorer
121122
/**
122123
* Convenience getter for generator pool of the item.
123124
*
124-
* @returns The item's generator pool.
125+
* @returns {GeneratorPool} The item's generator pool.
125126
*/
126-
private get generators() {
127+
private get generators(): GeneratorPool<HTMLElement, Text, Document> {
127128
return this.item?.generatorPool;
128129
}
129130

ts/a11y/speech/SpeechMenu.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ function csPrefsVariables(menu: MJContextMenu, prefs: string[]) {
6767
*
6868
* @param {MJContextMenu} menu The current context menu.
6969
* @param {string} locale The current locale.
70-
* @returns The constructed selection box sub menu.
70+
* @returns {object} The constructed selection box sub menu.
7171
*/
72-
function csSelectionBox(menu: MJContextMenu, locale: string) {
72+
function csSelectionBox(menu: MJContextMenu, locale: string): object {
7373
const prefs = Sre.clearspeakPreferences.getLocalePreferences();
7474
const props = prefs[locale];
7575
if (!props) {
@@ -111,9 +111,9 @@ function csSelectionBox(menu: MJContextMenu, locale: string) {
111111
* Generates the menu items for the base preference menu.
112112
*
113113
* @param {string} previous The currently set preferences.
114-
* @returns The menu items.
114+
* @returns {object[]} The menu items as a list of JSON objects.
115115
*/
116-
function basePreferences(previous: string) {
116+
function basePreferences(previous: string): object[] {
117117
const items = [
118118
{
119119
type: 'radio',
@@ -140,9 +140,13 @@ function basePreferences(previous: string) {
140140
* @param {string} previous The currently set preferences.
141141
* @param {string} smart The semantic type of the smart preferences.
142142
* @param {string} locale The current locale.
143-
* @returns The menu of the smart choices.
143+
* @returns {object[]} The menu of smart choices as a list of JSON objects.
144144
*/
145-
function smartPreferences(previous: string, smart: string, locale: string) {
145+
function smartPreferences(
146+
previous: string,
147+
smart: string,
148+
locale: string
149+
): object[] {
146150
const prefs = Sre.clearspeakPreferences.getLocalePreferences();
147151
const loc = prefs[locale];
148152
if (!loc) {

ts/adaptors/HTMLAdaptor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ export interface MinDocument<N, T> {
4242
body: N;
4343
title: string;
4444
doctype: { name: string };
45-
/* tslint:disable:jsdoc-require */
4645
createElement(kind: string): N;
4746
createElementNS(ns: string, kind: string): N;
4847
createTextNode(text: string): T;
4948
querySelectorAll(selector: string): ArrayLike<N>;
50-
/* tslint:enable */
5149
}
5250

5351
/*****************************************************************/
@@ -81,7 +79,6 @@ export interface MinHTMLElement<N, T> {
8179
childNodes: (N | T)[] | NodeList;
8280
firstChild: N | T | Node;
8381
lastChild: N | T | Node;
84-
/* tslint:disable:jsdoc-require */
8582
getElementsByTagName(name: string): N[] | HTMLCollectionOf<Element>;
8683
getElementsByTagNameNS(
8784
ns: string,
@@ -100,7 +97,6 @@ export interface MinHTMLElement<N, T> {
10097
hasAttribute(name: string): boolean;
10198
getBoundingClientRect(): object;
10299
getBBox?(): { x: number; y: number; width: number; height: number };
103-
/* tslint:endable */
104100
}
105101

106102
/*****************************************************************/

ts/components/latest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ function requestXML(
376376
) {
377377
const request = getXMLHttpRequest();
378378
if (request) {
379-
// tslint:disable-next-line:jsdoc-require
380379
request.onreadystatechange = function () {
381380
if (request.readyState === 4) {
382381
if (request.status === 200) {

ts/components/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ export const PathFilters: { [name: string]: PathFilterFunction } = {
136136
/**
137137
* Recursively replace path prefixes (e.g., [mathjax], [tex], etc.)
138138
*
139-
* @param data The data object containing the filter functions
140-
* @returns True
139+
* @param {PathFilterFunction} data The data object containing the filter functions
140+
* @returns {boolean} True
141141
*/
142142
prefix: (data) => {
143143
let match;

ts/components/package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ export type PackageMap = Map<string, Package>;
3838
* An error class that includes the package name
3939
*/
4040
export class PackageError extends Error {
41-
/* tslint:disable:jsdoc-require */
4241
public package: string;
4342
constructor(message: string, name: string) {
4443
super(message);
4544
this.package = name;
4645
}
47-
/* tslint:enable */
4846
}
4947

5048
/**
@@ -155,7 +153,8 @@ export class Package {
155153
}
156154

157155
/**
158-
* @param {string} name A promise for when extra files and checkReady have been fulfilled
156+
* @param {string} name The package configuration to be loaded
157+
* @returns {Promise<void>} A promise for when extra files and checkReady have been fulfilled
159158
*/
160159
public static loadPromise(name: string): Promise<void> {
161160
const config = (CONFIG[name] || {}) as PackageConfig;
@@ -249,8 +248,9 @@ export class Package {
249248
/**
250249
* @param {Promise<string>[]} promises The array or promises that must be resolved before
251250
* this package can load
251+
* @returns {Promise<string>} The promise indicating when this file is loaded
252252
*/
253-
protected makePromise(promises: Promise<string>[]) {
253+
protected makePromise(promises: Promise<string>[]): Promise<string> {
254254
//
255255
// Make a promise and save its resolve/reject functions
256256
//

ts/components/startup.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export interface MathJaxObject extends MJObject {
105105
document: MATHDOCUMENT;
106106
promise: Promise<void>;
107107
rerenderPromise: Promise<void>;
108-
/* tslint:disable:jsdoc-require */
109108
registerConstructor(name: string, constructor: any): void;
110109
useHandler(name: string, force?: boolean): void;
111110
useAdaptor(name: string, force?: boolean): void;
@@ -125,7 +124,6 @@ export interface MathJaxObject extends MJObject {
125124
getOutputJax(): OUTPUTJAX;
126125
getAdaptor(): DOMADAPTOR;
127126
getHandler(): HANDLER;
128-
/* tslint:enable */
129127
};
130128
[name: string]: any; // Needed for the methods created by the startup module
131129
}
@@ -320,8 +318,10 @@ export namespace Startup {
320318
* typesetting, if needed.
321319
*
322320
* Setting Mathjax.startup.pageReady in the configuration will override this.
321+
*
322+
* @returns {Promise<void>} Promise resolving when page is ready to process.
323323
*/
324-
export function defaultPageReady() {
324+
export function defaultPageReady(): Promise<void> {
325325
return (
326326
CONFIG.loadAllFontFiles && (output as COMMONJAX).font
327327
? (output as COMMONJAX).font.loadDynamicFiles()
@@ -338,9 +338,10 @@ export namespace Startup {
338338
/**
339339
* Perform the typesetting with handling of retries
340340
*
341-
* @param elements The list of elements to typeset
341+
* @param {any[]} elements The list of elements to typeset
342+
* @returns {Promise<void>} The promise that resolves when elements are typeset
342343
*/
343-
export function typesetPromise(elements: any[]) {
344+
export function typesetPromise(elements: any[]): Promise<void> {
344345
document.options.elements = elements;
345346
document.reset();
346347
return mathjax.handleRetriesFor(() => {

ts/core/MathItem.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ export type ProtoItem<N, T> = {
228228
/**
229229
* Produce a proto math item that can be turned into a MathItem
230230
*
231-
* @param open The opening delimiter
232-
* @param math The math expression itself
233-
* @param close The closing delimiter
234-
* @param n The index of the string in which this math is
235-
* @param start The starting location of the math
236-
* @param end The ending location of the math
237-
* @param display True means display mode, false is inline mode
238-
* @returns The proto math item
231+
* @param {string} open The opening delimiter
232+
* @param {string} math The math expression itself
233+
* @param {string} close The closing delimiter
234+
* @param {number} n The index of the string in which this math is
235+
* @param {number} start The starting location of the math
236+
* @param {number} end The ending location of the math
237+
* @param {boolean} display True means display mode, false is inline mode
238+
* @returns {ProtoItem<N, T>} The proto math item
239239
* @template N The HTMLElement node class
240240
* @template T The Text node class
241241
*/

0 commit comments

Comments
 (0)