Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEROM22 committed Dec 9, 2024
1 parent 4413f17 commit 3740da0
Show file tree
Hide file tree
Showing 2 changed files with 383 additions and 160 deletions.
79 changes: 27 additions & 52 deletions packages/typedoc-signature/lib/internal/concise.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// TODO: remove flat()
import {
type Declaration,
type Entity,
GroupEntity,
} from "@onlyoffice/library-declaration/next.ts"
import {type Declaration, type DeclarationEntity} from "@onlyoffice/library-declaration/next.ts"
import {
ParameterToken,
type Signature,
Expand All @@ -24,34 +20,32 @@ import {
isInterfaceReflection,
isMethodReflection,
isParameterReflection,
isProjectReflection,
isPropertyReflection,
isSignatureReflection,
isTypeAliasReflection,
isVariableReflection,
} from "@onlyoffice/typedoc-util-is-reflection"
import {type JSONOutput as J} from "typedoc"
import {type ComputeRepository} from "../main.ts"

export function concise(r: J.Reflection, e: Entity): void {
if (!isProjectReflection(r)) {
throw new Error("Expected a project reflection")
}

if (e instanceof GroupEntity) {
export function concise(r: ComputeRepository, e: DeclarationEntity): void {
const f = r.trailOf(e.declaration)
if (!f) {
return
}

const f = e.declaration.trail.flat(Infinity)
const t = resolve(r, f)
const t = r.reflectionOf(f)
f.pop()
const p = resolve(r, f)
const p = r.reflectionOf(f)

if (e.declaration.parameters.length !== 0) {
fragment(r, e.declaration)
}
if (isClassReflection(t)) {
classDeclaration(t, e.declaration)
return
}
if (isConstructorReflection(p) && isSignatureReflection(t)) {
constructorDeclaration(r, e.declaration)
constructorDeclaration(t, e.declaration)
return
}
if (isEnumMemberReflection(t)) {
Expand All @@ -63,15 +57,15 @@ export function concise(r: J.Reflection, e: Entity): void {
return
}
if (isFunctionReflection(p) && isCallSignatureReflection(t)) {
functionsDeclaration(r, e.declaration)
functionsDeclaration(t, e.declaration)
return
}
if (isInterfaceReflection(t)) {
interfaceReflection(t, e.declaration)
return
}
if (isMethodReflection(p) && isCallSignatureReflection(t)) {
methodDeclaration(r, e.declaration)
methodDeclaration(t, e.declaration)
return
}
if (isPropertyReflection(t)) {
Expand Down Expand Up @@ -106,10 +100,7 @@ export function classDeclaration(c: J.Reflection, d: Declaration): void {
d.signature.concise = s
}

export function constructorDeclaration(r: J.Reflection, d: Declaration): void {
const tt = d.trail.flat(Infinity)
const c = resolve(r, tt)

export function constructorDeclaration(c: J.Reflection, d: Declaration): void {
if (!isSignatureReflection(c)) {
return
}
Expand All @@ -120,10 +111,6 @@ export function constructorDeclaration(r: J.Reflection, d: Declaration): void {
s.push(...b)

d.signature.concise = s

if (d.parameters.length !== 0) {
fragment(r, d)
}
}

export function enumMemberReflection(e: J.Reflection, d: Declaration): void {
Expand Down Expand Up @@ -169,10 +156,7 @@ export function enumReflection(e: J.Reflection, d: Declaration): void {
d.signature.concise = s
}

export function functionsDeclaration(r: J.Reflection, d: Declaration): void {
const tt = d.trail.flat(Infinity)
const f = resolve(r, tt)

export function functionsDeclaration(f: J.Reflection, d: Declaration): void {
if (!isCallSignatureReflection(f)) {
return
}
Expand Down Expand Up @@ -201,10 +185,6 @@ export function functionsDeclaration(r: J.Reflection, d: Declaration): void {
}

d.signature.concise = s

if (d.parameters.length !== 0) {
fragment(r, d)
}
}

export function interfaceReflection(i: J.Reflection, d: Declaration): void {
Expand All @@ -226,10 +206,7 @@ export function interfaceReflection(i: J.Reflection, d: Declaration): void {
d.signature.concise = s
}

export function methodDeclaration(r: J.Reflection, d: Declaration): void {
const tt = d.trail.flat(Infinity)
const m = resolve(r, tt)

export function methodDeclaration(m: J.Reflection, d: Declaration): void {
if (!isSignatureReflection(m)) {
return
}
Expand All @@ -254,10 +231,6 @@ export function methodDeclaration(r: J.Reflection, d: Declaration): void {
}

d.signature.concise = s

if (d.parameters.length !== 0) {
fragment(r, d)
}
}

export function propertyReflection(p: J.Reflection, d: Declaration): void {
Expand Down Expand Up @@ -317,16 +290,18 @@ export function variableDeclaration(v: J.Reflection, d: Declaration): void {
d.signature.concise = s
}

export function fragment(r: J.Reflection, d: Declaration): void {
export function fragment(r: ComputeRepository, d: Declaration): void {
for (const f of d.parameters) {
const tt = f.trail.flat(Infinity)
const e = resolve(r, tt)
if (!isParameterReflection(e)) {
return
}
if (e.type) {
const b = type(e.type)
f.signature.concise.push(...b)
const tt = r.trailOf(f)
if (tt) {
const e = r.reflectionOf(tt)
if (!isParameterReflection(e)) {
return
}
if (e.type) {
const b = type(e.type)
f.signature.concise.push(...b)
}
}
}
}
Expand Down
Loading

0 comments on commit 3740da0

Please sign in to comment.