Action/Generate: Add relocatable option#449
Action/Generate: Add relocatable option#449fgaz-scrive wants to merge 4 commits intondmitchell:masterfrom
Conversation
|
Friendly ping |
|
Ping :) Is there anything I can do to move this forward? |
|
@fgaz-scrive could you please rebase to trigger a CI run? |
src/Action/Generate.hs
Outdated
| | [] <- local_ -> do readHaskellOnline timing settings doDownload | ||
| | otherwise -> readHaskellDirs timing settings local_ | ||
| | relocatable, _:_:_ <- local_ -> | ||
| exitFail "Error: --relocatable needs exactly one --local, or the paths will be ambiguous" |
There was a problem hiding this comment.
Could we validate this condition earlier? E. g., could our command line interface be --local [PATH] | --relocatable PATH, so that the configuration is valid by construction?
There was a problem hiding this comment.
could our command line interface be
--local [PATH] | --relocatable PATH
We'd still have to check that only one of those is supplied, unless cmdargs supports submodes and a breaking change is OK.
I pushed a separate commit with the change so you can compare and possibly revert.
|
@fgaz @fgaz-scrive are you still interested in this? |
|
Yes, I'll follow up next week |
e44d045 to
7de85f0
Compare
This is useful for example if you generate the haddocks and the index in CI and deploy them to another machine at a different path.
7de85f0 to
ecb4b9f
Compare
Bodigrim
left a comment
There was a problem hiding this comment.
Thanks! How can I test the new feature?
src/Action/Generate.hs
Outdated
| | Just _ <- relocatable, _:_ <- local_ -> | ||
| exitFail "Error: --relocatable and --local are mutually exclusive" | ||
| | Just relocatable' <- relocatable -> do | ||
| prefix <- traverse canonicalizePath relocatable |
There was a problem hiding this comment.
Could it be
| prefix <- traverse canonicalizePath relocatable | |
| prefix <- canonicalizePath relocatable' |
?
There was a problem hiding this comment.
Sure. I just have to wrap it back later, but it makes sense to do so because it's a different context with a different meaning. Done.
src/Action/Generate.hs
Outdated
| let url = "file://" ++ ['/' | not $ "/" `isPrefixOf` dir] ++ replace "\\" "/" dir ++ "/" | ||
| let url = case prefixToRemove of | ||
| Just prefix -> makeRelative prefix $ replace "\\" "/" dir ++ "/" | ||
| Nothing -> "file://" ++ ['/' | not $ "/" `isPrefixOf` dir] ++ replace "\\" "/" dir ++ "/" |
There was a problem hiding this comment.
Could we please factor out replace "\\" "/" dir ++ "/" so that it's not repeated?
There was a problem hiding this comment.
Done. While I was at it I also changed it to use isPathSeparator.
2104dc5 to
9b56337
Compare
In any cabal project: cabal haddock-project
hoogle generate --local=haddocks/ --database=regular.db
hoogle generate --relocatable=haddocks/ --database=relocatable.db
# "Deploy" the haddocks and hoogle databases
tmp="$(mktemp -d)"
mv regular.db relocatable.db haddocks "$tmp"
# Links from hoogle results to haddocks will not work
hoogle serve --database="$tmp/regular.db" --haddock="$tmp/haddocks/"
# Links from hoogle results to haddocks will work
hoogle serve --database="$tmp/relocatable.db" --haddock="$tmp/haddocks/" |
|
@Bodigrim ping |
|
Sorry for delay, we discovered that hoogle.haskell.org was using a patched version of Hoogle and now waiting to upstream the patches in #468 before accumulating more changes in |
This is useful for example if you generate the haddocks and the index in CI and deploy them to another machine at a different path.
Thanks for the pull request!
By raising this pull request you confirm you are licensing your contribution under all licenses that apply to this project (see LICENSE) and that you have no patents covering your contribution.
If you care, my PR preferences are at https://github.com/ndmitchell/neil#contributions, but they're all guidelines, and I'm not too fussy - you don't have to read them.