package dunolint

  1. Overview
  2. Docs
A linter for build files in dune projects

Install

dune-project
 Dependency

Authors

Maintainers

Sources

dunolint-0.0.20250804.tbz
sha256=e4ca7c98db73dd9ab2ae8cba37ee0645f580267484e9893dbce6e28f4f2f0170
sha512=7ca658fb96139a0c41724355ac6aaf83d75468c7df14569b8f6090711f73a8fb2408ed1145384e756418682f0fa660a915842fd2b3f8b42e5ed4990e795b384e

doc/dunolint.dunolinter/Dunolinter/Sections_handler/index.html

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.