Add source code links to Haddock docs
authorSimon Marlow <simonmar@microsoft.com>
Fri, 8 Sep 2006 11:27:25 +0000 (11:27 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Fri, 8 Sep 2006 11:27:25 +0000 (11:27 +0000)
Right now we can only manage to add a source code link for the module,
but that's better than nothing.

I had to put the list of core packages in a Makefile variable,
$(CorePackages), so we'll have to be careful to keep this up to date.
(I could have slurped it out of libraries/core-packages with $(shell),
but that's ugly and really slow on Windows).

There are a couple of new tweakables: CorePackageSourceURL and
ExtraPackageSourceURL in config.mk.in, set these to the appropriate
patterns for generating source links.

(when we merge this patch onto the HEAD we'll have to tweak these
settings).

Unfortunately it still doesn't work for all the modules, because
modules compiled without -cpp don't get any #line directives.  More
hackery required...

mk/config.mk.in
mk/package.mk

index 806908b..be48d99 100644 (file)
@@ -355,6 +355,15 @@ DLLized=@EnableWin32DLLs@
 #
 StripLibraries=NO
 
+# These are the URL patterns that Haddock uses to generate the "Source
+# File" links on each page.
+CorePackageSourceURL = http://darcs.haskell.org/ghc-6.6/packages/$(PACKAGE)/%{FILE}
+ExtraPackageSourceURL = http://darcs.haskell.org/packages/$(PACKAGE)/%{FILE}
+
+# These are the packages required to be present in order to bootstrap GHC
+# NB. must be synced with libraries/core-packages
+CorePackages = base Cabal haskell98 readline regex-base regex-compat \
+              regex-posix parsec stm template-haskell unix Win32
 
 # ----------------------------------------------------------------------------
 # Object-file splitting
index ce90aec..22bfdd0 100644 (file)
@@ -375,12 +375,19 @@ html :: $(HTML_DOC)
 extraclean :: 
        $(RM) -rf $(HTML_DIR)
 
+ifneq "$(findstring $(PACKAGE), $(CorePackages))" ""
+HaddockSourceURL = $(CorePackageSourceURL)
+else
+HaddockSourceURL = $(ExtraPackageSourceURL)
+endif
+
 $(HTML_DOC) : $(HS_PPS)
        @$(INSTALL_DIR) $(HTML_DIR)
        $(HADDOCK) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
                --package=$(PACKAGE) \
                --dump-interface=$(PACKAGE).haddock \
                --use-index=../doc-index.html --use-contents=../index.html \
+               --source-module=$(HaddockSourceURL) \
                $(foreach pkg, $(PACKAGE_DEPS), \
                   --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)