package dunolint

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Dunolinter.Sections_handlerSource

A utility module to help with the management of fields containing separated sections.

Sections denote parts that are separated by comments or blank lines within a field. For example, in libraries:

 (libraries
   ;; This is a first section
   aa
   bb
   ;; This is a second section
   cc
   zz)

We make use of this module, in addition to the the Comment_handler to implement and share some functionality related to the handling of such sections in fields.

Sourceval are_in_different_sections : previous:Parsexp.Positions.range -> current:Parsexp.Positions.range -> Base.bool

Tell whether two consecutive arguments are to be treated as belonging to different sections.

The way dunolint does this, is to look whether two consecutive entries are separated by more than 1 line. In particular this covers the case where entries are separated by a comment in its own line, in which case dunolint will consider that the dependencies are in different sections.

 (libraries
   aa
   bb
   ;; this a comment
   cc
   zz)

are_in_different_section must be called with two consecutive arguments, otherwise the returned value does not have any particular meaning.

Sourceval read_sections_fold : field_name:Base.string -> sexps_rewriter:Sexps_rewriter.t -> field:Base.Sexp.t -> init:'acc -> f: ('acc -> original_index:Base.int -> loc:Loc.t -> source:Base.string -> arg:Base.Sexp.t -> 'acc * 'a) -> 'a Base.list Base.list

Read the arguments from an existing field, grouping them into sections according to the heuristic implemented by this module.

Sourceval read_sections : field_name:Base.string -> sexps_rewriter:Sexps_rewriter.t -> field:Base.Sexp.t -> f: (original_index:Base.int -> loc:Loc.t -> source:Base.string -> arg:Base.Sexp.t -> 'a) -> 'a Base.list Base.list

A simplified version of read_sections_fold with no accumulator.

Sourceval rewrite_sections : field_name:Base.string -> sexps_rewriter:Sexps_rewriter.t -> field:Base.Sexp.t -> write_arg:('a -> Base.string) -> sections:'a Base.list Base.list -> Base.unit

This removes, replaces and inserts argument into sexps_rewriter while computing the diff between the input sections that we'd like to write, and the existing values found within field that we'd like to modify. Typically, sections is obtained from linting values according to rules, and field is the existing contents that was loaded from disk that we'd like to modify.

OCaml

Innovation. Community. Security.