diff options
author | Duncan Coutts <duncan.coutts@worc.ox.ac.uk> | 2006-01-21 17:15:27 +0000 |
---|---|---|
committer | Duncan Coutts <duncan.coutts@worc.ox.ac.uk> | 2006-01-21 17:15:27 +0000 |
commit | 43bb89fa9667162f3f4a0e024a3f926696c173b9 (patch) | |
tree | 92d67daf703a0b5acb50c7dd502b0ee163b52f2e /src/HsParser.ly | |
parent | f52324bb86a403f41ad9fc2050bc350fd7635714 (diff) |
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
Diffstat (limited to 'src/HsParser.ly')
-rw-r--r-- | src/HsParser.ly | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/HsParser.ly b/src/HsParser.ly index 21561e0a..b62f1cae 100644 --- a/src/HsParser.ly +++ b/src/HsParser.ly @@ -149,12 +149,12 @@ Reserved Ids Module Header > module :: { HsModule } -> : optdoc 'module' modid maybeexports 'where' body +> : optdoc 'module' srcloc modid maybeexports 'where' body > { case $1 of { (opts,info,doc) -> -> HsModule $3 $4 (reverse (fst $6)) (snd $6) +> HsModule $3 $4 $5 (reverse (fst $7)) (snd $7) > opts info doc } } -> | body -> { HsModule main_mod Nothing (reverse (fst $1)) (snd $1) +> | body srcloc +> { HsModule $2 main_mod Nothing (reverse (fst $1)) (snd $1) > Nothing emptyModuleInfo Nothing } > optdoc :: { (Maybe String,ModuleInfo,Maybe Doc) } @@ -951,7 +951,7 @@ Layout > : vccurly { () } -- context popped in lexer. > | error {% popContext } -> layout_on :: { () } : {% getSrcLoc `thenP` \(SrcLoc r c) -> +> layout_on :: { () } : {% getSrcLoc `thenP` \(SrcLoc r c f) -> > pushContext (Layout c) } ----------------------------------------------------------------------------- |