UNPKG

clean-jsdoc-theme

Version:

A beautifully crafted theme/template for JSDoc 3. This theme/template looks and feels like a premium theme/template. This is a fully mobile responsive theme and also fully customizable theme.

57 lines (43 loc) 1.58 kB
const fs = require('fs'); const path = require('path'); function parseCSS(cssContent) { // Implement your CSS parsing logic here // You can use regular expressions, string manipulation, or a CSS parsing library // Example: Simple parsing using regular expressions to extract CSS rules const cssRules = []; const ruleRegex = /(.+?)\s*{\s*(.*?)\s*}/gs; let match; while ((match = ruleRegex.exec(cssContent)) !== null) { const selector = match[1].trim(); const declarations = match[2].split(';').map((declaration) => { const parts = declaration.split(':').map((part) => part.trim()); return { property: parts[0], value: parts[1], }; }); cssRules.push({ selector, declarations: declarations .sort((a, b) => a.property.localeCompare(b.property)) .filter((declaration) => declaration.property !== ''), }); } return cssRules; } const cssFile = fs.readFileSync( path.join('.', 'static', 'styles', 'clean-jsdoc-theme-light.css') ); const parsed = parseCSS(cssFile); let output = ''; for (const parse of parsed) { output += `${parse.selector} {\n`; for (const declaration of parse.declarations) { output += `\t${declaration.property}: ${declaration.value};\n`; } output += '\n}\n\n'; } fs.writeFileSync( path.join('.', 'static', 'styles', 'clean-jsdoc-theme-list.update.css'), output );