From f506a356cec79336d516a4b5b0d1948bbce8c78b Mon Sep 17 00:00:00 2001 From: Alexander Biehl Date: Wed, 30 Aug 2017 09:24:56 +0200 Subject: Write meta.json when generating html output (#676) --- haddock-api/src/Haddock/Backends/Meta.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 haddock-api/src/Haddock/Backends/Meta.hs (limited to 'haddock-api/src/Haddock') diff --git a/haddock-api/src/Haddock/Backends/Meta.hs b/haddock-api/src/Haddock/Backends/Meta.hs new file mode 100644 index 00000000..c62c1ae8 --- /dev/null +++ b/haddock-api/src/Haddock/Backends/Meta.hs @@ -0,0 +1,22 @@ +module Haddock.Backends.Meta where + +import Haddock.Utils.Json +import Haddock.Version + +import Data.ByteString.Builder (hPutBuilder) +import System.FilePath (()) +import System.IO (withFile, IOMode (WriteMode)) + +-- | 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 + ] + + withFile (odir "meta.json") WriteMode $ \h -> + hPutBuilder h (encodeToBuilder meta_json) \ No newline at end of file -- cgit v1.2.3