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 rudimentary, 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
- ifaceInfo :: !(HaddockModInfo Name)
- ifaceDoc :: !(Documentation Name)
- ifaceRnDoc :: !(Documentation DocName)
- ifaceOptions :: [DocOption]
- ifaceDocMap :: !(DocMap Name)
- ifaceArgMap :: !(ArgMap Name)
- ifaceDefMeths :: ![(OccName, Name)]
- ifaceFixMap :: !(Map Name Fixity)
- ifaceExportItems :: [ExportItem GhcRn]
- ifaceRnExportItems :: [ExportItem DocNameI]
- ifaceExports :: [Name]
- ifaceVisibleExports :: [Name]
- ifaceInstances :: [ClsInst]
- ifaceOrphanInstances :: [DocInstance GhcRn]
- ifaceRnOrphanInstances :: [DocInstance DocNameI]
- ifaceHaddockCoverage :: (Int, Int)
- ifaceWarningMap :: WarningMap
- ifaceHieFile :: !FilePath
- ifaceDynFlags :: !DynFlags
- data InstalledInterface = InstalledInterface {
- instMod :: Module
- instIsSig :: Bool
- instInfo :: HaddockModInfo Name
- instDocMap :: DocMap Name
- instArgMap :: ArgMap Name
- instDefMeths :: [(OccName, Name)]
- instExports :: [Name]
- instVisibleExports :: [Name]
- instOptions :: [DocOption]
- instFixMap :: Map Name Fixity
- instWarningMap :: WarningMap
- instInstanceLocMap :: Map Name RealSrcSpan
- toInstalledIface :: Interface -> InstalledInterface
- createInterfaces :: [Flag] -> [String] -> IO [Interface]
- processModules :: Verbosity -> [String] -> [Flag] -> [InterfaceFile] -> Ghc ([Interface], LinkEnv)
- data ExportItem name
- = ExportDecl (XExportDecl name)
- | ExportNoDecl {
- expItemName :: !(IdP name)
- expItemSubs :: [IdP name]
- | ExportGroup {
- expItemSectionLevel :: !Int
- expItemSectionId :: !String
- expItemSectionText :: !(Doc (IdP name))
- | ExportDoc !(MDoc (IdP name))
- | ExportModule !Module
- 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 [(Int, 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 :: [(Int, 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 WarningMap = Map Name (Doc Name)
- type DocMap a = Map Name (MDoc a)
- data HaddockModInfo name = HaddockModInfo {
- hmi_description :: Maybe (Doc name)
- hmi_copyright :: Maybe String
- hmi_license :: Maybe String
- hmi_maintainer :: Maybe String
- hmi_stability :: Maybe String
- hmi_portability :: Maybe String
- hmi_safety :: Maybe String
- hmi_language :: Maybe Language
- hmi_extensions :: [Extension]
- markup :: DocMarkupH mod id a -> DocH mod id -> a
- data InterfaceFile = InterfaceFile {
- ifLinkEnv :: LinkEnv
- ifPackageInfo :: PackageInfo
- ifInstalledIfaces :: [InstalledInterface]
- readInterfaceFile :: NameCache -> FilePath -> Bool -> IO (Either String InterfaceFile)
- freshNameCache :: IO NameCache
- 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_BaseURL 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
- | Flag_ParCount (Maybe Int)
- | Flag_TraceArgs
- | Flag_OneShot String
- | Flag_NoCompilation
- 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_ :: WriteBinHandle -> InstalledInterface -> IO () Source # put :: WriteBinHandle -> InstalledInterface -> IO (Bin InstalledInterface) Source # get :: ReadBinHandle -> IO InstalledInterface Source # |
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 (XExportDecl name) | 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
NamedThing DocName Source # | |
HasOccName DocName Source # | |
Binary DocName Source # | |
Outputable DocName Source # | Useful for debugging |
OutputableBndr DocName Source # | |
Defined in Haddock.Types | |
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 # | |
Eq DocName Source # | |
type Anno DocName Source # | |
Defined in Haddock.Types |
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 [(Int, 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
Bifoldable DocH Source # | |
Bifunctor DocH Source # | |
Bitraversable DocH Source # | |
Defined in Documentation.Haddock.Types bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> DocH a b -> f (DocH c d) Source # | |
Functor (DocH mod) Source # | |
Foldable (DocH mod) Source # | |
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) Source # | |
(NFData a, NFData mod) => NFData (DocH mod a) Source # | |
Defined in Haddock.Types | |
(Binary mod, Binary id) => Binary (DocH mod id) Source # | |
(Show id, Show mod) => Show (DocH mod id) Source # | |
(Eq id, Eq mod) => Eq (DocH mod id) Source # | |
Hyperlink | |
|
Instances
Functor Hyperlink Source # | |
Foldable Hyperlink Source # | |
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 Source # | |
Defined in Documentation.Haddock.Types | |
NFData id => NFData (Hyperlink id) Source # | |
Defined in Haddock.Types | |
Binary a => Binary (Hyperlink a) Source # | |
Show id => Show (Hyperlink id) Source # | |
Eq id => Eq (Hyperlink id) Source # | |
type DocMarkup id a = DocMarkupH (Wrap (ModuleName, OccName)) id a Source #
data DocMarkupH mod id a Source #
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 # | |
NFData name => NFData (Documentation name) Source # | |
Defined in Haddock.Types rnf :: Documentation name -> () Source # |
data HaddockModInfo name Source #
HaddockModInfo | |
|
Instances
NFData name => NFData (HaddockModInfo name) Source # | |
Defined in Haddock.Types rnf :: HaddockModInfo name -> () Source # | |
Binary name => Binary (HaddockModInfo name) Source # | |
Defined in Haddock.InterfaceFile put_ :: WriteBinHandle -> HaddockModInfo name -> IO () Source # put :: WriteBinHandle -> HaddockModInfo name -> IO (Bin (HaddockModInfo name)) Source # get :: ReadBinHandle -> IO (HaddockModInfo name) Source # |
markup :: DocMarkupH mod id a -> DocH mod id -> a Source #
Interface files
data InterfaceFile Source #
InterfaceFile | |
|
Instances
Binary InterfaceFile Source # | |
Defined in Haddock.InterfaceFile put_ :: WriteBinHandle -> InterfaceFile -> IO () Source # put :: WriteBinHandle -> InterfaceFile -> IO (Bin InterfaceFile) Source # get :: ReadBinHandle -> IO InterfaceFile Source # |
:: NameCache | |
-> FilePath | |
-> Bool | Disable version check. Can cause runtime crash. |
-> IO (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.
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. |
OptPrintRuntimeRep | Render runtime reps for this module (see
the GHC |
Error handling
data HaddockException Source #
Haddock's own exception type.
Instances
Exception HaddockException Source # | |
Defined in Haddock.Types | |
Show HaddockException Source # | |
Defined in Haddock.Types showsPrec :: Int -> HaddockException -> ShowS # show :: HaddockException -> String # showList :: [HaddockException] -> ShowS # |
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