fix(typedoc-plugin-appium): use simple filenames for ExtensionReflection objects
Closes
MODIFY
packages/appium/docs/mkdocs-en.yml
packages/appium/docs/mkdocs-en.yml
@@ -46,8 +46,8 @@ nav:
- guides/grid.md
- guides/caching.md
- Developer Reference:
- - BaseDriver Commands: reference/commands/appium_base_driver-1._appium_base_driver.md
- - FakeDriver Commands: reference/commands/appium_fake_driver-1._appium_fake_driver.md
+ - BaseDriver Commands: reference/commands/base-driver.md
+ - FakeDriver Commands: reference/commands/fake-driver.md
- Ecosystem:
- ecosystem/index.md
- Developing Appium Extensions:

MODIFY
packages/typedoc-plugin-appium/lib/model/reflection/extension.ts
packages/typedoc-plugin-appium/lib/model/reflection/extension.ts
@@ -3,6 +3,8 @@ import {ModuleCommands} from '../module-commands';
import {ExecMethodDataSet, ParentReflection, RouteMap} from '../types';
import {AppiumPluginReflectionKind} from './kind';
+const SCOPED_PACKAGE_NAME_REGEX = /^(@[^/]+)\/([^/]+)$/;
+
/**
* A reflection containing data about commands and/or execute methods.
*
@@ -18,6 +20,13 @@ export class ExtensionReflection extends DeclarationReflection {
*/
public readonly routeMap: RouteMap;
+ public override hasOwnDocument = true;
+
+ /**
+ * Cached value of {@linkcode ExtensionReflection.getAlias}
+ */
+ #alias: string | undefined;
+
/**
*
* @param name Name of module containing commands
@@ -40,6 +49,34 @@ export class ExtensionReflection extends DeclarationReflection {
this.execMethodDataSet = execMethodDataSet;
}
+ /**
+ * This is called by `AppiumTheme`'s `getUrl` method, which causes a particular filename to be used.
+ *
+ * - The name of an `ExtensionReflection` is the name of the module containing commands
+ * - If that name is a _scoped package name_, we strip the scope and delimiter
+ * - Replaces any non-alphanumeric characters with `-`
+ * @returns The "alias", whatever that means
+ */
+ public override getAlias(): string {
+ if (this.#alias) {
+ return this.#alias;
+ }
+
+ let alias: string;
+ let matches = this.name.match(SCOPED_PACKAGE_NAME_REGEX);
+ alias = matches ? matches[2] : this.name;
+ alias = alias.replace(/\W/, '-');
+ this.#alias = alias;
+ return alias;
+ }
+
+ /**
+ * Returns number of execute methods in this data
+ */
+ public get execMethodCount(): number {
+ return this.execMethodDataSet.size;
+ }
+
/**
* Returns `true` if there are any "execute commands" in this set.
*
@@ -64,11 +101,4 @@ export class ExtensionReflection extends DeclarationReflection {
public get routeCount(): number {
return this.routeMap.size;
}
-
- /**
- * Returns number of execute methods in this data
- */
- public get execMethodCount(): number {
- return this.execMethodDataSet.size;
- }
}

MODIFY
packages/typedoc-plugin-appium/lib/theme/index.ts
packages/typedoc-plugin-appium/lib/theme/index.ts
-import {Application, ContainerReflection, PageEvent, ReflectionKind, Renderer} from 'typedoc';
+import {
+ Application,
+ ContainerReflection,
+ PageEvent,
+ Reflection,
+ ReflectionKind,
+ Renderer,
+} from 'typedoc';
import {MarkdownTheme} from 'typedoc-plugin-markdown';
import {AppiumPluginLogger} from '../logger';
import {AppiumPluginReflectionKind, NS} from '../model';
@@ -59,6 +66,21 @@ export class AppiumTheme extends MarkdownTheme {
registerHelpers();
}
+ /**
+ * Special-cases `ExtensionReflection` instances to make the filename shorter and thus better
+ * suitable for `mkdocs`.
+ * @param reflection Reflection to get URL for
+ * @returns String URL
+ */
+ public override getUrl(reflection: Reflection) {
+ if (reflection.kindOf(AppiumPluginReflectionKind.Extension as any)) {
+ // I don't know what this replace is for, but the superclass does it, so maybe it's important.
+ return reflection.getAlias().replace('^_', '');
+ }
+ return super.getUrl(reflection);
+ }
+
+ /**
/**
* A lookup of {@linkcode ReflectionKind}s to templates. It also controls in which directory the output files live.
*

fix(typedoc-plugin-appium): use simple filenames for ExtensionReflection objects

Closes #18110