diff options
author | alexbiehl <alex.biehl@gmail.com> | 2017-10-31 21:48:55 +0100 |
---|---|---|
committer | alexbiehl <alex.biehl@gmail.com> | 2017-10-31 21:48:55 +0100 |
commit | 08c9e19236770811caf571321f5ece271d1fccff (patch) | |
tree | beb3f6407d14abcab32f9d54811cabd319c356a4 /haddock-api/src/Haddock/Backends/Xhtml/Meta.hs | |
parent | 3896bff411596ef50b5ca2f2be425e89878410aa (diff) | |
parent | e5fe98530d9c70f5197494da9de07f42dd7fe334 (diff) |
Merge remote-tracking branch 'origin/master' into ghc-head
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Xhtml/Meta.hs')
-rw-r--r-- | haddock-api/src/Haddock/Backends/Xhtml/Meta.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs b/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs new file mode 100644 index 00000000..621bdd41 --- /dev/null +++ b/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs @@ -0,0 +1,28 @@ +module Haddock.Backends.Xhtml.Meta where + +import Haddock.Utils.Json +import Haddock.Version + +import Data.ByteString.Builder (hPutBuilder) +import System.FilePath ((</>)) +import System.IO (withFile, IOMode (WriteMode)) + +-- | Everytime breaking changes to the Quckjump api +-- happen this needs to be modified. +quickjumpVersion :: Int +quickjumpVersion = 1 + +-- | Writes a json encoded file containing additional +-- information about the generated documentation. This +-- is useful for external tools (e.g. hackage). +writeHaddockMeta :: FilePath -> Bool -> IO () +writeHaddockMeta odir withQuickjump = do + let + meta_json :: Value + meta_json = object (concat [ + [ "haddock_version" .= String projectVersion ] + , [ "quickjump_version" .= quickjumpVersion | withQuickjump ] + ]) + + withFile (odir </> "meta.json") WriteMode $ \h -> + hPutBuilder h (encodeToBuilder meta_json) |