aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/haddock.sgml167
-rw-r--r--src/HaddockUtil.hs15
-rw-r--r--src/Main.hs58
3 files changed, 137 insertions, 103 deletions
diff --git a/doc/haddock.sgml b/doc/haddock.sgml
index ce1112bc..a74e91fc 100644
--- a/doc/haddock.sgml
+++ b/doc/haddock.sgml
@@ -225,19 +225,49 @@
<variablelist>
<varlistentry>
- <term><option>-d</option></term>
- <term><option>--docbook</option></term>
- <indexterm><primary><option>-d</option></primary></indexterm>
- <indexterm><primary><option>--docbook</option></primary></indexterm>
+ <term><option>-o</option> <replaceable>dir</replaceable></term>
+ <term><option>--odir</option>=<replaceable>dir</replaceable></term>
+ <indexterm><primary><option>-o</option></primary></indexterm>
+ <indexterm><primary><option>--odir</option></primary></indexterm>
+ <listitem>
+ <para>Generate files into <replaceable>dir</replaceable>
+ instead of the current directory.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-i</option> <replaceable>path</replaceable>,<replaceable>file</replaceable></term>
+ <term><option>--read-interface</option>=<replaceable>path</replaceable>,<replaceable>file</replaceable></term>
+ <indexterm><primary><option>-i</option></primary></indexterm>
+ <indexterm><primary><option>--read-interface</option></primary></indexterm>
<listitem>
- <para>Output documentation in SGML DocBook format. NOTE: at
- time of writing this is only partially implemented and
- doesn't work.</para>
+ <para>Read the interface file in
+ <replaceable>file</replaceable>, which must have been
+ produced by running Haddock with the
+ <option>--dump-interface</option> option. The interface
+ describes a set of modules whose HTML documentation is
+ located in <replaceable>path</replaceable> (which may be a
+ relative pathname). The <replaceable>path</replaceable> is
+ optional, and defaults to <quote>.</quote>.</para>
+
+ <para>This option allows Haddock to produce separate sets of
+ documentation with hyperlinks between them. The
+ <replaceable>path</replaceable> is used to direct hyperlinks
+ to point to the right files; so make sure you don't move the
+ HTML files later or these links will break. Using a
+ relative <replaceable>path</replaceable> means that a
+ documentation subtree can still be moved around without
+ breaking links.</para>
+
+ <para>Multiple <option>--read-interface</option> options may
+ be given.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-D</option> <replaceable>file</replaceable></term>
<term><option>--dump-interface</option>=<replaceable>file</replaceable></term>
+ <indexterm><primary><option>-D</option></primary></indexterm>
<indexterm><primary><option>--dump-interface</option></primary>
</indexterm>
<listitem>
@@ -255,6 +285,28 @@
</varlistentry>
<varlistentry>
+ <term><option>-l</option> <replaceable>dir</replaceable></term>
+ <term><option>--lib</option>=<replaceable>dir</replaceable></term>
+ <indexterm><primary><option>-l</option></primary></indexterm>
+ <indexterm><primary><option>--lib</option></primary>
+ </indexterm>
+ <listitem>
+ <para>Use auxiliary files in <replaceable>dir</replaceable>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-S</option></term>
+ <term><option>--docbook</option></term>
+ <indexterm><primary><option>-S</option></primary></indexterm>
+ <indexterm><primary><option>--docbook</option></primary></indexterm>
+ <listitem>
+ <para>Reserved for future use (output documentation in SGML DocBook
+ format).</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-h</option></term>
<term><option>--html</option></term>
<indexterm><primary><option>-h</option></primary></indexterm>
@@ -304,36 +356,9 @@
</varlistentry>
<varlistentry>
- <term><option>-i</option> <replaceable>path</replaceable>,<replaceable>file</replaceable></term>
- <term><option>--read-interface</option>=<replaceable>path</replaceable>,<replaceable>file</replaceable></term>
- <indexterm><primary><option>-i</option></primary></indexterm>
- <indexterm><primary><option>--read-interface</option></primary></indexterm>
- <listitem>
- <para>Read the interface file in
- <replaceable>file</replaceable>, which must have been
- produced by running Haddock with the
- <option>--dump-interface</option> option. The interface
- describes a set of modules whose HTML documentation is
- located in <replaceable>path</replaceable> (which may be a
- relative pathname). The <replaceable>path</replaceable> is
- optional, and defaults to <quote>.</quote>.</para>
-
- <para>This option allows Haddock to produce separate sets of
- documentation with hyperlinks between them. The
- <replaceable>path</replaceable> is used to direct hyperlinks
- to point to the right files; so make sure you don't move the
- HTML files later or these links will break. Using a
- relative <replaceable>path</replaceable> means that a
- documentation subtree can still be moved around without
- breaking links.</para>
-
- <para>Multiple <option>--read-interface</option> options may
- be given.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
+ <term><option>-m</option></term>
<term><option>--ms-help</option></term>
+ <indexterm><primary><option>-m</option></primary></indexterm>
<indexterm><primary><option>--ms-help</option></primary>
</indexterm>
<listitem>
@@ -359,24 +384,25 @@
</varlistentry>
<varlistentry>
- <term><option>--no-implicit-prelude</option></term>
- <indexterm><primary><option>--no-implicit-prelude</option></primary>
- </indexterm>
+ <term><option>-s</option> <replaceable>URL</replaceable></term>
+ <term><option>--source</option>=<replaceable>URL</replaceable></term>
+ <indexterm><primary><option>-s</option></primary></indexterm>
+ <indexterm><primary><option>--source</option></primary></indexterm>
<listitem>
- <para>Don't automatically import <literal>Prelude</literal>
- in every module. Used when producing documentation for the
- <literal>Prelude</literal> itself.</para>
+ <para>Include links to the source files in the generated
+ documentation, where <replaceable>URL</replaceable> is the
+ base URL where the source files can be found.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>-o</option> <replaceable>dir</replaceable></term>
- <term><option>--odir</option>=<replaceable>dir</replaceable></term>
- <indexterm><primary><option>-o</option></primary></indexterm>
- <indexterm><primary><option>--odir</option></primary></indexterm>
+ <term><option>-c</option> <replaceable>file</replaceable></term>
+ <term><option>--css</option>=<replaceable>file</replaceable></term>
+ <indexterm><primary><option>--css</option></primary></indexterm>
<listitem>
- <para>Generate files into <replaceable>dir</replaceable>
- instead of the current directory.</para>
+ <para>Specify a stylesheet to use instead of the default one
+ that comes with Haddock. It should specify certain classes:
+ see the default stylesheet for details.</para>
</listitem>
</varlistentry>
@@ -395,18 +421,6 @@
</varlistentry>
<varlistentry>
- <term><option>-s</option> <replaceable>URL</replaceable></term>
- <term><option>--source</option>=<replaceable>URL</replaceable></term>
- <indexterm><primary><option>-s</option></primary></indexterm>
- <indexterm><primary><option>--source</option></primary></indexterm>
- <listitem>
- <para>Include links to the source files in the generated
- documentation, where <replaceable>URL</replaceable> is the
- base URL where the source files can be found.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
<term><option>-t</option> <replaceable>title</replaceable></term>
<term><option>--title</option>=<replaceable>title</replaceable></term>
<indexterm><primary><option>-t</option></primary></indexterm>
@@ -422,6 +436,29 @@
</varlistentry>
<varlistentry>
+ <term><option>-n</option></term>
+ <term><option>--no-implicit-prelude</option></term>
+ <indexterm><primary><option>-n</option></primary></indexterm>
+ <indexterm><primary><option>--no-implicit-prelude</option></primary>
+ </indexterm>
+ <listitem>
+ <para>Don't automatically import <literal>Prelude</literal>
+ in every module. Used when producing documentation for the
+ <literal>Prelude</literal> itself.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-d</option></term>
+ <term><option>--debug</option></term>
+ <indexterm><primary><option>-d</option></primary></indexterm>
+ <indexterm><primary><option>--debug</option></primary></indexterm>
+ <listitem>
+ <para>Produce extra debugging output.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-?</option></term>
<term><option>--help</option></term>
<indexterm><primary><option>-?</option></primary></indexterm>
@@ -440,16 +477,6 @@
<para>Output version information and exit.</para>
</listitem>
</varlistentry>
-
- <varlistentry>
- <term><option>--css</option>=<replaceable>filename</replaceable></term>
- <indexterm><primary><option>--css</option></primary></indexterm>
- <listitem>
- <para>Specify a stylesheet to use instead of the default one
- that comes with Haddock. It should specify certain classes:
- see the default stylesheet for details.</para>
- </listitem>
- </varlistentry>
</variablelist>
</chapter>
diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs
index 9804fb6e..20d86b79 100644
--- a/src/HaddockUtil.hs
+++ b/src/HaddockUtil.hs
@@ -18,7 +18,7 @@ module HaddockUtil (
moduleHtmlFile,
-- * Miscellaneous utilities
- die, dieMsg, mapSnd, mapMaybeM,
+ getProgramName, bye, die, dieMsg, mapSnd, mapMaybeM,
-- * HTML cross reference mapping
html_xrefs_ref, html_xrefs,
@@ -26,7 +26,7 @@ module HaddockUtil (
import HsSyn
-import List ( intersect )
+import List ( intersect, isSuffixOf )
import Maybe
import IO ( hPutStr, stderr )
import System
@@ -261,11 +261,20 @@ moduleHtmlFile dir mod0 = dir ++ pathSeparator : mod0 ++ ".html"
-----------------------------------------------------------------------------
-- misc.
+getProgramName :: IO String
+getProgramName = liftM (`withoutSuffix` ".bin") getProgName
+ where str `withoutSuffix` suff
+ | suff `isSuffixOf` str = take (length str - length suff) str
+ | otherwise = str
+
+bye :: String -> IO a
+bye s = putStr s >> exitWith ExitSuccess
+
die :: String -> IO a
die s = hPutStr stderr s >> exitWith (ExitFailure 1)
dieMsg :: String -> IO a
-dieMsg s = getProgName >>= \prog -> die (prog ++ ": " ++ s)
+dieMsg s = getProgramName >>= \prog -> die (prog ++ ": " ++ s)
mapSnd :: (b -> c) -> [(a,b)] -> [(a,c)]
mapSnd _ [] = []
diff --git a/src/Main.hs b/src/Main.hs
index ff85a038..3e4afca2 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -56,17 +56,17 @@ main = do
cmdline <- getArgs
case getOpt Permute options cmdline of
(flags, args, [] ) -> run flags args
- (_, _, errors) -> do prog <- getProgName
+ (_, _, errors) -> do prog <- getProgramName
die (concat errors ++
usageInfo (usageHeader prog) options)
usageHeader :: String -> String
-usageHeader prog = prog ++ " [OPTION...] file...\n"
+usageHeader prog = "Usage: " ++ prog ++ " [OPTION...] file...\n"
data Flag
= Flag_CSS String
| Flag_Debug
- | Flag_DocBook
+-- | Flag_DocBook
| Flag_DumpInterface FilePath
| Flag_Heading String
| Flag_Html
@@ -84,32 +84,32 @@ data Flag
options :: [OptDescr Flag]
options =
[
- Option ['d'] ["docbook"] (NoArg Flag_DocBook)
- "output in docbook (SGML)",
- Option ['D'] ["debug"] (NoArg Flag_Debug)
- "extra debugging output",
- Option ['h'] ["html"] (NoArg Flag_Html)
- "output in HTML",
Option ['o'] ["odir"] (ReqArg Flag_OutputDir "DIR")
"directory in which to put the output files",
- Option ['p'] ["prologue"] (ReqArg Flag_Prologue "FILE")
- "file containing prologue text",
+ Option ['i'] ["read-interface"] (ReqArg Flag_ReadInterface "FILE")
+ "read an interface from FILE",
+ Option ['D'] ["dump-interface"] (ReqArg Flag_DumpInterface "FILE")
+ "dump an interface for these modules in FILE",
+ Option ['l'] ["lib"] (ReqArg Flag_Lib "DIR")
+ "location of Haddock's auxiliary files",
+-- Option ['S'] ["docbook"] (NoArg Flag_DocBook)
+-- "output in docbook (SGML)",
+ Option ['h'] ["html"] (NoArg Flag_Html)
+ "output in HTML",
+ Option ['m'] ["ms-help"] (NoArg Flag_MSHtmlHelp)
+ "produce Microsoft HTML Help files (with -h)",
Option ['s'] ["source"] (ReqArg Flag_SourceURL "URL")
"base URL for links to source code",
+ Option ['c'] ["css"] (ReqArg Flag_CSS "FILE")
+ "the CSS file to use for HTML output",
+ Option ['p'] ["prologue"] (ReqArg Flag_Prologue "FILE")
+ "file containing prologue text",
Option ['t'] ["title"] (ReqArg Flag_Heading "TITLE")
"page heading",
- Option ['i'] ["read-interface"] (ReqArg Flag_ReadInterface "FILE")
- "read an interface from FILE",
- Option [] ["css"] (ReqArg Flag_CSS "FILE")
- "The CSS file to use for HTML output",
- Option [] ["dump-interface"] (ReqArg Flag_DumpInterface "FILE")
- "dump an interface for these modules in FILE",
- Option [] ["lib"] (ReqArg Flag_Lib "DIR")
- "Location of Haddock's auxiliary files",
- Option [] ["ms-help"] (NoArg Flag_MSHtmlHelp)
- "Produce Microsoft HTML Help files (with -h)",
- Option [] ["no-implicit-prelude"] (NoArg Flag_NoImplicitPrelude)
- "Do not assume Prelude is imported",
+ Option ['n'] ["no-implicit-prelude"] (NoArg Flag_NoImplicitPrelude)
+ "do not assume Prelude is imported",
+ Option ['d'] ["debug"] (NoArg Flag_Debug)
+ "extra debugging output",
Option ['?'] ["help"] (NoArg Flag_Help)
"display this help and exit",
Option ['V'] ["version"] (NoArg Flag_Version)
@@ -122,13 +122,11 @@ saved_flags = unsafePerformIO (newIORef (error "no flags yet"))
run :: [Flag] -> [FilePath] -> IO ()
run flags files = do
when (Flag_Help `elem` flags) $ do
- prog <- getProgName
- putStrLn (usageInfo (usageHeader prog) options)
- exitWith ExitSuccess
+ prog <- getProgramName
+ bye (usageInfo (usageHeader prog) options)
- when (Flag_Version `elem` flags) $ do
- putStrLn ("Haddock version " ++ projectVersion ++ ", (c) Simon Marlow 2002")
- exitWith ExitSuccess
+ when (Flag_Version `elem` flags) $
+ bye ("Haddock version " ++ projectVersion ++ ", (c) Simon Marlow 2002\n")
let title = case [str | Flag_Heading str <- flags] of
[] -> ""
@@ -265,7 +263,7 @@ parse_file file = do
(\h -> do stuff <- hGetContents h
case parse stuff (SrcLoc 1 1) 1 0 [] of
Ok _ e -> return e
- Failed err -> die (file ++ ':':err)
+ Failed err -> die (file ++ ':':err ++ "\n")
)
getPrologue :: [Flag] -> IO (Maybe Doc)