chore(typedoc-plugin-appium): move kind-related utils into the kind module

Nothing else will ever use them, so in they go
This commit is contained in:
Christopher Hiller
2023-02-10 13:26:21 -08:00
parent 2bbf42ff6b
commit fac31a3d68
2 changed files with 31 additions and 31 deletions

View File

@@ -8,7 +8,37 @@
* @module
*/
import {addReflectionKind} from './utils';
/**
* Adapted from `@knodes/typedoc-pluginutils`
* @see https://github.com/knodescommunity/typedoc-plugins
* Copyright (c) 2022 KnodesCommunity
* Licensed MIT
* @see https://github.com/KnodesCommunity/typedoc-plugins/blob/05717565fae14357b1c4be8122f3156e1d46d332/LICENSE
* @module
*/
import {ReflectionKind} from 'typedoc';
const getHigherBitMask = () =>
Math.max(
...Object.values({...ReflectionKind, All: -1})
.filter((value) => typeof value === 'number')
.map((v) => v.toString(2))
.filter((v) => v.match(/^0*10*$/))
.map((v) => parseInt(v, 2))
);
function addReflectionKind(name: string, value?: number | null) {
const kindAny = ReflectionKind as any;
const existingValue = kindAny[name];
if (existingValue !== null && existingValue !== undefined) {
return existingValue;
}
const defaultedValue = value ?? getHigherBitMask() * 2;
kindAny[name] = defaultedValue;
kindAny[defaultedValue] = name;
return defaultedValue;
}
/**
* Extends the TypeDoc's `ReflectionKind` to add namespaced kinds

View File

@@ -1,30 +0,0 @@
/**
* Adapted from `@knodes/typedoc-pluginutils`
* @see https://github.com/knodescommunity/typedoc-plugins
* Copyright (c) 2022 KnodesCommunity
* Licensed MIT
* @see https://github.com/KnodesCommunity/typedoc-plugins/blob/05717565fae14357b1c4be8122f3156e1d46d332/LICENSE
* @module
*/
import {ReflectionKind} from 'typedoc';
const getHigherBitMask = () =>
Math.max(
...Object.values({...ReflectionKind, All: -1})
.filter((value) => typeof value === 'number')
.map((v) => v.toString(2))
.filter((v) => v.match(/^0*10*$/))
.map((v) => parseInt(v, 2))
);
export const addReflectionKind = (name: string, value?: number | null) => {
const kindAny = ReflectionKind as any;
const existingValue = kindAny[name];
if (existingValue !== null && existingValue !== undefined) {
return existingValue;
}
const defaultedValue = value ?? getHigherBitMask() * 2;
kindAny[name] = defaultedValue;
kindAny[defaultedValue] = name;
return defaultedValue;
};