Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

LINE pragmas cause missing documentation #441

Open
@mjakob

Description

@mjakob

Dear Haddock developers,

I ran into a problem with Haddock while using c2hs, but I think this issue can be applicable for any pre-processor using LINE pragmas. I managed to simplify the issue to the following: say we have a source file LinePragmaIssue.chs and we run a pre-processor on it to produce LinePragmaIssue.hs:

{-# LINE 1 "LinePragmaIssue.chs" #-}
-- |Module LinePragmaIssue
module LinePragmaIssue ( B ) where
-- This and the following two lines were generated by the pre-processor:
data A = SomethingLongerThanTheAnnotationForB

{-# LINE 4 "LinePragmaIssue.chs" #-}
-- |Data type B.
data B = B

If Haddock is applied to this file, the output is:

$ haddock LinePragmaIssue.hs
Haddock coverage:
  50% (  1 /  2) in 'LinePragmaIssue'
  Missing documentation for:
    B (LinePragmaIssue.chs:5)

Since the (generated) line data A = SomethingLongerThanTheAnnotationForB has the same line number as the Haddock annotation for B when the LINE pragmas are taken into account and since the declaration is longer, it is sorted after the latter, i.e., the sorted document structure that Haddock uses is:

-- |Data type B.
data A = SomethingLongerThanTheAnnotationForB
data B = B

This results in B being undocumented, which was unexpected, at least to me.

If this is considered a bug, one solution I can think of is to ignore the LINE pragmas while matching comments to declarations, but this might be built into the GHC API and perhaps cause other problems. I couldn't find any related issues in this tracker, but I appologize if I missed them.

Specs according to the guidelines:

  • GHC: 7.10.1
  • Platform: Arch Linux x86_64
  • Cabal: 1.22.2.0

Regards, Mattias

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions