Search code examples
documentationtypedoc

How to create a Typedoc that documents only objects exposed via index.ts?


I am creating an NPM package that has index.js as entry point.

index.ts (which is compiled to index.js) only export a class Client.

Yet typedoc documents other classes that are not exposed to users, but area only used internally by Client.

Here is an example of such a module. I believe it is not exposed by the npm package I am writing, but I still export the module so that the Client module can use it.

import { Connection }  from '../connection';
import { Request, IRequestBody } from '.';
import { IServerResponse } from '../common';

export interface RecordingDeleteRequestBody extends IRequestBody {
    cmd: 'recording_delete';
    data: {
        recording_id: number;
    } 
}

export interface RecordingDeleteServerResponse extends IServerResponse {
    cmd: 'recording_delete';
}

export type RecordingDeleteResponse = true;


export class RecordingDeleteRequest extends Request {
    constructor(
        recordingId: number,
        transactionId: string, 
        connection: Connection, 
        maxTime: number
    ) {
        let requestBody: RecordingDeleteRequestBody = {
            type: 'request',
            cmd: 'recording_delete',
            data: { recording_id: recordingId }
        }

        super(requestBody, transactionId, connection, maxTime);
    }

    async run(): Promise<RecordingDeleteResponse> {
        await new Promise<RecordingDeleteServerResponse>((resolve, reject) => {
            this.connection.push(
                this.requestBody, 
                this.transactionId, 
                this.maxTime, 
                resolve, 
                reject
            );
        });

        return true;
    }
}

How can I purge these classes from my typedoc docs?

I only want the docs for the client method, Class.recordingDeleteRequest(), that uses this class to be created.

export default class Client {
    public async recordingDelete(recordingId: number) {
        let req = new requests.RecordingDeleteRequest(recordingId, this.newTransactionId(), this.connection!, this.defaultMaxWaitForResponse)
        return await req.run();
    }
}

Solution

  • TypeDoc does not yet support only documenting exported symbols (see issue #639). The @ignore doc comment can be used to manually hide individual symbols.