From aca68f620beb07f9bdebdf52948c6ea670be4980 Mon Sep 17 00:00:00 2001 From: Alexander Biehl Date: Mon, 30 Oct 2017 08:45:51 +0100 Subject: Add QuickJump version to meta.json (#696) --- haddock-api/src/Haddock/Backends/Xhtml/Meta.hs | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 haddock-api/src/Haddock/Backends/Xhtml/Meta.hs (limited to 'haddock-api/src/Haddock/Backends/Xhtml') 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..5cf03ec4 --- /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 -> IO () +writeHaddockMeta odir = do + let + meta_json :: Value + meta_json = object [ + "haddock_version" .= String projectVersion + , "quickjump_version" .= quickjumpVersion + ] + + withFile (odir "meta.json") WriteMode $ \h -> + hPutBuilder h (encodeToBuilder meta_json) \ No newline at end of file -- cgit v1.2.3