fix(typedoc-plugin-appium): better top-level header for extension reflection
It now shows "Command API" if there's only one 3p extension we're documenting, and "(name) Command API" if there are multiple (e.g. in the case of a monorepo)
MODIFY
packages/typedoc-plugin-appium/lib/model/reflection/extension.ts
packages/typedoc-plugin-appium/lib/model/reflection/extension.ts
-import {DeclarationReflection} from 'typedoc';
+import _ from 'lodash';
+import {DeclarationReflection, ProjectReflection} from 'typedoc';
+import {NAME_BUILTIN_COMMAND_MODULE} from '../../converter';
import {ModuleCommands} from '../module-commands';
import {ExecMethodDataSet, ParentReflection, RouteMap} from '../types';
import {AppiumPluginReflectionKind} from './kind';
@@ -49,6 +51,19 @@ export class ExtensionReflection extends DeclarationReflection {
this.execMethodDataSet = execMethodDataSet;
}
+ /**
+ * Returns `true` if the project contains more than one `ExtensionReflection` that isn't built-in commands.
+ *
+ * Should **not** be called before the TypeDoc converter has emitted `EVENT_RESOLVE_END`
+ */
+ static isCompositeProject = _.memoize((project: ProjectReflection) => {
+ return (
+ project
+ .getChildrenByKind(AppiumPluginReflectionKind.Extension as any)
+ ?.filter(({name}) => name !== NAME_BUILTIN_COMMAND_MODULE).length > 1
+ );
+ });
+
/**
* This is called by `AppiumTheme`'s `getUrl` method, which causes a particular filename to be used.
*
@@ -70,6 +85,19 @@ export class ExtensionReflection extends DeclarationReflection {
return alias;
}
+ /**
+ * Returns the title for display. Used as the first-level header for rendered page.
+ *
+ * If this is a composite project, the title will be "Command API" prefixed by the name of the
+ * module, otherwise it's just "Command API"
+ */
+ public get extensionTitle(): string {
+ if (ExtensionReflection.isCompositeProject(this.project)) {
+ return `${this.name} Command API`;
+ }
+ return 'Command API';
+ }
+
/**
* Returns number of execute methods in this data
*/

MODIFY
packages/typedoc-plugin-appium/lib/theme/resources/templates/extension.hbs
packages/typedoc-plugin-appium/lib/theme/resources/templates/extension.hbs
{{> header}}
-{{#ifShowPageTitle}}
-
-# {{{reflectionTitle true}}}
-
-{{/ifShowPageTitle}}
-
{{#with model}}
+# {{extensionTitle}}
+
{{#if hasComment}}
{{> comment}}

fix(typedoc-plugin-appium): better top-level header for extension reflection

It now shows "Command API" if there's only one 3p extension we're documenting, and "(name) Command API" if there are multiple (e.g. in the case of a monorepo)