Skip to content

Commit

Permalink
Fix variable shadowing and moved imports in Elm code
Browse files Browse the repository at this point in the history
  • Loading branch information
evancz committed Jan 31, 2018
1 parent cb81d4c commit ac475ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/frontend/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Session
import Session.Query as Query
import Session.Status exposing (Status(..))
import Task
import Url.Parser as Parser
import Utils.App as App
import Utils.OneOrMore as OneOrMore
import Version
Expand Down Expand Up @@ -76,7 +77,7 @@ subscriptions model =
-- NAVIGATION


onNavigation : Browser.Url -> Msg
onNavigation : Parser.Url -> Msg
onNavigation url =
ReactToUrl (Route.fromUrl url)

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/Page/Docs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,17 @@ viewSidebar metadata allDocs query =


viewSidebarModules : Metadata -> List Docs.Module -> String -> Html Msg
viewSidebarModules metadata docs query =
viewSidebarModules metadata modules query =
if String.isEmpty query then
let
viewEntry docs =
li [] [ viewModuleLink metadata docs.name ]
in
ul [] (List.map viewEntry docs)
ul [] (List.map viewEntry modules)

else
ul [] <|
List.filterMap (viewSearchItem metadata (String.toLower query)) docs
List.filterMap (viewSearchItem metadata (String.toLower query)) modules


viewSearchItem : Metadata -> String -> Docs.Module -> Maybe (Html Msg)
Expand Down
26 changes: 13 additions & 13 deletions src/frontend/Page/Docs/Block.elm
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ type alias TypeNameDict =
makeInfo : String -> String -> Route.Version -> String -> List Docs.Module -> Info
makeInfo user project version moduleName docsList =
let
addUnion moduleName union docs =
Dict.insert (moduleName ++ "." ++ union.name) (moduleName, union.name) docs
addUnion home union docs =
Dict.insert (home ++ "." ++ union.name) (home, union.name) docs

addModule docs dict =
List.foldl (addUnion docs.name) dict docs.unions
Expand Down Expand Up @@ -303,8 +303,8 @@ toLines info context tipe =

Type.Record (f :: fs) extension ->
let
toLns ( field, tipe ) =
( field, toLines info Other tipe )
toLns ( field, fieldType ) =
( field, toLines info Other fieldType )
in
case extension of
Nothing ->
Expand Down Expand Up @@ -648,26 +648,26 @@ toOneLine chunkWidth chunk one entries =


toMoreLines : MoreSettings a msg -> a -> List a -> Lines (Line msg)
toMoreLines {open, sep, close, openIndent, sepIndent, toLines} x xs =
toMoreLines s x xs =
let
(OneOrMore firstLine firstRest) =
toLines x
s.toLines x

openIndentation =
text (String.repeat openIndent " ")
text (String.repeat s.openIndent " ")

sepIndentation =
text (String.repeat sepIndent " ")
text (String.repeat s.sepIndent " ")

toChunk (OneOrMore x xs) =
(sep :: x) :: List.map ((::) sepIndentation) xs
toChunk (OneOrMore y ys) =
(s.sep :: y) :: List.map ((::) sepIndentation) ys

otherLines =
List.map ((::) openIndentation) firstRest
++ List.concatMap (toChunk << toLines) xs
++ List.concatMap (toChunk << s.toLines) xs
in
More (open ++ firstLine) <|
case close of
More (s.open ++ firstLine) <|
case s.close of
Nothing ->
otherLines

Expand Down
36 changes: 20 additions & 16 deletions src/frontend/Route.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ module Route exposing
)


import Browser
import Url
import Url.Parser exposing (Parser, (</>), custom, fragment, map, oneOf, parsePath, s, top)
import Url.Parser as Parser exposing (Parser, (</>), custom, fragment, map, oneOf, s, top)
import Version


Expand Down Expand Up @@ -65,35 +64,40 @@ getHash info =
-- LOCATION TO ROUTE


fromUrl : Browser.Url -> Route
fromUrl : Parser.Url -> Route
fromUrl url =
parsePath parser NotFound url
case Parser.parse parser url of
Nothing ->
NotFound (Parser.fromUrl url)

Just route ->
route


parser : Parser (Route -> a) a
parser =
oneOf
[ map Home <| top
, map User <| s "packages" </> user
, map Package <| s "packages" </> user </> project
, map Version <| s "packages" </> user </> project </> version </> versionInfo
, map User <| s "packages" </> user_
, map Package <| s "packages" </> user_ </> project_
, map Version <| s "packages" </> user_ </> project_ </> version_ </> versionInfo
, map Guidelines <| s "help" </> s "design-guidelines"
, map DocsHelp <| s "help" </> s "docs"
]


user : Parser (String -> a) a
user =
user_ : Parser (String -> a) a
user_ =
custom "USER" Just


project : Parser (String -> a) a
project =
project_ : Parser (String -> a) a
project_ =
custom "PROJECT" Just


version : Parser (Version -> a) a
version =
version_ : Parser (Version -> a) a
version_ =
custom "VERSION" <| \string ->
if string == "latest" then
Just Latest
Expand All @@ -105,12 +109,12 @@ versionInfo : Parser (VersionInfo -> a) a
versionInfo =
oneOf
[ map Readme top
, map Module (moduleName </> fragment identity)
, map Module (moduleName_ </> fragment identity)
]


moduleName : Parser (String -> a) a
moduleName =
moduleName_ : Parser (String -> a) a
moduleName_ =
custom "MODULE" (Just << String.replace "-" ".")


Expand Down

0 comments on commit ac475ce

Please sign in to comment.