chore(typedoc-plugin-appium): just cleanup
MODIFY
packages/typedoc-plugin-appium/lib/converter/base-converter.ts
packages/typedoc-plugin-appium/lib/converter/base-converter.ts
@@ -2,12 +2,12 @@ import {Context} from 'typedoc';
import {AppiumPluginLogger} from '../logger';
import {ModuleCommands} from '../model';
-export abstract class BaseConverter<T> {
+export abstract class BaseConverter<Result> {
constructor(
protected ctx: Context,
protected log: AppiumPluginLogger,
protected readonly builtinCommands?: ModuleCommands
) {}
- abstract convert(): T;
+ abstract convert(): Result;
}

MODIFY
packages/typedoc-plugin-appium/lib/index.ts
packages/typedoc-plugin-appium/lib/index.ts
+/**
+ * Contains the {@link load entry point} for `@appium/typedoc-plugin-appium`
+ * @module
+ */
+
import _ from 'lodash';
import {Application, Context, Converter, DeclarationReflection} from 'typedoc';
import {convertCommands, createReflections, omitDefaultReflections} from './converter';
@@ -18,7 +23,9 @@ export function load(
// register our custom theme. the user still has to choose it
setup(app);
- // TypeDoc does not expect a return value here, but it's useful for testing
+ // TypeDoc does not expect a return value here, but it's useful for testing.
+ // note that this runs both methods "in parallel", but the `convert` method will always resolve
+ // first, and `postProcess` won't do any real work until that happens.
return Promise.allSettled([convert(app), postProcess(app)]);
}

MODIFY
packages/typedoc-plugin-appium/lib/options/index.ts
packages/typedoc-plugin-appium/lib/options/index.ts
@@ -23,10 +23,12 @@ export function configureOptions(app: Application): Application {
return app;
}
+type OptionDeclarations = typeof declarations;
+
export type AppiumPluginOptions = {
- [O in keyof typeof declarations]: (typeof declarations)[O]['type'] extends ParameterType.Boolean
+ [O in keyof OptionDeclarations]: OptionDeclarations[O]['type'] extends ParameterType.Boolean
? boolean
- : (typeof declarations)[O]['type'] extends ParameterType.String
+ : OptionDeclarations[O]['type'] extends ParameterType.String
? string
: unknown;
};

DELETE
packages/typedoc-plugin-appium/test/e2e/converter/comment.e2e.spec.ts
-import {expect} from 'chai';
-import {
- KnownMethods,
- BuiltinExternalDriverConverter,
- NAME_TYPES_MODULE,
- deriveComment,
-} from '../../../lib/converter';
-import {initConverter} from '../helpers';
-
-describe('@appium/typedoc-plugin-appium', function () {
- describe('comments', function () {
- let knownMethods: KnownMethods;
-
- before(async function () {
- const converter = await initConverter(BuiltinExternalDriverConverter, NAME_TYPES_MODULE);
- knownMethods = converter.convert();
- expect(knownMethods.size).to.be.greaterThan(0);
- expect(knownMethods.get('activateApp')).to.exist;
- });
-
- it('should', function () {});
- });
-});

MODIFY
packages/typedoc-plugin-appium/test/e2e/converter/converter.e2e.spec.ts
packages/typedoc-plugin-appium/test/e2e/converter/converter.e2e.spec.ts
@@ -31,7 +31,7 @@ describe('@appium/typedoc-plugin-appium', function () {
app.converter.once(Converter.EVENT_RESOLVE_BEGIN, (ctx: Context) => {
resolve(ctx);
});
- app.converter.convert(app.getEntryPoints()!);
+ app.convert();
});
log = new AppiumPluginLogger(app.logger, 'appium-test');
});

MODIFY
packages/typedoc-plugin-appium/test/e2e/helpers.ts
packages/typedoc-plugin-appium/test/e2e/helpers.ts
@@ -16,6 +16,8 @@ import {AppiumPluginLogger} from '../../lib/logger';
const {expect} = chai;
+const NAME_PACKAGE_JSON = 'package.json';
+
/**
* Name of the fake driver package which is good for testing
*/
@@ -32,7 +34,7 @@ export const ROOT_TSCONFIG = path.join(__dirname, '..', '..', '..', '..', 'tscon
* @returns Path to its entry point
*/
async function getEntryPoint(pkgName: string): Promise<string> {
- const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
+ const pkgDir = path.dirname(require.resolve(`${pkgName}/${NAME_PACKAGE_JSON}`));
if (!pkgDir) {
throw new TypeError(`Could not find package ${pkgName}!`);
}
@@ -42,9 +44,12 @@ async function getEntryPoint(pkgName: string): Promise<string> {
}
/**
- * Initializes a new TypeDoc application with some defaults
+ * Initializes a new TypeDoc application with some defaults.
+ *
+ * If `_FORCE_LOGS` is in the env, use verbose logging; otherwise logs are suppressed for your pleasure
+ *
+ * Note: if multiple entry points are provided, we assume that the `entryPointStrategy` should be `packages`
*
- * If `_FORCE_LOGS` is in the env, use verbose logging
* @param opts - Opts
* @returns New TypeDoc app
* @todo Figure out how to get plugin-specific options into TypeDoc other than via `Options.setValue`
@@ -61,9 +66,7 @@ function getTypedocApp(opts: Partial<TypeDocOptions> = {}): Application {
logLevel: forceLogs ? LogLevel.Verbose : LogLevel.Info,
logger: forceLogs ? undefined : 'none',
entryPointStrategy:
- opts.entryPoints && opts.entryPoints.length > 1
- ? EntryPointStrategy.Packages
- : EntryPointStrategy.Resolve,
+ opts.entryPoints?.length ?? 0 > 1 ? EntryPointStrategy.Packages : EntryPointStrategy.Resolve,
theme: THEME_NAME,
skipErrorChecking: true,
...opts,
@@ -90,7 +93,7 @@ export async function initAppForPkg(
/**
* Runs Typedoc against multiple packages (using `entryPointStrategy` of `packages`)
- * @param opts
+ * @param opts - Options; `entryPoints` is required
* @returns Typedoc Application
*/
export function initAppForPkgs({
@@ -98,8 +101,8 @@ export function initAppForPkgs({
...opts
}: SetRequired<Partial<TypeDocOptions>, 'entryPoints'>): Application {
let {entryPoints, ...typedocOpts} = opts;
- entryPoints = entryPoints?.map((pkgName) =>
- path.dirname(require.resolve(`${pkgName}/package.json`))
+ entryPoints = entryPoints.map((pkgName) =>
+ path.dirname(require.resolve(`${pkgName}/${NAME_PACKAGE_JSON}`))
);
// because entryPoints is a list of directories, this must be 'packages'
const entryPointStrategy = EntryPointStrategy.Packages;
@@ -113,11 +116,15 @@ export function initAppForPkgs({
* @param extraArgs Extra args to `cls`' constructor
* @returns Converter class instance
*/
-async function convert<T, C extends BaseConverter<T>, Args extends any = any>(
+async function convert<
+ ConvertResult,
+ SomeConverter extends BaseConverter<ConvertResult>,
+ Args extends any = any
+>(
app: Application,
- cls: Constructor<C, [Context, AppiumPluginLogger, ...Args[]]>,
+ cls: Constructor<SomeConverter, [Context, AppiumPluginLogger, ...Args[]]>,
extraArgs: Args[] = []
-): Promise<C> {
+): Promise<SomeConverter> {
return await new Promise((resolve, reject) => {
const listener = (ctx: Context) => {
const log = new AppiumPluginLogger(app.logger, `test-${cls.name}`);
@@ -142,7 +149,11 @@ async function convert<T, C extends BaseConverter<T>, Args extends any = any>(
* @param opts Extra args to `cls`' constructor and typedoc options
* @returns Converter class instance
*/
-export async function initConverter<T, C extends BaseConverter<T>, Args extends any = any>(
+export async function initConverter<
+ ConverterResult,
+ C extends BaseConverter<ConverterResult>,
+ Args extends any = any
+>(
cls: Constructor<C, [Context, AppiumPluginLogger, ...Args[]]>,
pkgName: string,
opts: InitConverterOptions<Args> = {}
@@ -153,6 +164,9 @@ export async function initConverter<T, C extends BaseConverter<T>, Args extends
return await convert(app, cls, extraArgs);
}
+/**
+ * Options for {@linkcode initConverter}
+ */
export interface InitConverterOptions<Args extends any = any> extends Partial<TypeDocOptions> {
extraArgs?: Args[];
}

chore(typedoc-plugin-appium): just cleanup