headroom-0.1.3.0: License Header Manager
Copyright(c) 2019-2020 Vaclav Svejcar
LicenseBSD-3
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Header

Description

License header is usually the very top comment in source code, holding some short text about license type, author and copyright. This module provides data types and functions for adding, dropping and replacing such headers. The license header is represented by Header data type, where FileType defines for which programming language source code this header is generated and the header text itself.

Synopsis

Documentation

data Header Source #

Generated license header for specified source code file type.

Constructors

Header 

Fields

Instances

Instances details
Eq Header Source # 
Instance details

Defined in Headroom.Header

Methods

(==) :: Header -> Header -> Bool #

(/=) :: Header -> Header -> Bool #

Show Header Source # 
Instance details

Defined in Headroom.Header

addHeader Source #

Arguments

:: Header

license header to add to the input text

-> Text

source code text

-> Text

source code text with added license header

Adds header to the given source code text if no existing header is detected, otherwise returns the unchanged input text. If you need to replace the header, use the replaceHeader instead.

containsHeader Source #

Arguments

:: FileType

type of the input source code text

-> Text

source code text

-> Bool

result of check

Checks whether the license header is present in given source code text.

dropHeader Source #

Arguments

:: FileType

type of the input source code text

-> Text

source code text

-> Text

source code text without the license header

Drops license header (if detected) from the given source code text.

headerSize Source #

Arguments

:: FileType

type of the input source code text

-> Text

source code text

-> Int

size of the headers (number of lines)

Detects what is the header size in terms of lines in the given source code text. Returns 0 if no header detected.

replaceHeader Source #

Arguments

:: Header

new license header to use for replacement

-> Text

source code text

-> Text

source code text with replaced license header

Replaces already existing (or adds if none detected) license header with the new one in the given source code text. If you need to only add header if none detected and skip if it already contains one, use the addHeader instead.