Skip to content

Commit 3bd5594

Browse files
committed
chore: wip
1 parent 7e3207f commit 3bd5594

File tree

2 files changed

+0
-61
lines changed

2 files changed

+0
-61
lines changed

src/generate.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { extract } from './extract'
77
import { checkIsolatedDeclarations, getAllTypeScriptFiles, writeToFile } from './utils'
88

99
export async function generateDeclarationsFromFiles(options?: DtsGenerationConfig): Promise<void> {
10-
// console.log('Generating declaration files...', options)
1110
try {
1211
// Check for isolatedModules setting
1312
const isIsolatedDeclarations = await checkIsolatedDeclarations(options)
@@ -17,7 +16,6 @@ export async function generateDeclarationsFromFiles(options?: DtsGenerationConfi
1716
}
1817

1918
if (options?.clean) {
20-
// console.log('Cleaning output directory...')
2119
await rm(options.outdir, { recursive: true, force: true })
2220
}
2321

@@ -29,10 +27,7 @@ export async function generateDeclarationsFromFiles(options?: DtsGenerationConfi
2927
files = await getAllTypeScriptFiles(options?.root)
3028
}
3129

32-
// console.log('Found the following TypeScript files:', files)
33-
3430
for (const file of files) {
35-
// console.log(`Processing file: ${file}`)
3631
const fileDeclarations = await extract(file)
3732

3833
if (fileDeclarations) {
@@ -45,15 +40,11 @@ export async function generateDeclarationsFromFiles(options?: DtsGenerationConfi
4540

4641
// Write the declarations without additional formatting
4742
await writeToFile(outputPath, fileDeclarations)
48-
49-
// console.log(`Generated ${outputPath}`)
5043
}
5144
else {
5245
console.warn(`No declarations extracted for ${file}`)
5346
}
5447
}
55-
56-
// console.log('Declaration file generation complete')
5748
}
5849
catch (error) {
5950
console.error('Error generating declarations:', error)

src/utils.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -34,58 +34,6 @@ export async function checkIsolatedDeclarations(options?: DtsGenerationConfig):
3434
}
3535
}
3636

37-
export function formatDeclarations(declarations: string): string {
38-
const lines = declarations.split('\n')
39-
const formattedLines = lines.map((line) => {
40-
// Trim trailing spaces
41-
line = line.trimEnd()
42-
43-
// Handle interface and type declarations
44-
if (line.startsWith('export interface') || line.startsWith('export type')) {
45-
const parts = line.split('{')
46-
if (parts.length > 1) {
47-
return `${parts[0].trim()} {${parts[1]}`
48-
}
49-
}
50-
51-
// Remove semicolons from the end of lines
52-
if (line.endsWith(';')) {
53-
line = line.slice(0, -1)
54-
}
55-
56-
return line
57-
})
58-
59-
// Join lines and ensure only one blank line between declarations
60-
let result = formattedLines.join('\n')
61-
result = result.replace(/\n{3,}/g, '\n\n')
62-
63-
// Format comments
64-
result = result.replace(/\/\*\*\n([^*]*)(\n \*\/)/g, (match, content) => {
65-
const formattedContent = content
66-
.split('\n')
67-
.map((line: string) => ` *${line.trim() ? ` ${line.trim()}` : ''}`)
68-
.join('\n')
69-
return `/**\n${formattedContent}\n */`
70-
})
71-
72-
return `${result.trim()}\n`
73-
}
74-
75-
export function formatComment(comment: string): string {
76-
const lines = comment.split('\n')
77-
return lines
78-
.map((line, index) => {
79-
if (index === 0)
80-
return '/**'
81-
if (index === lines.length - 1)
82-
return ' */'
83-
const trimmedLine = line.replace(/^\s*\*?\s?/, '').trim()
84-
return ` * ${trimmedLine}`
85-
})
86-
.join('\n')
87-
}
88-
8937
export function deepMerge<T extends object>(target: T, ...sources: Array<Partial<T>>): T {
9038
if (!sources.length)
9139
return target

0 commit comments

Comments
 (0)