diff options
author | simonmar <unknown> | 2002-06-24 14:37:43 +0000 |
---|---|---|
committer | simonmar <unknown> | 2002-06-24 14:37:43 +0000 |
commit | 45290d2e6e2e4558f4469a9fc19403d80117223d (patch) | |
tree | 4bc121cff2f34b1e742a4f26bbfc7a090333b473 /src/Main.hs | |
parent | 780c506b11953b81d41f01d73e0beea6f9352743 (diff) |
[haddock @ 2002-06-24 14:37:42 by simonmar]
When reading an interface, allow a file path offset to be specified
which represents the path to the HTML files for the modules specified
by that interface. The path may be either relative (to the location
of the HTML for this package), or absolute.
The syntax is
--read-interface=PATH,FILE
where PATH is the path to the HTML, and FILE is the filename
containing the interface.
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Main.hs b/src/Main.hs index e6c9576f..ad83cf9c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -125,16 +125,19 @@ run flags files = do [] -> Nothing fs -> Just (last fs) - ifaces_to_read = [str | Flag_ReadInterface str <- flags] + ifaces_to_read = [ parseIfaceOption str + | Flag_ReadInterface str <- flags ] no_implicit_prelude = Flag_NoImplicitPrelude `elem` flags prologue <- getPrologue flags - writeIORef saved_flags flags - parsed_mods <- sequence (map parse_file files) + read_ifaces_s <- mapM readIface (map snd ifaces_to_read) + + updateHTMLXRefs (map fst ifaces_to_read) read_ifaces_s - read_ifaces_s <- mapM readIface ifaces_to_read + writeIORef saved_flags flags + parsed_mods <- mapM parse_file files let read_ifaces = concat read_ifaces_s external_mods = map fst read_ifaces @@ -180,6 +183,12 @@ run flags files = do prepared_ifaces = [ (mod, fmToList (iface_env iface)) | (mod, iface) <- these_mod_ifaces ] +parseIfaceOption :: String -> (FilePath,FilePath) +parseIfaceOption s = + case break (==',') s of + (path,',':file) -> (path,file) + (_, file) -> ("", file) + readIface :: FilePath -> IO [(Module,Interface)] readIface filename = do bh <- readBinMem filename @@ -201,6 +210,16 @@ readIface filename = do ) +updateHTMLXRefs :: [FilePath] -> [[(Module,Interface)]] -> IO () +updateHTMLXRefs paths ifaces_s = + writeIORef html_xrefs_ref (listToFM mapping) + where + mapping = [ (mod,path) + | (path, ifaces) <- zip paths ifaces_s, + (mod, _iface) <- ifaces + ] + + parse_file file = do bracket (openFile file ReadMode) |