headroom-0.3.1.0: License Header Manager

Copyright(c) 2019-2020 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Ext.Haskell.Haddock

Description

Support for extracting data from Haddock module headers present in Haskell source code files or templates.

Synopsis

Documentation

data HaddockModuleHeader Source #

Extracted fields from the Haddock module header.

Constructors

HaddockModuleHeader 

Fields

extractFieldOffsets Source #

Arguments

:: 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.

extractModuleHeader Source #

Arguments

:: Text

text containing Haddock module header

-> Maybe TemplateMeta

extracted metadata from corresponding template

-> HaddockModuleHeader

extracted metadata

Extracts metadata from given Haddock module header.

indentField Source #

Arguments

:: 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"

stripCommentSyntax Source #

Arguments

:: Text

input text to strip

-> Text

resulting text without comment syntax tokens

Strips Haskell comment syntax tokens (e.g. {-, -}) from input text.

>>> stripCommentSyntax "{- foo -}\nbar\n"
"foo \nbar\n"