Skip to content

Automate list of differing defaults for styles#874

Merged
domluna merged 1 commit intodomluna:masterfrom
jonas-schulze:automate-different-defaults
Oct 5, 2024
Merged

Automate list of differing defaults for styles#874
domluna merged 1 commit intodomluna:masterfrom
jonas-schulze:automate-different-defaults

Conversation

@jonas-schulze
Copy link
Contributor

Update docstrings of BlueStyle, SciMLStyle, and YASStyle to contain the computed list of options that are different from DefaultStyle.

Would this be something you are interested in? If not, feel free to close. If yes, where should list_different_defaults be defined? I am happy to iterate on this PR.

Update docstrings of BlueStyle, SciMLStyle, and YASStyle to contain the
computed list of options that are different from DefaultStyle.
Copy link
Owner

@domluna domluna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a good idea to me. do you have an output of what this looks like in the REPL?

Comment on lines +141 to +151
function list_different_defaults(style)
options_style = pairs(options(style))
options_default = pairs(options(DefaultStyle()))
options_changed = setdiff(options_style, options_default)
sort!(options_changed; by = first)
io = IOBuffer()
for (key, val) in options_changed
println(io, "- `$key` = $val")
end
String(take!(io))
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to define this here.

@jonas-schulze
Copy link
Contributor Author

Sure 🙂

help?> BlueStyle
search: BlueStyle

  BlueStyle()

  Formatting style based on BlueStyle (https://github.com/invenia/BlueStyle) and JuliaFormatter#283 (https://github.com/domluna/JuliaFormatter.jl/issues/283).

  │ Note
  │
  │  This style is still work-in-progress, and does not yet implement all of the BlueStyle guide.

  Configurable options with different defaults to DefaultStyle are:

    •  always_for_in = true

    •  always_use_return = true

    •  annotate_untyped_fields_with_any = false

    •  conditional_to_if = true

    •  import_to_using = true

    •  indent_submodule = true

    •  pipe_to_function_call = true

    •  remove_extra_newlines = true

    •  separate_kwargs_with_semicolon = true

    •  short_to_long_function_def = true

    •  whitespace_in_kwargs = false

    •  whitespace_ops_in_indices = true

    •  yas_style_nesting = false

help?> SciMLStyle
search: SciMLStyle

  SciMLStyle()

  Formatting style based on SciMLStyle (https://github.com/SciML/SciMLStyle).

  │ Note
  │
  │  This style is still work-in-progress.

  Configurable options with different defaults to DefaultStyle are:

    •  always_for_in = true

    •  disallow_single_arg_nesting = true

    •  join_lines_based_on_source = true

    •  normalize_line_endings = unix

    •  remove_extra_newlines = true

    •  trailing_comma = false

    •  whitespace_ops_in_indices = true

    •  whitespace_typedefs = true

    •  yas_style_nesting = false

help?> YASStyle
search: YASStyle

  YASStyle()

  Formatting style based on YASGuide (https://github.com/jrevels/YASGuide) and JuliaFormatter#198 (https://github.com/domluna/JuliaFormatter.jl/issues/198).

  Configurable options with different defaults to DefaultStyle are:

    •  always_for_in = true

    •  always_use_return = true

    •  import_to_using = true

    •  join_lines_based_on_source = true

    •  pipe_to_function_call = true

    •  remove_extra_newlines = true

    •  separate_kwargs_with_semicolon = true

    •  short_to_long_function_def = true

    •  whitespace_in_kwargs = false

    •  whitespace_ops_in_indices = true

    •  yas_style_nesting = false

julia> 

@domluna
Copy link
Owner

domluna commented Oct 3, 2024

ok this looks good to me! let me know when you feel it's ready to be merged.

@jonas-schulze
Copy link
Contributor Author

From my side, this is good to go.

@domluna domluna merged commit 5f704e8 into domluna:master Oct 5, 2024
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.

2 participants