Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Support for extracting data from Haddock module headers present in Haskell source code files or templates.
Synopsis
- data HaddockModuleHeader = HaddockModuleHeader {}
- extractFieldOffsets :: Template t => t -> HaddockFieldOffsets
- extractModuleHeader :: Text -> Maybe TemplateMeta -> HaddockModuleHeader
- indentField :: Maybe Int -> Text -> Text
- stripCommentSyntax :: Text -> Text
Documentation
data HaddockModuleHeader Source #
Extracted fields from the Haddock module header.
HaddockModuleHeader | |
|
Instances
Eq HaddockModuleHeader Source # | |
Defined in Headroom.Ext.Haskell.Haddock (==) :: HaddockModuleHeader -> HaddockModuleHeader -> Bool # (/=) :: HaddockModuleHeader -> HaddockModuleHeader -> Bool # | |
Show HaddockModuleHeader Source # | |
Defined in Headroom.Ext.Haskell.Haddock showsPrec :: Int -> HaddockModuleHeader -> ShowS # show :: HaddockModuleHeader -> String # showList :: [HaddockModuleHeader] -> ShowS # |
:: Template t | |
=> t | parsed template |
-> HaddockFieldOffsets | extracted field offsets |
Extracts offsets for selected haddock fields (i.e. number of chars between start of line and field value). This is needed to properly format multi-line field values rendered in new license headers.
:: Text | text containing Haddock module header |
-> Maybe TemplateMeta | extracted metadata from corresponding template |
-> HaddockModuleHeader | extracted metadata |
Extracts metadata from given Haddock module header.
:: Maybe Int | offset (in number of black chars) for 2nd and subsequent lines |
-> Text | input text to indent |
-> Text | processed text |
Adds correct indentation to multi-line Haddock field values. It's usually desired to have such values indented like this:
Copyright : (c) 2020, 1st Author (c) 2020, 2nd Author
This functions achieves that using the offset value, which specifies number of empty characters that should be placed before second (and any subsequent) line.
>>>
indentField (Just 2) "foo\nbar\nbaz"
"foo\n bar\n baz"
Strips Haskell comment syntax tokens (e.g. {-
, -}
) from input text.
>>>
stripCommentSyntax "{- foo -}\nbar\n"
"foo \nbar\n"