Skip to content

Commit

Permalink
Merge pull request avh4#549 from avh4/release-prep
Browse files Browse the repository at this point in the history
Prepare 0.8.1-rc2
  • Loading branch information
avh4 authored Sep 13, 2018
2 parents 33455ba + 33aed3f commit 94f43d7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Bug fixes:
- For Elm 0.18 and earlier, tag listings of documented custom types are no longer converted to `(..)`
- Listing a value more than once in module documentation no longer results in an invalid module line
- Code blocks in doc comments containing commented Elm expressions are now correctly separated by a single blank line
- When converting `exposing (..)` to an explicit listing, undocumented values are not longer hidden


## 0.8.0
Expand Down
2 changes: 1 addition & 1 deletion elm-format.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: elm-format
version: 0.8.1-rc1
version: 0.8.1-rc2

Synopsis:
A source code formatter for Elm
Expand Down
2 changes: 1 addition & 1 deletion package/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elm-format",
"version": "0.8.1-rc1",
"version": "0.8.1-rc2",
"description": "Install elm-format",
"preferGlobal": true,
"main": "index.js",
Expand Down
39 changes: 13 additions & 26 deletions src/ElmFormat/Render/Box.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ removeDuplicates input =
else (ReversedList.push next acc, Set.insert next seen)


sortVars :: Bool -> Set (AST.Commented AST.Variable.Value) -> [[AST.Variable.Ref]] -> Set AST.Variable.Value -> ([[AST.Commented AST.Variable.Value]], AST.Comments)
sortVars forceMultiline fromExposing fromDocs fromModule =
sortVars :: Bool -> Set (AST.Commented AST.Variable.Value) -> [[AST.Variable.Ref]] -> ([[AST.Commented AST.Variable.Value]], AST.Comments)
sortVars forceMultiline fromExposing fromDocs =
let
refName (AST.Variable.VarRef _ (LowercaseIdentifier name)) = name
refName (AST.Variable.TagRef _ (UppercaseIdentifier name)) = name
Expand Down Expand Up @@ -201,9 +201,7 @@ sortVars forceMultiline fromExposing fromDocs fromModule =
|> Map.fromList

allowedInDocs =
Map.union
(varSetToMap fromExposing)
(varSetToMap $ Set.map (\v -> AST.Commented [] v []) fromModule)
varSetToMap fromExposing

allFromDocs =
Set.fromList $ fmap varName $ concat listedInDocs
Expand All @@ -221,20 +219,9 @@ sortVars forceMultiline fromExposing fromDocs fromModule =
|> fmap (\(AST.Commented pre _ post) -> pre ++ post)
|> concat
in
case (List.null $ concat listedInDocs) && (List.null remainingFromExposing) of
False ->
if List.null listedInDocs && forceMultiline
then ( fmap (\x -> [x]) remainingFromExposing, commentsFromReorderedVars )
else ( listedInDocs ++ if List.null remainingFromExposing then [] else [ remainingFromExposing ], commentsFromReorderedVars )

True ->
-- we have no exposing, and no docs; use from module
fromModule
|> Set.toList
|> fmap (\x -> AST.Commented [] x [])
|> List.sortOn varOrder
|> (\x -> if List.null x then [] else [x])
|> (\x -> (x, []))
if List.null listedInDocs && forceMultiline
then ( fmap (\x -> [x]) remainingFromExposing, commentsFromReorderedVars )
else ( listedInDocs ++ if List.null remainingFromExposing then [] else [ remainingFromExposing ], commentsFromReorderedVars )


formatModuleHeader :: ElmVersion -> AST.Module.Module -> Box
Expand Down Expand Up @@ -266,19 +253,20 @@ formatModuleHeader elmVersion modu =
'(':a:b:')':[] -> AST.Variable.OpRef (SymbolIdentifier $ a:b:[])
s -> AST.Variable.VarRef [] (LowercaseIdentifier s)

definedVars :: Set AST.Variable.Value
definedVars :: Set (AST.Commented AST.Variable.Value)
definedVars =
AST.Module.body modu
|> concatMap extractVarName
|> fmap (\x -> AST.Commented [] x [])
|> Set.fromList

AST.KeywordCommented _ _ exportsList =
AST.Module.exports header

detailedListingToSet :: AST.Variable.Listing AST.Module.DetailedListing -> Set (AST.Commented AST.Variable.Value)
detailedListingToSet (AST.Variable.OpenListing _) = Set.empty
detailedListingToSet AST.Variable.ClosedListing = Set.empty
detailedListingToSet (AST.Variable.ExplicitListing (AST.Module.DetailedListing values operators types) _) =
detailedListingToSet :: Set (AST.Commented AST.Variable.Value) -> AST.Variable.Listing AST.Module.DetailedListing -> Set (AST.Commented AST.Variable.Value)
detailedListingToSet allAvailable (AST.Variable.OpenListing _) = allAvailable
detailedListingToSet _ AST.Variable.ClosedListing = Set.empty
detailedListingToSet _ (AST.Variable.ExplicitListing (AST.Module.DetailedListing values operators types) _) =
Set.unions
[ Map.assocs values |> fmap (\(name, AST.Commented pre () post) -> AST.Commented pre (AST.Variable.Value name) post) |> Set.fromList
, Map.assocs operators |> fmap (\(name, AST.Commented pre () post) -> AST.Commented pre (AST.Variable.OpValue name) post) |> Set.fromList
Expand All @@ -292,9 +280,8 @@ formatModuleHeader elmVersion modu =
varsToExpose =
sortVars
(detailedListingIsMultiline exportsList)
(detailedListingToSet exportsList)
(detailedListingToSet definedVars exportsList)
documentedVars
definedVars

extractVarName :: TopLevelStructure Declaration -> [AST.Variable.Value]
extractVarName decl =
Expand Down
1 change: 0 additions & 1 deletion src/Flags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Flags where
import Data.Monoid ((<>))
import ElmVersion (ElmVersion(..))

import qualified Data.Maybe as Maybe
import qualified ElmVersion
import qualified Options.Applicative as Opt
import qualified Text.PrettyPrint.ANSI.Leijen as PP
Expand Down
2 changes: 2 additions & 0 deletions tests/test-files/transform/Elm-0.19/ListExports.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module ListExports exposing (..)

type alias X = ()
type Y = Y1 | Y2
q = 4
a = 1
b = 2
c = 3
p = 5
9 changes: 9 additions & 0 deletions tests/test-files/transform/Elm-0.19/ListExports.formatted.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ListExports exposing
, X
, Y(..)
, b, c
, p, q
)

{-|
Expand All @@ -28,6 +29,10 @@ type Y
| Y2


q =
4


a =
1

Expand All @@ -38,3 +43,7 @@ b =

c =
3


p =
5

0 comments on commit 94f43d7

Please sign in to comment.