aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockTypes.hs
blob: 10d7f7960d47a5a9cd0468cd2875b1b5ada6c98e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
--
-- Haddock - A Haskell Documentation Tool
--
-- (c) Simon Marlow 2003
--

module HaddockTypes (
  -- * Module interfaces
  NameEnv, Interface(..), ExportItem(..), ExportItem2(..), ModuleMap, ModuleMap2,
  HaddockModule(..), 
  -- * Misc types
  DocOption(..), InstHead,
 ) where

import HsSyn2

import qualified GHC as GHC

import Data.Map

-- ---------------------------------------------------------------------------
-- Describing a module interface

type NameEnv   = Map HsName HsQName

data Interface 
  = Interface {
	iface_filename :: FilePath,
		-- ^ the filename that contains the source code for this module

	iface_orig_filename :: FilePath,
		-- ^ the original filename for this module, which may be
                -- different to the 'iface_filename' (for example the original
                -- file may have had a .lhs or .hs.pp extension).

	iface_module :: Module,

	iface_package :: Maybe String,

	iface_env :: NameEnv,
		-- ^ environment mapping exported names to *original* names

	iface_reexported :: [HsName],
		-- ^ For names exported by this module, but not
		-- actually documented in this module's documentation
		-- (perhaps because they are reexported via 'module M'
		-- in the export list), this mapping gives the
		-- location of documentation for the name in another
		-- module.

	iface_sub :: Map HsName [HsName],
		-- ^ maps names to "subordinate" names 
		-- (eg. tycon to constrs & fields, class to methods)

	iface_exports :: [ExportItem],
		-- ^ the exports used to construct the documentation 

	iface_orig_exports :: [ExportItem],
		-- ^ the exports used to construct the documentation
		-- (with orig names, not import names)

	iface_decls :: Map HsName HsDecl,
		-- ^ decls from this module (only)
		-- restricted to only those bits exported.
		-- the map key is the "main name" of the decl.

	iface_insts :: [HsDecl],
		-- ^ instances from this module

	iface_info :: ModuleInfo,
		-- ^ information from the module header

	iface_doc :: Maybe Doc,
		-- ^ documentation from the module header

	iface_options :: [DocOption]
		-- ^ module-wide doc options
  }

data DocOption
  = OptHide		-- this module should not appear in the docs
  | OptPrune
  | OptIgnoreExports	-- pretend everything is exported
  | OptNotHome		-- not the best place to get docs for things
		 	-- exported by this module.
  deriving (Eq, Show)

data ExportItem 
  = ExportDecl
	HsQName	      -- the original name
	HsDecl        -- a declaration (with doc annotations)
	[InstHead]    -- instances relevant to this declaration

  | ExportNoDecl	-- an exported entity for which we have no documentation
			-- (perhaps becuase it resides in another package)
	HsQName		-- the original name
	HsQName		-- where to link to
	[HsQName]	-- subordinate names

  | ExportGroup		-- a section heading
	Int		-- section level (1, 2, 3, ... )
	String		-- section "id" (for hyperlinks)
	Doc		-- section heading text

  | ExportDoc		-- some documentation
	Doc

  | ExportModule	-- a cross-reference to another module
	Module

data ExportItem2 
  = ExportDecl2
	GHC.Name	      -- the original name
	(GHC.HsDecl GHC.Name) -- a declaration
        (Maybe (GHC.HsDoc GHC.Name))       -- maybe a doc comment
	[InstHead]	      -- instances relevant to this declaration

  | ExportNoDecl2	-- an exported entity for which we have no documentation
			-- (perhaps becuase it resides in another package)
	GHC.Name		-- the original name
	GHC.Name		-- where to link to
	[GHC.Name]	-- subordinate names

  | ExportGroup2		-- a section heading
	Int		-- section level (1, 2, 3, ... )
	String		-- section "id" (for hyperlinks)
	(GHC.HsDoc GHC.Name)		-- section heading text

  | ExportDoc2		-- some documentation
	(GHC.HsDoc GHC.Name)

  | ExportModule2	-- a cross-reference to another module
	GHC.Module

type InstHead = (HsContext,HsAsst)

type ModuleMap = Map Module Interface
type ModuleMap2 = Map GHC.Module HaddockModule

data HaddockModule = HM {
  hmod_options           :: [DocOption],
  hmod_exported_decl_map :: Map GHC.Name (GHC.HsDecl GHC.Name),
  hmod_orig_exports      :: [ExportItem2],
  hmod_sub_map           :: Map GHC.Name [GHC.Name]
}