cabal-gild-1.1.4.0: Formats package descriptions.
Safe HaskellSafe-Inferred
LanguageHaskell2010

CabalGild.Action.ReflowText

Synopsis

Documentation

run :: Applicative m => CabalSpecVersion -> ([Field (Position, [Comment Position])], cs) -> m ([Field (Position, [Comment Position])], cs) Source #

A wrapper around fields to allow this to be composed with other actions.

fields :: CabalSpecVersion -> [Field (Position, [Comment Position])] -> [Field (Position, [Comment Position])] Source #

Reflows the free text field values if the Cabal spec version is recent enough (at least 3.0).

Note that this requires comments to be already attached. That's because comments should not be attached to blank lines, which this function will insert.

field :: Field (Position, [Comment Position]) -> Field (Position, [Comment Position]) Source #

Reflows the free text field value if applicable. Otherwise returns the field as is. If the field is a section, the fields within the section will be recursively reflowed.

relevantFieldNames :: Set FieldName Source #

The names of the fields that should be reflowed.

fieldLines :: Field (Position, [Comment Position]) -> [FieldLine (Position, [Comment Position])] -> [FieldLine (Position, [Comment Position])] Source #

Reflows the field lines for the given field. This is just a wrapper around fixRows and fixCols.

fixRows :: [FieldLine (Position, [Comment Position])] -> [FieldLine (Position, [Comment Position])] Source #

Inserts blank lines between field lines if necessary.

fixCols :: Field (Position, [Comment Position]) -> [FieldLine (Position, [Comment Position])] -> [FieldLine (Position, [Comment Position])] Source #

Reindents field lines by finding the least indented line and adjusting the other lines relative to that one. Note that if the first field line is on the same line as the field itself, it will never be reindented.

fieldLineToCol :: FieldLine (Position, cs) -> Int Source #

Extracts the column number from a field line.

fieldLineToFirstRow :: FieldLine (Position, [Comment Position]) -> Int Source #

Extracts the first row number from a field line, which might belong to one of its comments.

fieldLineToLastRow :: FieldLine (Position, cs) -> Int Source #

Extracts the last row number from a field line, which will not belong to any of its comments.

fieldToRow :: Field (Position, cs) -> Int Source #

Extracts the row number from a field.

reindent :: Int -> FieldLine (Position, cs) -> FieldLine (Position, cs) Source #

Reindents the field line using the given column number.

rowToFieldLine :: Int -> FieldLine (Position, [c]) Source #

Creates a blank field line at the given row number.