quinnj / JSON3.jl

Other
214 stars 47 forks source link

Nicer formatting of generated types #165

Closed mcmcgrath13 closed 3 years ago

mcmcgrath13 commented 3 years ago

prior:

module JSONTypes
import StructTypes
mutable struct Item
    id::String
    label::Union{Nothing, String}
    Item() = begin
            #= none:1 =#
            new()
        end
end
mutable struct Menu
    header::String
    items::Array{Union{Nothing, Union{Missing, Item}}, 1}
    Menu() = begin
            #= none:1 =#
            new()
        end
end
mutable struct Root
    menu::Menu
    Root() = begin
            #= none:1 =#
            new()
        end
end
StructTypes.StructType(::Type{Item}) = begin
        #= none:1 =#
        StructTypes.Mutable()
    end
StructTypes.StructType(::Type{Menu}) = begin
        #= none:1 =#
        StructTypes.Mutable()
    end
StructTypes.StructType(::Type{Root}) = begin
        #= none:1 =#
        StructTypes.Mutable()
    end
end

with these changes:

module JSONTypes

import StructTypes

mutable struct Item
    id::String
    label::Union{Nothing, String}
    Item() = new()
end

mutable struct Menu
    header::String
    items::Array{Union{Nothing, Missing, Item}, 1}
    Menu() = new()
end

mutable struct Root
    menu::Menu
    Root() = new()
end

StructTypes.StructType(::Type{Item}) = StructTypes.Mutable()
StructTypes.StructType(::Type{Menu}) = StructTypes.Mutable()
StructTypes.StructType(::Type{Root}) = StructTypes.Mutable()

end # module
codecov[bot] commented 3 years ago

Codecov Report

Merging #165 (29a7723) into main (1c69202) will increase coverage by 0.00%. The diff coverage is 89.65%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #165   +/-   ##
=======================================
  Coverage   88.76%   88.77%           
=======================================
  Files           9        9           
  Lines        1531     1559   +28     
=======================================
+ Hits         1359     1384   +25     
- Misses        172      175    +3     
Impacted Files Coverage Δ
src/gentypes.jl 96.52% <89.65%> (-1.75%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3d9d086...29a7723. Read the comment docs.