Add a --print-docdir flag
authorIan Lynagh <igloo@earth.li>
Fri, 31 Aug 2007 23:15:38 +0000 (23:15 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 31 Aug 2007 23:15:38 +0000 (23:15 +0000)
compiler/Makefile
compiler/main/Main.hs
docs/users_guide/flags.xml
docs/users_guide/using.xml

index 9ddef07..1140788 100644 (file)
@@ -262,6 +262,7 @@ endif
        @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
        @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
        @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
+       @echo "cDocDir               = \"$(docdir)\""         >> $(CONFIG_HS)
        @echo done.
 
 CLEAN_FILES += $(CONFIG_HS)
index bc18dae..038a7b9 100644 (file)
@@ -89,6 +89,8 @@ main =
                                   exitWith ExitSuccess
     ShowSupportedLanguages  -> do showSupportedLanguages
                                   exitWith ExitSuccess
+    ShowDocDir              -> do showDocDir
+                                  exitWith ExitSuccess
     ShowVersion             -> do showVersion
                                   exitWith ExitSuccess
     ShowNumVersion          -> do putStrLn cProjectVersion
@@ -164,6 +166,7 @@ main =
     ShowUsage              -> showGhcUsage dflags cli_mode
     PrintLibdir            -> putStrLn (topDir dflags)
     ShowSupportedLanguages -> alreadyHandled
+    ShowDocDir             -> alreadyHandled
     ShowVersion            -> alreadyHandled
     ShowNumVersion         -> alreadyHandled
     ShowInterface f        -> doShowIface dflags f
@@ -298,6 +301,7 @@ verifyOutputFiles dflags = do
 data CmdLineMode
   = ShowUsage               -- ghc -?
   | PrintLibdir             -- ghc --print-libdir
+  | ShowDocDir              -- ghc --print-docdir
   | ShowInfo                -- ghc --info
   | ShowSupportedLanguages  -- ghc --supported-languages
   | ShowVersion             -- ghc -V/--version
@@ -357,13 +361,14 @@ type ModeM a = CmdLineP (CmdLineMode, String, [String]) a
 mode_flags :: [(String, OptKind (CmdLineP (CmdLineMode, String, [String])))]
 mode_flags =
   [  ------- help / version ----------------------------------------------
-     ( "?"              , PassFlag (setMode ShowUsage))
-  ,  ( "-help"          , PassFlag (setMode ShowUsage))
-  ,  ( "-print-libdir"   , PassFlag (setMode PrintLibdir))
-  ,  ( "V"              , PassFlag (setMode ShowVersion))
-  ,  ( "-version"       , PassFlag (setMode ShowVersion))
-  ,  ( "-numeric-version", PassFlag (setMode ShowNumVersion))
-  ,  ( "-info", PassFlag (setMode ShowInfo))
+     ( "?"                   , PassFlag (setMode ShowUsage))
+  ,  ( "-help"               , PassFlag (setMode ShowUsage))
+  ,  ( "-print-libdir"       , PassFlag (setMode PrintLibdir))
+  ,  ( "-print-docdir"       , PassFlag (setMode ShowDocDir))
+  ,  ( "V"                   , PassFlag (setMode ShowVersion))
+  ,  ( "-version"            , PassFlag (setMode ShowVersion))
+  ,  ( "-numeric-version"    , PassFlag (setMode ShowNumVersion))
+  ,  ( "-info"               , PassFlag (setMode ShowInfo))
   ,  ( "-supported-languages", PassFlag (setMode ShowSupportedLanguages))
 
       ------- interfaces ----------------------------------------------------
@@ -465,6 +470,11 @@ showSupportedLanguages :: IO ()
 showSupportedLanguages = do mapM_ putStrLn supportedLanguages
                             exitWith ExitSuccess
 
+showDocDir :: IO ()
+showDocDir = do
+  putStrLn cDocDir
+  exitWith ExitSuccess
+
 showVersion :: IO ()
 showVersion = do
   putStrLn (cProjectName ++ ", version " ++ cProjectVersion)
index c8aeb18..d47fcbf 100644 (file)
              <entry>-</entry>
            </row>
            <row>
+             <entry><option>&ndash;&ndash;print-docdir</option></entry>
+             <entry>display GHC documentation directory</entry>
+             <entry>mode</entry>
+             <entry>-</entry>
+           </row>
+           <row>
              <entry><option>-ferror-spans</option></entry>
              <entry>output full span in error messages</entry>
              <entry>static</entry>
index ee4d9fd..9df6eb5 100644 (file)
@@ -409,6 +409,20 @@ module X where
        </listitem>
       </varlistentry>
 
+      <varlistentry>
+       <term>
+         <cmdsynopsis>
+            <command>ghc --print-docdir</command>
+          </cmdsynopsis>
+          <indexterm><primary><option>&ndash;&ndash;print-docdir</option></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Print the path to GHC's documentation directory. Note that
+      some distributions do no include the documentation, in which case
+      this directory may be empty or may not exist.</para>
+       </listitem>
+      </varlistentry>
+
     </variablelist>
 
     <sect2 id="make-mode">