Skip to content

Add RustyWind::sort_class_value for sorting bare class attribute values - #151

Open
UnknownPlatypus wants to merge 1 commit into
avencera:masterfrom
UnknownPlatypus:expose-sort-class-value
Open

Add RustyWind::sort_class_value for sorting bare class attribute values#151
UnknownPlatypus wants to merge 1 commit into
avencera:masterfrom
UnknownPlatypus:expose-sort-class-value

Conversation

@UnknownPlatypus

@UnknownPlatypus UnknownPlatypus commented Aug 5, 2026

Copy link
Copy Markdown

Hi !

I'm trying to integrate rustywind to djangofmt and was needing an api to format a class content directly, respecting the template language

I've added an api for that and updated existing code to reuse it.

Let me know what you think

Summary by CodeRabbit

  • New Features

    • Added support for sorting standalone class attribute values with template-aware handling.
    • Preserves template expressions while sorting static classes and removes local duplicates.
    • Supports configured class wrapping and multiple source languages.
  • Bug Fixes

    • Improved handling of dynamic and malformed class values.
  • Documentation

    • Documented the new class-value sorting capability.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f6126361-1d17-4426-b4ae-cf73b20afe94

📥 Commits

Reviewing files that changed from the base of the PR and between bec101c and ce65550.

📒 Files selected for processing (3)
  • rustywind-core/CHANGELOG.md
  • rustywind-core/src/app.rs
  • rustywind-core/tests/template_aware_sorting.rs

📝 Walkthrough

Walkthrough

Adds RustyWind::sort_class_value for template-aware sorting of standalone class values. Shared validation now supports both direct API calls and existing regex-based and structured-attribute sorting paths. Tests cover templates, duplicates, malformed input, wrapping, and document equivalence.

Changes

Class-value sorting

Layer / File(s) Summary
Public API and shared validation
rustywind-core/src/app.rs, rustywind-core/CHANGELOG.md
Adds RustyWind::sort_class_value, centralizes sortable class-value validation, updates existing sorting paths, and documents the API.
Class-value sorting coverage
rustywind-core/tests/template_aware_sorting.rs
Tests template-aware sorting, duplicate handling, dynamic and malformed values, wrapping configuration, and consistency with document sorting.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

Suggested reviewers: praveenperera

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding RustyWind::sort_class_value for bare class attribute values.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a public API for sorting an already-extracted class attribute value while preserving language-specific template expressions.

  • Adds RustyWind::sort_class_value and consolidates document and capture sorting through a shared value-analysis helper.
  • Covers plain, template-aware, duplicate-removal, configured-wrapping, and document-equivalence behavior.
  • Documents the new API in the changelog.

Confidence Score: 5/5

The PR appears safe to merge, with the new API consistently reusing the existing fail-closed template-aware sorting behavior.

The bare-value, regex-capture, and structured-attribute paths now share the same value classifier and sorter, while invalid or opaque values remain unchanged and the public types are available to downstream callers.

Important Files Changed

Filename Overview
rustywind-core/src/app.rs Adds the public bare-value sorting method and reuses its template-aware classification helper across existing document extraction paths.
rustywind-core/tests/template_aware_sorting.rs Adds coverage for static and dynamic values, local duplicate removal, malformed syntax, wrapping configuration, and equivalence with document sorting.
rustywind-core/CHANGELOG.md Documents the new sort_class_value public API and its intended parser-integration use case.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Caller supplies class value and SourceLanguage] --> B[sort_class_value]
    B --> C[sortable_class_value]
    C -->|No wrapping| D[Analyze language-specific static runs]
    C -->|Configured wrapping| E[Parse validated wrapped class list]
    D --> F[Sort each static run independently]
    E --> G[Sort wrapped classes]
    F --> H[Return sorted or borrowed value]
    G --> H
    C -->|Opaque or invalid| I[Return original borrowed value]
Loading

Reviews (1): Last reviewed commit: "Add `RustyWind::sort_class_value` for so..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant