JuliaFormatter.jl icon indicating copy to clipboard operation
JuliaFormatter.jl copied to clipboard

format_docstrings is not idempotent

Open odow opened this issue 2 years ago • 2 comments

Another example from https://github.com/jump-dev/JuMP.jl/pull/2993

s = """
\"\"\"
    solve_knapsack(
        optimizer,
        data_filename::String,
        config::_AbstractConfiguration,
    )

Solve the knapsack problem and return the optimal primal solution

## Arguments

  - `optimizer`: an object that can be passed to `JuMP.Model` to construct a new
    JuMP model.
  - `data_filename`: the filename of a JSON file containing the data for the
    problem.
  - `config`: an object to control the type of knapsack model constructed.
    Valid options are:
      + `BinaryKnapsackConfig()`
      + `IntegerKnapsackConfig()`

## Returns
\"\"\"
foo() = nothing
"""
s1 = JuliaFormatter.format_text(s; format_docstrings = true)
s2 = JuliaFormatter.format_text(s1; format_docstrings = true)
s3 = JuliaFormatter.format_text(s2; format_docstrings = true)

yields

julia> s1 == s2
false

julia> s2 == s3
true

julia> print(s3)
"""
    solve_knapsack(
        optimizer,
        data_filename::String,
        config::_AbstractConfiguration,
    )

Solve the knapsack problem and return the optimal primal solution

## Arguments

  - `optimizer`: an object that can be passed to `JuMP.Model` to construct a new
    JuMP model.

  - `data_filename`: the filename of a JSON file containing the data for the
    problem.
  - `config`: an object to control the type of knapsack model constructed.
    Valid options are:
    
      + `BinaryKnapsackConfig()`
      + `IntegerKnapsackConfig()`

## Returns
"""
foo() = nothing

I don't know what should happen, but there probably should be an additional blank line added after the first argument bullet.

odow avatar May 26 '22 23:05 odow

so it keeps adding a new blank line on each format then?

domluna avatar May 27 '22 13:05 domluna

No, once it gets to s3 it stops.

odow avatar May 30 '22 00:05 odow