haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
361 stars 241 forks source link

Section comments are missing when re-exporting the module itself #1524

Open geroldmeisinger opened 2 years ago

geroldmeisinger commented 2 years ago
module Foo where

-- * Section

-- | foo function
foo :: Int
foo = 123

=> Section is shown

module Foo (module Foo) where

-- * Section

-- | foo function
foo :: Int
foo = 123

=> Section is missing

The reason why I need the second version is because I have to re-export other modules as well.

module Foo (module Foo, module X) where
import Control.Arrow as X
...

From the documentation I understand that haddock tries to "specifies the order that entities will be listed in the generated documentation.". "without an export list:" "the section headers (e.g. -- * Image importers) now appear in the module body itself,". I don't want to use an export list which list all functions again, just refer to other modules (and the module itself). "If they are imported wholly and without any hiding qualifiers, then the documentation will just contain a cross-reference to the documentation for B and C.". So I guess there is a special case when re-exporting the module itself (I cannot hide anything, but Haddock also doesn't just include a "cross-reference".. to nothing), hence Haddock generates documentation of all exports in no specific order and ignores section.

I would expect the re-export of the "self" module to act as if no export list was given for the module and use the order in the body, and include all other modules in order specified by the export list.

related issues: issue #958 Question: including re-exported module's documentation issue #1249 Inline section headings with explicit export list issue #1106 Controlling the documentation for reexported modules issue #584 Bugs in Haskell-level Re-exports