mirror of
https://github.com/appium/appium.git
synced 2026-02-23 03:40:15 -06:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user