Skip to content

Commit f830b45

Browse files
committed
docs: improve comments
1 parent 36d7367 commit f830b45

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/oxc_transformer/src/plugins/styled_components.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,12 @@ fn is_valid_styled_component_source(source: &str) -> bool {
831831
///
832832
/// # Steps
833833
///
834-
/// 1. Initialize state variables to track whether currently inside a string,
835-
/// the current string quote character, and the depth of parentheses.
836-
/// 2. Iterate through each byte of each quasi:
834+
/// 1. Initialize state variables to track whether:
835+
/// - Currently inside a string.
836+
/// - Current string quote character.
837+
/// - Depth of parentheses.
838+
/// This state is carried over across different quasis.
839+
/// 2. Iterate through each quasi, and each byte of each quasi:
837840
/// - If encounter a string quote (`"` or `'`), toggle the `string_quote` state.
838841
/// - Skip comments (both block and line comments) and whitespace, compressing them as needed.
839842
/// - Handle unescaped newlines by replacing them with a space.
@@ -893,17 +896,19 @@ fn minify_template_literal<'a>(lit: &mut TemplateLiteral<'a>, ast: AstBuilder<'a
893896
let mut push_output = false;
894897

895898
// TODO: Update span end of `TemplateElement` when it has next one appended to end of it.
896-
// TODO: Remove scopes, symbols, and references when removing an `Expression`.
897899
// TODO: What about `cooked`? Shouldn't we alter that too?
898900
quasis.retain_mut(|quasi| {
899901
let mut bytes = quasi.value.raw.as_str().as_bytes();
900902

901903
let mut retain_quasi = true;
902904
if let Some(is_block_comment) = comment_type {
903-
// Remove this quasi and the preceding expression
905+
// Remove this quasi and the preceding expression.
906+
// Note: This branch cannot be taken on first iteration.
907+
// TODO: Remove scopes, symbols, and references for removed `Expression`.
904908
retain_quasi = false;
905909
expressions.remove(new_raws.len());
906910

911+
// Find end of comment
907912
let start_index = if is_block_comment {
908913
bytes.windows(2).position(|q| q == b"*/").map(|mut pos| {
909914
pos += 2;

0 commit comments

Comments
 (0)