{"library":"scss-comment-parser","title":"SCSS Comment Parser","description":"scss-comment-parser is a JavaScript library designed to parse `///` style comments within SCSS files and extract structured context information. It is primarily used to generate documentation, serving as a core component for tools like SassDoc. The current stable version is 0.8.4. While not on a rapid release cycle (last updated in 2018), it receives maintenance updates for bug fixes and dependency upgrades. Key differentiators include its specific focus on SassDoc-style comment syntax, its ability to extract detailed SCSS context (including variables, mixins, functions, placeholders, and CSS selectors), and support for custom annotation definitions, allowing for flexible documentation generation workflows. It processes SCSS code to identify comment blocks and their associated code, providing a structured JSON output.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install scss-comment-parser"],"cli":null},"imports":["const ScssCommentParser = require('scss-comment-parser');","import ScssCommentParser from 'scss-comment-parser';","const ScssCommentParser = (await import('scss-comment-parser')).default;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const ScssCommentParser = require('scss-comment-parser');\n\nconst annotations = {\n  _: {\n    alias: {\n      'aliasTest': 'annotationTest'\n    }\n  },\n  annotationTest: function ( commentLine ) {\n    return 'Working';\n  }\n};\n\nconst parser = new ScssCommentParser( annotations );\n\nconst scss = `\n/// @annotationTest\n/// This is a test comment for a variable.\n$my-variable: #ff00ff;\n\n/// @param {string} $name - The name to greet.\n/// This mixin generates a greeting style.\n@mixin greet($name) {\n  .greeting-#{$name} { color: blue; }\n}\n\n/// A placeholder for common base styles.\n%base-styles {\n  margin: 0;\n  padding: 0;\n}\n\n/// @example\n///   .some-class { @extend %base-styles; }\n.some-selector { /* some styles */ }\n`;\n\nconst comments = parser.parse( scss );\n\nconsole.log(JSON.stringify(comments, null, 2));\n/* Expected output (truncated):\n[\n  {\n    \"context\": {\n      \"type\": \"variable\",\n      \"name\": \"my-variable\",\n      \"value\": \"#ff00ff\",\n      \"code\": \"$my-variable: #ff00ff;\",\n      \"line\": {\n        \"start\": 4,\n        \"end\": 4\n      }\n    },\n    \"description\": \"This is a test comment for a variable.\",\n    \"annotations\": {\n      \"annotationTest\": [\n        \"Working\"\n      ]\n    }\n  },\n  {\n    \"context\": {\n      \"type\": \"mixin\",\n      \"name\": \"greet\",\n      \"args\": \"($name)\",\n      \"code\": \"@mixin greet($name) {\\n  .greeting-#{$name} { color: blue; }\\n}\",\n      \"line\": {\n        \"start\": 8,\n        \"end\": 10\n      }\n    },\n    \"description\": \"This mixin generates a greeting style.\",\n    \"annotations\": {\n      \"param\": [\n        \"{string} $name - The name to greet.\"\n      ]\n    }\n  },\n  // ... and other parsed contexts\n]\n*/","lang":"javascript","description":"Initializes the parser with custom annotations, processes a sample SCSS string containing various comment types and code contexts, and logs the extracted documentation data in a formatted JSON output.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}