Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small jsdoc tweaks #97

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 12 additions & 42 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,20 @@ export function format(css, { minify = false } = {}) {
/**
* Indent a string
* @param {number} size
* @returns A string with {size} tabs
* @returns {string} A string with {size} tabs
*/
function indent(size) {
return minify ? EMPTY_STRING : '\t'.repeat(size)
}

/**
* @param {import('css-tree').CssNode} node
* @returns A portion of the CSS
*/
/** @param {import('css-tree').CssNode} node */
function substr(node) {
let loc = node.loc
if (!loc) return EMPTY_STRING
return css.slice(loc.start.offset, loc.end.offset)
}

/**
* @param {import('css-tree').Rule} node
* @returns {string} A formatted Rule
*/
/** @param {import('css-tree').Rule} node */
function print_rule(node) {
let buffer
let prelude = node.prelude
Expand All @@ -93,10 +87,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').SelectorList} node
* @returns {string} A formatted SelectorList
*/
/** @param {import('css-tree').SelectorList} node */
function print_selectorlist(node) {
let buffer = EMPTY_STRING

Expand All @@ -113,9 +104,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node
*/
/** @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node */
function print_simple_selector(node) {
let buffer = EMPTY_STRING
let children = node.children || []
Expand Down Expand Up @@ -235,10 +224,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').Block} node
* @returns {string} A formatted Block
*/
/** @param {import('css-tree').Block} node */
function print_block(node) {
let children = node.children
let buffer = OPTIONAL_SPACE
Expand Down Expand Up @@ -291,10 +277,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').Atrule} node
* @returns {string} A formatted Atrule
*/
/** @param {import('css-tree').Atrule} node */
function print_atrule(node) {
let buffer = indent(indent_level) + '@'
let prelude = node.prelude
Expand Down Expand Up @@ -338,10 +321,7 @@ export function format(css, { minify = false } = {}) {

}

/**
* @param {import('css-tree').Declaration} node
* @returns {string} A formatted Declaration
*/
/** @param {import('css-tree').Declaration} node */
function print_declaration(node) {
let property = node.property

Expand All @@ -366,9 +346,7 @@ export function format(css, { minify = false } = {}) {
return indent(indent_level) + property + COLON + OPTIONAL_SPACE + value
}

/**
* @param {import('css-tree').List<import('css-tree').CssNode>} children
*/
/** @param {import('css-tree').List<import('css-tree').CssNode>} children */
function print_list(children) {
let buffer = EMPTY_STRING

Expand Down Expand Up @@ -406,10 +384,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').Operator} node
* @returns {string} A formatted Operator
*/
/** @param {import('css-tree').Operator} node */
function print_operator(node) {
let buffer = EMPTY_STRING
// https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes
Expand Down Expand Up @@ -445,9 +420,7 @@ export function format(css, { minify = false } = {}) {
return buffer
}

/**
* @param {import('css-tree').Value | import('css-tree').Raw} node
*/
/** @param {import('css-tree').Value | import('css-tree').Raw} node */
function print_value(node) {
if (node.type === 'Raw') {
return print_unknown(node, 0)
Expand All @@ -465,10 +438,7 @@ export function format(css, { minify = false } = {}) {
return indent(indent_level) + substr(node).trim()
}

/**
* @param {import('css-tree').CssNode} node
* @returns {string} A formatted Stylesheet
*/
/** @param {import('css-tree').CssNode} node */
function print(node) {
let buffer = EMPTY_STRING

Expand Down
Loading