docs: fix typedoc generation with inheritance
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Apr 2023 12:49:45 +0000 (14:49 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Apr 2023 12:49:45 +0000 (14:49 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
14 files changed:
.eslintrc.js
src/pools/abstract-pool.ts
src/pools/cluster/dynamic.ts
src/pools/cluster/fixed.ts
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
src/pools/selection-strategies/less-busy-worker-choice-strategy.ts
src/pools/selection-strategies/less-used-worker-choice-strategy.ts
src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
src/pools/thread/dynamic.ts
src/pools/thread/fixed.ts
src/worker/cluster-worker.ts
src/worker/thread-worker.ts

index 0987025540001c47debfb418c2cac1b5b7b57178..4fc348072f5fb5cb316c2130873d0018744baa8f 100644 (file)
@@ -93,7 +93,7 @@ module.exports = defineConfig({
           'error',
           { ignoreProperties: true }
         ],
-        'tsdoc/syntax': 'error'
+        'tsdoc/syntax': 'warn'
       }
     },
     {
index ad21effb3bbb9837977a54c2f8c159c85af6b3c8..68e833710f802d7bd30f52bab9955dc373072c35 100644 (file)
@@ -25,10 +25,10 @@ export abstract class AbstractPool<
   Data = unknown,
   Response = unknown
 > implements IPoolInternal<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly workers: Array<WorkerType<Worker>> = []
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly emitter?: PoolEmitter
 
   /**
@@ -154,7 +154,7 @@ export abstract class AbstractPool<
     this.opts.enableEvents = opts.enableEvents ?? true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract get type (): PoolType
 
   /**
@@ -174,7 +174,7 @@ export abstract class AbstractPool<
     return this.workers.findIndex(workerItem => workerItem.worker === worker)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public setWorkerChoiceStrategy (
     workerChoiceStrategy: WorkerChoiceStrategy
   ): void {
@@ -193,10 +193,10 @@ export abstract class AbstractPool<
     )
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract get full (): boolean
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract get busy (): boolean
 
   protected internalBusy (): boolean {
@@ -206,14 +206,14 @@ export abstract class AbstractPool<
     )
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public findFreeWorkerKey (): number {
     return this.workers.findIndex(workerItem => {
       return workerItem.tasksUsage.running === 0
     })
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public async execute (data: Data): Promise<Response> {
     const [workerKey, worker] = this.chooseWorker()
     const messageId = crypto.randomUUID()
@@ -229,7 +229,7 @@ export abstract class AbstractPool<
     return res
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public async destroy (): Promise<void> {
     await Promise.all(
       this.workers.map(async workerItem => {
@@ -239,7 +239,7 @@ export abstract class AbstractPool<
   }
 
   /**
-   * Shutdowns given worker.
+   * Shutdowns given worker in the pool.
    *
    * @param worker - A worker within `workers`.
    */
@@ -248,6 +248,8 @@ export abstract class AbstractPool<
   /**
    * Setup hook that can be overridden by a Poolifier pool implementation
    * to run code before workers are created in the abstract constructor.
+   *
+   * @virtual
    */
   protected setupHook (): void {
     // Can be overridden
@@ -341,6 +343,7 @@ export abstract class AbstractPool<
    * Can be used to update the `maxListeners` or binding the `main-worker`\<-\>`worker` connection if not bind by default.
    *
    * @param worker - The newly created worker.
+   * @virtual
    */
   protected abstract afterWorkerSetup (worker: Worker): void
 
@@ -423,7 +426,7 @@ export abstract class AbstractPool<
   }
 
   /**
-   * Gets worker tasks usage.
+   * Gets the given worker tasks usage in the pool.
    *
    * @param worker - The worker.
    * @returns The worker tasks usage.
index 79f684cbd39a2990f0b7f968e41cf7dda9d70569..6171ce4e8a4b51991294677b680e9373d8e64313 100644 (file)
@@ -34,17 +34,17 @@ export class DynamicClusterPool<
     super(min, filePath, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get type (): PoolType {
     return PoolType.DYNAMIC
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get full (): boolean {
     return this.workers.length === this.max
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get busy (): boolean {
     return this.full && this.findFreeWorkerKey() === -1
   }
index d644f2298000fe1b6176f335ff228e51483e9144..78de7073b615fc10936091aca0cd203165efaac8 100644 (file)
@@ -55,28 +55,28 @@ export class FixedClusterPool<
     super(numberOfWorkers, filePath, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected setupHook (): void {
     cluster.setupPrimary({ ...this.opts.settings, exec: this.filePath })
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected isMain (): boolean {
     return cluster.isPrimary
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public destroyWorker (worker: Worker): void {
     this.sendToWorker(worker, { kill: 1 })
     worker.kill()
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected sendToWorker (worker: Worker, message: MessageValue<Data>): void {
     worker.send(message)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public registerWorkerMessageListener<Message extends Data | Response>(
     worker: Worker,
     listener: (message: MessageValue<Message>) => void
@@ -84,28 +84,28 @@ export class FixedClusterPool<
     worker.on('message', listener)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected createWorker (): Worker {
     return cluster.fork(this.opts.env)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected afterWorkerSetup (worker: Worker): void {
     // Listen to worker messages.
     this.registerWorkerMessageListener(worker, super.workerListener())
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get type (): PoolType {
     return PoolType.FIXED
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get full (): boolean {
     return this.workers.length === this.numberOfWorkers
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get busy (): boolean {
     return this.internalBusy()
   }
index 332b3fc103bdffcd2e0339d1153651441d2c29da..0d337b53191f4a991368ea66976761d95fda1027 100644 (file)
@@ -18,9 +18,9 @@ export abstract class AbstractWorkerChoiceStrategy<
   Data = unknown,
   Response = unknown
 > implements IWorkerChoiceStrategy<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly isDynamicPool: boolean
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public requiredStatistics: RequiredStatistics = {
     runTime: false,
     avgRunTime: false
@@ -38,12 +38,12 @@ export abstract class AbstractWorkerChoiceStrategy<
     this.choose.bind(this)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract reset (): boolean
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract choose (): number
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public abstract remove (workerKey: number): boolean
 }
index 60c22a299df6ee2825dc63a79e9c405fe72d3312..f8427d01bab393ae47c9d6975d31e14338f5c74d 100644 (file)
@@ -28,7 +28,7 @@ export class FairShareWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly requiredStatistics: RequiredStatistics = {
     runTime: true,
     avgRunTime: true
@@ -42,13 +42,13 @@ export class FairShareWorkerChoiceStrategy<
   WorkerVirtualTaskTimestamp
   > = new Map<number, WorkerVirtualTaskTimestamp>()
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public reset (): boolean {
     this.workerLastVirtualTaskTimestamp.clear()
     return true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public choose (): number {
     let minWorkerVirtualTaskEndTimestamp = Infinity
     let chosenWorkerKey!: number
@@ -66,7 +66,7 @@ export class FairShareWorkerChoiceStrategy<
     return chosenWorkerKey
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public remove (workerKey: number): boolean {
     const workerDeleted = this.workerLastVirtualTaskTimestamp.delete(workerKey)
     for (const [key, value] of this.workerLastVirtualTaskTimestamp.entries()) {
index 9952a41df80fc191fcbcc829d5389f7f720ba02c..a9c5500462df9ddafa004bc9988b27fe6177007b 100644 (file)
@@ -19,18 +19,18 @@ export class LessBusyWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly requiredStatistics: RequiredStatistics = {
     runTime: true,
     avgRunTime: false
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public reset (): boolean {
     return true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public choose (): number {
     const freeWorkerKey = this.pool.findFreeWorkerKey()
     if (freeWorkerKey !== -1) {
@@ -50,7 +50,7 @@ export class LessBusyWorkerChoiceStrategy<
     return lessBusyWorkerKey
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public remove (workerKey: number): boolean {
     return true
   }
index dffed99e8f6ece8658fd6b22688598e1374ece6b..f3b45e06ccd671ef782cdcb87e8264858ac48732 100644 (file)
@@ -16,12 +16,12 @@ export class LessUsedWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public reset (): boolean {
     return true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public choose (): number {
     const freeWorkerKey = this.pool.findFreeWorkerKey()
     if (freeWorkerKey !== -1) {
@@ -42,7 +42,7 @@ export class LessUsedWorkerChoiceStrategy<
     return lessUsedWorkerKey
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public remove (workerKey: number): boolean {
     return true
   }
index 91ceb5bc9ade9e8d8df8be244c54fd105b76771a..9cc966c47956a9a1689f82a435168127bbfbd272 100644 (file)
@@ -21,13 +21,13 @@ export class RoundRobinWorkerChoiceStrategy<
    */
   private nextWorkerId: number = 0
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public reset (): boolean {
     this.nextWorkerId = 0
     return true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public choose (): number {
     const chosenWorkerKey = this.nextWorkerId
     this.nextWorkerId =
@@ -37,7 +37,7 @@ export class RoundRobinWorkerChoiceStrategy<
     return chosenWorkerKey
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public remove (workerKey: number): boolean {
     if (this.nextWorkerId === workerKey) {
       if (this.pool.workers.length === 0) {
index e1325865eaba7df03f0d36b277599bd828be5b34..997366cd5984c49fe973896b8dce8ce4d389e4f2 100644 (file)
@@ -30,7 +30,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy<Worker, Data, Response> {
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public readonly requiredStatistics: RequiredStatistics = {
     runTime: true,
     avgRunTime: true
@@ -63,7 +63,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     this.initWorkersTaskRunTime()
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public reset (): boolean {
     this.currentWorkerId = 0
     this.workersTaskRunTime.clear()
@@ -71,7 +71,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     return true
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public choose (): number {
     const chosenWorkerKey = this.currentWorkerId
     if (this.isDynamicPool && !this.workersTaskRunTime.has(chosenWorkerKey)) {
@@ -99,7 +99,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     return chosenWorkerKey
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public remove (workerKey: number): boolean {
     if (this.currentWorkerId === workerKey) {
       if (this.pool.workers.length === 0) {
index 33e42892c424a671caf547148aa4deacaf83f5f8..62ddba9fc4792148a47f69c51c8c6f7a01b3adb0 100644 (file)
@@ -35,17 +35,17 @@ export class DynamicThreadPool<
     super(min, filePath, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get type (): PoolType {
     return PoolType.DYNAMIC
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get full (): boolean {
     return this.workers.length === this.max
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get busy (): boolean {
     return this.full && this.findFreeWorkerKey() === -1
   }
index 2c4f66f0ff4d8be12d192f4028b1b1a17262bbc7..a95a86034fcf13abc471862bbe9d51d8aa4604d1 100644 (file)
@@ -45,12 +45,12 @@ export class FixedThreadPool<
     super(numberOfThreads, filePath, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected isMain (): boolean {
     return isMainThread
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public async destroyWorker (
     worker: ThreadWorkerWithMessageChannel
   ): Promise<void> {
@@ -58,7 +58,7 @@ export class FixedThreadPool<
     await worker.terminate()
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected sendToWorker (
     worker: ThreadWorkerWithMessageChannel,
     message: MessageValue<Data>
@@ -66,7 +66,7 @@ export class FixedThreadPool<
     worker.postMessage(message)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public registerWorkerMessageListener<Message extends Data | Response>(
     messageChannel: ThreadWorkerWithMessageChannel,
     listener: (message: MessageValue<Message>) => void
@@ -74,14 +74,14 @@ export class FixedThreadPool<
     messageChannel.port2?.on('message', listener)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected createWorker (): ThreadWorkerWithMessageChannel {
     return new Worker(this.filePath, {
       env: SHARE_ENV
     })
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected afterWorkerSetup (worker: ThreadWorkerWithMessageChannel): void {
     const { port1, port2 } = new MessageChannel()
     worker.postMessage({ parent: port1 }, [port1])
@@ -91,17 +91,17 @@ export class FixedThreadPool<
     this.registerWorkerMessageListener(worker, super.workerListener())
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get type (): PoolType {
     return PoolType.FIXED
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get full (): boolean {
     return this.workers.length === this.numberOfWorkers
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   public get busy (): boolean {
     return this.internalBusy()
   }
index 43e86dd751a5cf8f17a35bbc40185c1ab978920a..655520ccedb84aeccc0c1231dfb7c4566747e2c0 100644 (file)
@@ -38,12 +38,12 @@ export class ClusterWorker<
     )
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected sendToMainWorker (message: MessageValue<Response>): void {
     this.getMainWorker().send(message)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected handleError (e: Error | string): string {
     return e instanceof Error ? e.message : e
   }
index 639fd19c8437fdb478aeea0ebc481bc9125f019b..ac775a09842c970629a07ef29fa5b961a8e53a9c 100644 (file)
@@ -32,7 +32,7 @@ export class ThreadWorker<
     super('worker-thread-pool:poolifier', isMainThread, fn, parentPort, opts)
   }
 
-  /** {@inheritDoc} */
+  /** @inheritDoc */
   protected sendToMainWorker (message: MessageValue<Response>): void {
     this.getMainWorker().postMessage(message)
   }