From 43bb89fa9667162f3f4a0e024a3f926696c173b9 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Sat, 21 Jan 2006 17:15:27 +0000 Subject: Teach haddock about line pragmas and add accurate source code links Teach haddock about C and Haskell style line pragmas. Extend the lexer/parser's source location tracking to include the file name as well as line/column. This way each AST item that is tagged with a SrcLoc gets the original file name too. Use this original file name to add source links to each exported item, in the same visual style as the wiki links. Note that the per-export source links are to the defining module rather than whichever module haddock pretends it is exported from. This is what we want for source code links. The source code link URL can also contain the name of the export so one could implement jumping to the actual location of the function in the file if it were linked to an html version of the source rather than just plain text. The name can be selected with the %N wild card. So for linking to the raw source code one might use: --source=http://darcs/haskell.org/foo/%F Or for linking to html syntax highlighted code: --source=http://darcs/haskell.org/foo/%M.html#%N --- src/HaddockLex.x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/HaddockLex.x') diff --git a/src/HaddockLex.x b/src/HaddockLex.x index 1044d64a..f5e40942 100644 --- a/src/HaddockLex.x +++ b/src/HaddockLex.x @@ -142,7 +142,7 @@ ident str sc cont = strToHsQNames :: String -> Maybe [HsQName] strToHsQNames str0 - = case lexer (\t -> returnP t) str0 (SrcLoc 1 1) 1 1 [] of + = case lexer (\t -> returnP t) str0 (SrcLoc 1 1 "") 1 1 "" [] of Ok _ (VarId str) -> Just [ UnQual (HsVarName (HsIdent str)) ] Ok _ (QVarId (mod0,str)) -- cgit v1.2.3