Copyright | (c) David Waern 2010 |
---|---|
License | BSD-like |
Maintainer | haddock@projects.haskellorg |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The Haddock API: A rudimentory, highly experimental API exposing some of the internals of Haddock. Don't expect it to be stable.
Synopsis
- data Interface = Interface {
- ifaceMod :: !Module
- ifaceIsSig :: !Bool
- ifaceOrigFilename :: !FilePath
- ifaceInfo :: !(HaddockModInfo Name)
- ifaceDoc :: !(Documentation Name)
- ifaceRnDoc :: !(Documentation DocName)
- ifaceOptions :: ![DocOption]
- ifaceDeclMap :: !(Map Name [LHsDecl GhcRn])
- ifaceDocMap :: !(DocMap Name)
- ifaceArgMap :: !(ArgMap Name)
- ifaceRnDocMap :: !(DocMap DocName)
- ifaceRnArgMap :: !(ArgMap DocName)
- ifaceFixMap :: !(Map Name Fixity)
- ifaceExportItems :: ![ExportItem GhcRn]
- ifaceRnExportItems :: ![ExportItem DocNameI]
- ifaceExports :: ![Name]
- ifaceVisibleExports :: ![Name]
- ifaceModuleAliases :: !AliasMap
- ifaceInstances :: ![ClsInst]
- ifaceFamInstances :: ![FamInst]
- ifaceOrphanInstances :: ![DocInstance GhcRn]
- ifaceRnOrphanInstances :: ![DocInstance DocNameI]
- ifaceHaddockCoverage :: !(Int, Int)
- ifaceWarningMap :: !WarningMap
- ifaceHieFile :: !(Maybe FilePath)
- ifaceDynFlags :: !DynFlags
- data InstalledInterface = InstalledInterface {
- instMod :: Module
- instIsSig :: Bool
- instInfo :: HaddockModInfo Name
- instDocMap :: DocMap Name
- instArgMap :: ArgMap Name
- instExports :: [Name]
- instVisibleExports :: [Name]
- instOptions :: [DocOption]
- instFixMap :: Map Name Fixity
- toInstalledIface :: Interface -> InstalledInterface
- createInterfaces :: [Flag] -> [String] -> IO [Interface]
- processModules :: Verbosity -> [String] -> [Flag] -> [InterfaceFile] -> Ghc ([Interface], LinkEnv)
- data ExportItem name
- = ExportDecl {
- expItemDecl :: !(LHsDecl name)
- expItemPats :: ![(HsDecl name, DocForDecl (IdP name))]
- expItemMbDoc :: !(DocForDecl (IdP name))
- expItemSubDocs :: ![(IdP name, DocForDecl (IdP name))]
- expItemInstances :: ![DocInstance name]
- expItemFixities :: ![(IdP name, Fixity)]
- expItemSpliced :: !Bool
- | ExportNoDecl {
- expItemName :: !(IdP name)
- expItemSubs :: ![IdP name]
- | ExportGroup {
- expItemSectionLevel :: !Int
- expItemSectionId :: !String
- expItemSectionText :: !(Doc (IdP name))
- | ExportDoc !(MDoc (IdP name))
- | ExportModule !Module
- = ExportDecl {
- type DocForDecl name = (Documentation name, FnArgsDoc name)
- type FnArgsDoc name = Map Int (MDoc name)
- type LinkEnv = Map Name Module
- data DocName
- type DocInstance name = (InstHead name, Maybe (MDoc (IdP name)), Located (IdP name), Maybe Module)
- data InstHead name
- type Doc id = DocH (Wrap (ModuleName, OccName)) (Wrap id)
- type MDoc id = MetaDoc (Wrap (ModuleName, OccName)) (Wrap id)
- data DocH mod id
- = DocEmpty
- | DocAppend (DocH mod id) (DocH mod id)
- | DocString String
- | DocParagraph (DocH mod id)
- | DocIdentifier id
- | DocIdentifierUnchecked mod
- | DocModule (ModLink (DocH mod id))
- | DocWarning (DocH mod id)
- | DocEmphasis (DocH mod id)
- | DocMonospaced (DocH mod id)
- | DocBold (DocH mod id)
- | DocUnorderedList [DocH mod id]
- | DocOrderedList [DocH mod id]
- | DocDefList [(DocH mod id, DocH mod id)]
- | DocCodeBlock (DocH mod id)
- | DocHyperlink (Hyperlink (DocH mod id))
- | DocPic Picture
- | DocMathInline String
- | DocMathDisplay String
- | DocAName String
- | DocProperty String
- | DocExamples [Example]
- | DocHeader (Header (DocH mod id))
- | DocTable (Table (DocH mod id))
- data Example = Example {}
- data Hyperlink id = Hyperlink {
- hyperlinkUrl :: String
- hyperlinkLabel :: Maybe id
- type DocMarkup id a = DocMarkupH (Wrap (ModuleName, OccName)) id a
- data DocMarkupH mod id a = Markup {
- markupEmpty :: a
- markupString :: String -> a
- markupParagraph :: a -> a
- markupAppend :: a -> a -> a
- markupIdentifier :: id -> a
- markupIdentifierUnchecked :: mod -> a
- markupModule :: ModLink a -> a
- markupWarning :: a -> a
- markupEmphasis :: a -> a
- markupBold :: a -> a
- markupMonospaced :: a -> a
- markupUnorderedList :: [a] -> a
- markupOrderedList :: [a] -> a
- markupDefList :: [(a, a)] -> a
- markupCodeBlock :: a -> a
- markupHyperlink :: Hyperlink a -> a
- markupAName :: String -> a
- markupPic :: Picture -> a
- markupMathInline :: String -> a
- markupMathDisplay :: String -> a
- markupProperty :: String -> a
- markupExample :: [Example] -> a
- markupHeader :: Header a -> a
- markupTable :: Table a -> a
- data Documentation name = Documentation {
- documentationDoc :: Maybe (MDoc name)
- documentationWarning :: !(Maybe (Doc name))
- type ArgMap a = Map Name (Map Int (MDoc a))
- type AliasMap = Map Module ModuleName
- type WarningMap = Map Name (Doc Name)
- type DocMap a = Map Name (MDoc a)
- data HaddockModInfo name = HaddockModInfo {}
- markup :: DocMarkupH mod id a -> DocH mod id -> a
- data InterfaceFile = InterfaceFile {}
- readInterfaceFile :: forall m. MonadIO m => NameCacheAccessor m -> FilePath -> Bool -> m (Either String InterfaceFile)
- nameCacheFromGhc :: GhcMonad m => NameCacheAccessor m
- freshNameCache :: NameCacheAccessor IO
- type NameCacheAccessor m = (m NameCache, NameCache -> m ())
- data Flag
- = Flag_BuiltInThemes
- | Flag_CSS String
- | Flag_ReadInterface String
- | Flag_DumpInterface String
- | Flag_ShowInterface String
- | Flag_Heading String
- | Flag_Html
- | Flag_Hoogle
- | Flag_Lib String
- | Flag_OutputDir FilePath
- | Flag_Prologue FilePath
- | Flag_SourceBaseURL String
- | Flag_SourceModuleURL String
- | Flag_SourceEntityURL String
- | Flag_SourceLEntityURL String
- | Flag_WikiBaseURL String
- | Flag_WikiModuleURL String
- | Flag_WikiEntityURL String
- | Flag_LaTeX
- | Flag_LaTeXStyle String
- | Flag_QuickJumpIndex
- | Flag_HyperlinkedSource
- | Flag_SourceCss String
- | Flag_Mathjax String
- | Flag_Help
- | Flag_Verbosity String
- | Flag_Version
- | Flag_CompatibleInterfaceVersions
- | Flag_InterfaceVersion
- | Flag_BypassInterfaceVersonCheck
- | Flag_UseContents String
- | Flag_GenContents
- | Flag_UseIndex String
- | Flag_GenIndex
- | Flag_IgnoreAllExports
- | Flag_HideModule String
- | Flag_ShowModule String
- | Flag_ShowAllModules
- | Flag_ShowExtensions String
- | Flag_OptGhc String
- | Flag_GhcLibDir String
- | Flag_GhcVersion
- | Flag_PrintGhcPath
- | Flag_PrintGhcLibDir
- | Flag_NoWarnings
- | Flag_UseUnicode
- | Flag_NoTmpCompDir
- | Flag_Qualification String
- | Flag_PrettyHtml
- | Flag_NoPrintMissingDocs
- | Flag_PackageName String
- | Flag_PackageVersion String
- | Flag_Reexport String
- | Flag_SinceQualification String
- | Flag_IgnoreLinkSymbol String
- data DocOption
- data HaddockException
- haddock :: [String] -> IO ()
- haddockWithGhc :: (forall a. [Flag] -> Ghc a -> IO a) -> [String] -> IO ()
- getGhcDirs :: [Flag] -> IO (Maybe FilePath, Maybe FilePath)
- withGhc :: [Flag] -> Ghc a -> IO a
Interface
Interface
holds all information used to render a single Haddock page.
It represents the interface of a module. The core business of Haddock
lies in creating this structure. Note that the record contains some fields
that are only used to create the final record, and that are not used by the
backends.
Interface | |
|
data InstalledInterface Source #
A subset of the fields of Interface
that we store in the interface
files.
InstalledInterface | |
|
Instances
Binary InstalledInterface Source # | |
Defined in Haddock.InterfaceFile put_ :: BinHandle -> InstalledInterface -> IO () # put :: BinHandle -> InstalledInterface -> IO (Bin InstalledInterface) # get :: BinHandle -> IO InstalledInterface # |
toInstalledIface :: Interface -> InstalledInterface Source #
Convert an Interface
to an InstalledInterface
:: Verbosity | Verbosity of logging to |
-> [String] | A list of file or module names sorted by module topology |
-> [Flag] | Command-line flags |
-> [InterfaceFile] | Interface files of package dependencies |
-> Ghc ([Interface], LinkEnv) | Resulting list of interfaces and renaming environment |
Create Interface
s and a link environment by typechecking the list of
modules using the GHC API and processing the resulting syntax trees.
Export items & declarations
data ExportItem name Source #
ExportDecl | An exported declaration. |
| |
ExportNoDecl | An exported entity for which we have no documentation (perhaps because it resides in another package). |
| |
ExportGroup | A section heading. |
| |
ExportDoc !(MDoc (IdP name)) | Some documentation. |
ExportModule !Module | A cross-reference to another module. |
type DocForDecl name = (Documentation name, FnArgsDoc name) Source #
type FnArgsDoc name = Map Int (MDoc name) Source #
Arguments and result are indexed by Int, zero-based from the left, because that's the easiest to use when recursing over types.
Cross-referencing
type LinkEnv = Map Name Module Source #
Type of environment used to cross-reference identifiers in the syntax.
Extends Name
with cross-reference information.
Documented Name Module | This thing is part of the (existing or resulting)
documentation. The |
Undocumented Name | This thing is not part of the (existing or resulting) documentation, as far as Haddock knows. |
Instances
Eq DocName Source # | |
Data DocName Source # | |
Defined in Haddock.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DocName -> c DocName # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DocName # toConstr :: DocName -> Constr # dataTypeOf :: DocName -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DocName) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DocName) # gmapT :: (forall b. Data b => b -> b) -> DocName -> DocName # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DocName -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DocName -> r # gmapQ :: (forall d. Data d => d -> u) -> DocName -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DocName -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DocName -> m DocName # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DocName -> m DocName # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DocName -> m DocName # | |
NamedThing DocName Source # | |
Defined in Haddock.Types | |
HasOccName DocName Source # | |
Defined in Haddock.Types | |
Binary DocName Source # | |
Outputable DocName Source # | Useful for debugging |
OutputableBndr DocName Source # | |
Defined in Haddock.Types pprBndr :: BindingSite -> DocName -> SDoc # pprPrefixOcc :: DocName -> SDoc # pprInfixOcc :: DocName -> SDoc # bndrIsJoin_maybe :: DocName -> Maybe Int # |
Instances
type DocInstance name = (InstHead name, Maybe (MDoc (IdP name)), Located (IdP name), Maybe Module) Source #
An instance head that may have documentation and a source location.
The head of an instance. Consists of a class name, a list of type parameters (which may be annotated with kinds), and an instance type
Documentation comments
DocEmpty | |
DocAppend (DocH mod id) (DocH mod id) | |
DocString String | |
DocParagraph (DocH mod id) | |
DocIdentifier id | |
DocIdentifierUnchecked mod | A qualified identifier that couldn't be resolved. |
DocModule (ModLink (DocH mod id)) | A link to a module, with an optional label. |
DocWarning (DocH mod id) | This constructor has no counterpart in Haddock markup. |
DocEmphasis (DocH mod id) | |
DocMonospaced (DocH mod id) | |
DocBold (DocH mod id) | |
DocUnorderedList [DocH mod id] | |
DocOrderedList [DocH mod id] | |
DocDefList [(DocH mod id, DocH mod id)] | |
DocCodeBlock (DocH mod id) | |
DocHyperlink (Hyperlink (DocH mod id)) | |
DocPic Picture | |
DocMathInline String | |
DocMathDisplay String | |
DocAName String | A (HTML) anchor. It must not contain any spaces. |
DocProperty String | |
DocExamples [Example] | |
DocHeader (Header (DocH mod id)) | |
DocTable (Table (DocH mod id)) |
Instances
Bitraversable DocH | NOTE: Only defined for |
Defined in Documentation.Haddock.Types bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> DocH a b -> f (DocH c d) # | |
Bifoldable DocH | NOTE: Only defined for |
Bifunctor DocH | NOTE: Only defined for |
Functor (DocH mod) | |
Foldable (DocH mod) | |
Defined in Documentation.Haddock.Types fold :: Monoid m => DocH mod m -> m # foldMap :: Monoid m => (a -> m) -> DocH mod a -> m # foldMap' :: Monoid m => (a -> m) -> DocH mod a -> m # foldr :: (a -> b -> b) -> b -> DocH mod a -> b # foldr' :: (a -> b -> b) -> b -> DocH mod a -> b # foldl :: (b -> a -> b) -> b -> DocH mod a -> b # foldl' :: (b -> a -> b) -> b -> DocH mod a -> b # foldr1 :: (a -> a -> a) -> DocH mod a -> a # foldl1 :: (a -> a -> a) -> DocH mod a -> a # elem :: Eq a => a -> DocH mod a -> Bool # maximum :: Ord a => DocH mod a -> a # minimum :: Ord a => DocH mod a -> a # | |
Traversable (DocH mod) | |
(Eq id, Eq mod) => Eq (DocH mod id) | |
(Show id, Show mod) => Show (DocH mod id) | |
(NFData a, NFData mod) => NFData (DocH mod a) Source # | |
Defined in Haddock.Types | |
(Binary mod, Binary id) => Binary (DocH mod id) Source # | |
Hyperlink | |
|
Instances
Functor Hyperlink | |
Foldable Hyperlink | |
Defined in Documentation.Haddock.Types fold :: Monoid m => Hyperlink m -> m # foldMap :: Monoid m => (a -> m) -> Hyperlink a -> m # foldMap' :: Monoid m => (a -> m) -> Hyperlink a -> m # foldr :: (a -> b -> b) -> b -> Hyperlink a -> b # foldr' :: (a -> b -> b) -> b -> Hyperlink a -> b # foldl :: (b -> a -> b) -> b -> Hyperlink a -> b # foldl' :: (b -> a -> b) -> b -> Hyperlink a -> b # foldr1 :: (a -> a -> a) -> Hyperlink a -> a # foldl1 :: (a -> a -> a) -> Hyperlink a -> a # toList :: Hyperlink a -> [a] # length :: Hyperlink a -> Int # elem :: Eq a => a -> Hyperlink a -> Bool # maximum :: Ord a => Hyperlink a -> a # minimum :: Ord a => Hyperlink a -> a # | |
Traversable Hyperlink | |
Defined in Documentation.Haddock.Types | |
Eq id => Eq (Hyperlink id) | |
Show id => Show (Hyperlink id) | |
NFData id => NFData (Hyperlink id) Source # | |
Defined in Haddock.Types | |
Binary a => Binary (Hyperlink a) Source # | |
type DocMarkup id a = DocMarkupH (Wrap (ModuleName, OccName)) id a Source #
data DocMarkupH mod id a #
DocMarkupH
is a set of instructions for marking up documentation.
In fact, it's really just a mapping from Doc
to some other
type [a], where [a] is usually the type of the output (HTML, say).
Use markup
to apply a DocMarkupH
to
a DocH
.
Since: haddock-library-1.4.5
Markup | |
|
data Documentation name Source #
Documentation | |
|
Instances
Functor Documentation Source # | |
Defined in Haddock.Types fmap :: (a -> b) -> Documentation a -> Documentation b # (<$) :: a -> Documentation b -> Documentation a # |
data HaddockModInfo name Source #
HaddockModInfo | |
|
Instances
Binary name => Binary (HaddockModInfo name) Source # | |
Defined in Haddock.InterfaceFile put_ :: BinHandle -> HaddockModInfo name -> IO () # put :: BinHandle -> HaddockModInfo name -> IO (Bin (HaddockModInfo name)) # get :: BinHandle -> IO (HaddockModInfo name) # |
markup :: DocMarkupH mod id a -> DocH mod id -> a #
Interface files
data InterfaceFile Source #
Instances
Binary InterfaceFile Source # | |
Defined in Haddock.InterfaceFile put_ :: BinHandle -> InterfaceFile -> IO () # put :: BinHandle -> InterfaceFile -> IO (Bin InterfaceFile) # get :: BinHandle -> IO InterfaceFile # |
:: forall m. MonadIO m | |
=> NameCacheAccessor m | |
-> FilePath | |
-> Bool | Disable version check. Can cause runtime crash. |
-> m (Either String InterfaceFile) |
Read a Haddock (.haddock
) interface file. Return either an
InterfaceFile
or an error message.
This function can be called in two ways. Within a GHC session it will update the use and update the session's name cache. Outside a GHC session a new empty name cache is used. The function is therefore generic in the monad being used. The exact monad is whichever monad the first argument, the getter and setter of the name cache, requires.
nameCacheFromGhc :: GhcMonad m => NameCacheAccessor m Source #
type NameCacheAccessor m = (m NameCache, NameCache -> m ()) Source #
Flags and options
Source-level options for controlling the documentation.
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. |
OptShowExtensions | Render enabled extensions for this module. |
Error handling
data HaddockException Source #
Haddock's own exception type.
Instances
Show HaddockException Source # | |
Defined in Haddock.Types showsPrec :: Int -> HaddockException -> ShowS # show :: HaddockException -> String # showList :: [HaddockException] -> ShowS # | |
Exception HaddockException Source # | |
Defined in Haddock.Types |
Program entry point
haddock :: [String] -> IO () Source #
Run Haddock with given list of arguments.
Haddock's own main function is defined in terms of this:
main = getArgs >>= haddock