Skip to content

Comments

Add FormatConfig support for links notation formatting in all languages (C#, JavaScript, Rust, Python)#171

Merged
konard merged 6 commits intomainfrom
issue-155-7899dac8e6ec
Dec 1, 2025
Merged

Add FormatConfig support for links notation formatting in all languages (C#, JavaScript, Rust, Python)#171
konard merged 6 commits intomainfrom
issue-155-7899dac8e6ec

Conversation

@konard
Copy link
Member

@konard konard commented Nov 30, 2025

Summary

This PR ensures that the formatter in all languages is configurable with special formatting options as requested in #155.

Changes Made

Rust Implementation (new in this PR):

  • Added LiNo<T>::format_with_config() method for formatting individual links with configuration
  • Added format_links_with_config() function for formatting link collections with configuration
  • Implemented group_consecutive_links() helper for grouping consecutive same-ID links
  • Added helper functions: escape_reference(), needs_parentheses(), format_value()
  • Added 8 new integration tests verifying all formatting options

All 7 Formatting Options Now Supported Across All Languages

Option C# JavaScript Python Rust
lessParentheses / less_parentheses
maxLineLength / max_line_length
indentLongLines / indent_long_lines
maxInlineRefs / max_inline_refs
groupConsecutive / group_consecutive
indentString / indent_string
preferInline / prefer_inline

Example Usage

The formatter can now transform:

sequence: 1 2 3 4

Into indented format when configured (e.g., maxInlineRefs: 3 and preferInline: false):

sequence:
  1
  2
  3
  4

And group consecutive links:

(SetA a)
(SetA b)

Into:

SetA:
  a
  b

Test Plan

  • All JavaScript tests pass (140 tests)
  • All Python tests pass (138 tests)
  • All C# tests pass (142 tests)
  • All Rust tests pass (148 tests, including 8 new integration tests)
  • Verify CI passes

Issue Reference

Fixes #155

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #155
@konard konard self-assigned this Nov 30, 2025
This commit completes the FormatConfig support across all languages by
implementing format_with_config() method for LiNo<T> and
format_links_with_config() function in Rust.

New features:
- LiNo<T>::format_with_config() - format individual links with config
- format_links_with_config() - format link collections with config
- group_consecutive_links() - groups consecutive same-ID links
- Helper functions: escape_reference(), needs_parentheses(), format_value()

All 7 formatting options are now supported in Rust:
- less_parentheses: omit parentheses where safe
- max_line_length: line length threshold for auto-indenting
- indent_long_lines: enable length-based auto-indenting
- max_inline_refs: reference count threshold for auto-indenting
- group_consecutive: group consecutive links with same ID
- indent_string: customizable indentation string
- prefer_inline: prefer inline format when under thresholds

Added 8 new integration tests that verify:
- less_parentheses formatting
- max_inline_refs indentation
- line length limit indentation
- consecutive link grouping
- custom indent string
- format roundtrip preservation
- empty links handling
- single ref formatting

Fixes #155

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Make sure we support format options for links notation formatting in languages (C#, JavaScript, Rust, Python) Add FormatConfig support for links notation formatting in all languages (C#, JavaScript, Rust, Python) Nov 30, 2025
@konard konard marked this pull request as ready for review November 30, 2025 20:39
@konard
Copy link
Member Author

konard commented Nov 30, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.625110 USD
  • Calculated by Anthropic: $3.197206 USD
  • Difference: $-1.427904 (-30.87%)
    📎 Log file uploaded as GitHub Gist (939KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Nov 30, 2025

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

?? python/links_notation.egg-info/

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

@konard
Copy link
Member Author

konard commented Nov 30, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.242668 USD
  • Calculated by Anthropic: unknown
  • Difference: unknown
    📎 Log file uploaded as GitHub Gist (1320KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Dec 1, 2025

Double check everything is done according to requirements.

@konard konard marked this pull request as draft December 1, 2025 14:46
@konard
Copy link
Member Author

konard commented Dec 1, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-01T14:46:12.887Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 3 commits December 1, 2025 14:48
Resolved conflict in rust/src/lib.rs by combining:
- std::fmt import from main branch
- FormatConfig import and formatting functions from feature branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Applied clippy suggestion to collapse nested else-if into a single
else-if chain for better readability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard marked this pull request as ready for review December 1, 2025 14:55
@konard
Copy link
Member Author

konard commented Dec 1, 2025

✅ Double-Check Complete

I've verified all requirements from issue #155 are implemented correctly:

All 7 Formatting Options Confirmed Across All Languages

Option C# JavaScript Python Rust
lessParentheses / less_parentheses
maxLineLength / max_line_length
indentLongLines / indent_long_lines
maxInlineRefs / max_inline_refs
groupConsecutive / group_consecutive
indentString / indent_string
preferInline / prefer_inline

Issue Requirements Verified

  1. Configurable formatter - All languages now support FormatConfig/FormatOptions
  2. Formatting with/without parentheses - less_parentheses option
  3. Inline vs indented format - prefer_inline + max_inline_refs + indent_long_lines
  4. Format based on ref count - max_inline_refs triggers indentation
  5. Format based on line length - max_line_length + indent_long_lines
  6. Group consecutive links - group_consecutive option groups same-ID links
  7. Custom indent string - indent_string option
  8. All settings optional - All options have sensible defaults

Test Results

  • Rust: 148 tests passed
  • JavaScript: 140 tests passed
  • Python: 138 tests passed (1 skipped)
  • C#: 142 tests passed

Changes Made This Session

  1. Resolved merge conflicts with main branch (linting/formatting updates)
  2. Fixed Clippy warning (collapsible else-if)
  3. Applied cargo fmt formatting

All CI checks are now passing ✅

🤖 Generated with Claude Code

@konard
Copy link
Member Author

konard commented Dec 1, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.291411 USD
  • Calculated by Anthropic: $2.413140 USD
  • Difference: $-1.878271 (-43.77%)
    📎 Log file uploaded as GitHub Gist (572KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Dec 1, 2025

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

M js/package-lock.json
?? python/links_notation.egg-info/

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

@konard
Copy link
Member Author

konard commented Dec 1, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.226010 USD
  • Calculated by Anthropic: $0.757346 USD
  • Difference: $-0.468664 (-38.23%)
    📎 Log file uploaded as GitHub Gist (743KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit c34ec1c into main Dec 1, 2025
7 checks passed
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.

Make sure we support format options for links notation formatting in languages (C#, JavaScript, Rust, Python)

1 participant