UNPKG

expodoc

Version:

A tool to generate API documentation automatically for Express.js applications.

35 lines (34 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeToSentenceCase = normalizeToSentenceCase; exports.extractRouterVariableName = extractRouterVariableName; exports.cleanCodeContent = cleanCodeContent; function normalizeToSentenceCase(input) { if (!input) return input; return input .replace(/([A-Z]{2,})([A-Z][a-z])/g, "$1 $2") .replace(/([a-z])([A-Z]{2,})/g, "$1 $2") .replace(/[_\-\s]+/g, " ") .replace(/([a-z])([A-Z])/g, "$1 $2") .replace(/([A-Z])([A-Z][a-z])/g, "$1 $2") .replace(/\s+/g, " ") .trim(); // .replace(/([A-Z])/g, " $1") // .replace(/[_-]+/g, " ") // .trim() // .replace(/\s+/g, " ") // .replace(/^./, (match) => match.toUpperCase()) // .replace(/\s./g, (match) => match.toLowerCase()); } function extractRouterVariableName(content) { const match = /(?:const|let|var)\s+([a-zA-Z0-9_]+)\s*=\s*Router\(\)/.exec(content); return (match === null || match === void 0 ? void 0 : match[1]) || null; } function cleanCodeContent(content) { return content .replace(/\/\/.*$/gm, "") .replace(/\/\*[\s\S]*?\*\//g, "") .replace(/\s+/g, " ") .trim(); }