scss-sassdoc-parser
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

scss-sassdoc-parser

A more lightweight parser for SassDoc.

More or less a thin wrapper around scss-comment-parser, but with all SassDoc annotations and TypeScript definitions built in.

Usage

import { parse } from "scss-sassdoc-parser";

async function doParse() {
  const result = await parse(`
/// Keeps it secret
/// @output Sets display to hidden
@mixin _keep-it-secret {
  display: hidden;
}
`);

doParse();

Or sync

import { parseSync } from "scss-sassdoc-parser";

const result = parseSync(`
/// Keeps it secret
/// @output Sets display to hidden
@mixin _keep-it-secret {
  display: hidden;
}
`);

Parse using paths

import fs from "node:fs/promises";
import { parse } from "scss-sassdoc-parser";

export async function doParse(path: string | string[]): Promise<ParseResult[]> {
	const paths = Array.isArray(path) ? path : [path];
	const result = await Promise.all(
		paths.map(async (src) => {
			const code = await fs.readFile(src, "utf-8");
			return await parse(code);
		}),
	);
	return result.flat();
}

const singlePathResult = await doParse("_helpers.scss");
const arrayOfPathsResult = await doParse(["_mixins.scss", "_functions.scss"]);

Output

The result from the parse function is an array of ParseResult (type definitions). Check out the snapshot tests for some example outputs.

Dependencies (1)

Dev Dependencies (12)

Package Sidebar

Install

npm i scss-sassdoc-parser

Weekly Downloads

45

Version

3.1.0

License

MIT

Unpacked Size

81.7 kB

Total Files

146

Last publish

Collaborators

  • wllm