Skip to content

Commit 410cc01

Browse files
committed
Remove commented-out code and unnecessary comments from server, route collector, and HTML parser files for improved readability and maintainability.
1 parent 5621912 commit 410cc01

3 files changed

Lines changed: 0 additions & 22 deletions

File tree

src/mcp/server.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class McpDocsServer {
8383
private registerTools(server: McpServer): void {
8484
const toolOverrides = this.config.tools;
8585

86-
// Register docs_search tool
8786
server.registerTool(
8887
docsSearchTool.name,
8988
{
@@ -118,7 +117,6 @@ export class McpDocsServer {
118117
}
119118
);
120119

121-
// Register docs_fetch tool
122120
server.registerTool(
123121
docsFetchTool.name,
124122
{
@@ -199,13 +197,11 @@ export class McpDocsServer {
199197
}
200198

201199
private async _doInitialize(): Promise<void> {
202-
// Load the search provider (specifier string or pre-instantiated provider)
203200
const searchSpecifier = this.config.search ?? 'flexsearch';
204201
this.searchProvider = await loadSearchProvider(searchSpecifier, {
205202
flexsearch: this.config.flexsearch,
206203
});
207204

208-
// Build provider context
209205
const providerContext: ProviderContext = {
210206
baseUrl: this.config.baseUrl ?? '',
211207
serverName: this.config.name,
@@ -228,7 +224,6 @@ export class McpDocsServer {
228224
throw new Error('Invalid server config: must provide either file paths or pre-loaded data');
229225
}
230226

231-
// Initialize the search provider
232227
await this.searchProvider.initialize(providerContext, initData);
233228

234229
this.initialized = true;
@@ -260,14 +255,11 @@ export class McpDocsServer {
260255
enableJsonResponse: true, // Return JSON instead of SSE streams
261256
});
262257

263-
// Connect the server to this transport
264258
await server.connect(transport);
265259

266260
try {
267-
// Let the transport handle the request
268261
await transport.handleRequest(req, res, parsedBody);
269262
} finally {
270-
// Clean up the transport after request
271263
await transport.close();
272264
}
273265
}
@@ -287,20 +279,16 @@ export class McpDocsServer {
287279

288280
const server = this.createMcpServer();
289281

290-
// Create a stateless transport for Web Standards
291282
const transport = new WebStandardStreamableHTTPServerTransport({
292283
sessionIdGenerator: undefined, // Stateless mode
293284
enableJsonResponse: true,
294285
});
295286

296-
// Connect the server to this transport
297287
await server.connect(transport);
298288

299289
try {
300-
// Let the transport handle the request and return the response
301290
return await transport.handleRequest(request);
302291
} finally {
303-
// Clean up the transport after request
304292
await transport.close();
305293
}
306294
}

src/plugin/route-collector.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ export function flattenRoutes(routes: RouteConfig[]): FlattenedRoute[] {
1010
const flattened: FlattenedRoute[] = [];
1111

1212
function traverse(route: RouteConfig): void {
13-
// Add the route if it has a path
1413
if (route.path) {
1514
flattened.push({
1615
path: route.path,
1716
htmlPath: '', // Will be resolved later
1817
});
1918
}
2019

21-
// Recursively process child routes
2220
if (route.routes && Array.isArray(route.routes)) {
2321
for (const childRoute of route.routes) {
2422
traverse(childRoute);
@@ -42,15 +40,12 @@ export function flattenRoutes(routes: RouteConfig[]): FlattenedRoute[] {
4240
* - /api -> build/api/index.html
4341
*/
4442
export function routeToHtmlPath(routePath: string, outDir: string): string {
45-
// Normalize the route path
4643
let normalizedPath = routePath;
4744

48-
// Remove trailing slash if present (except for root)
4945
if (normalizedPath.length > 1 && normalizedPath.endsWith('/')) {
5046
normalizedPath = normalizedPath.slice(0, -1);
5147
}
5248

53-
// Handle root path
5449
if (normalizedPath === '/') {
5550
return path.join(outDir, 'index.html');
5651
}
@@ -98,7 +93,6 @@ export async function discoverHtmlFiles(outDir: string): Promise<FlattenedRoute[
9893
const fullPath = path.join(dir, entry.name);
9994

10095
if (entry.isDirectory()) {
101-
// Skip common non-content directories
10296
if (['assets', 'img', 'static'].includes(entry.name)) {
10397
continue;
10498
}
@@ -159,10 +153,7 @@ export async function collectRoutes(
159153
outDir: string,
160154
excludePatterns: string[]
161155
): Promise<FlattenedRoute[]> {
162-
// Discover all HTML files in the build directory
163156
const allRoutes = await discoverHtmlFiles(outDir);
164-
165-
// Filter out excluded routes
166157
const filteredRoutes = filterRoutes(allRoutes, excludePatterns);
167158

168159
// Deduplicate routes by path. When the same route is emitted as both

src/processing/html-parser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export function cleanContentElement(element: Element, excludeSelectors: string[]
135135
}
136136
}
137137

138-
// Recursively clean children
139138
removeUnwanted(childElement);
140139
return true;
141140
});

0 commit comments

Comments
 (0)