package dunolint
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=b44119c96aeabb960e852711c2f20ae43f0011e796f05e012141ba980a5b58f6
sha512=5bf76732adc940db6cac0875e94c3eaff436288faba95388b9675c68b3f30f5362e01f289fc8a096325f7db812ace273773a1e051ab7d7ace3b8db4a57a0e070
doc/dunolint.dunolinter/Dunolinter/Sexp_handler/index.html
Module Dunolinter.Sexp_handler
Source
A handler for fields found in a dune stanza (in files "dune", "dune-project", etc.)
Such field is typically identified by its name, and then it is immediately followed by a variable number of arguments.
For example:
(name dunolint)
(libraries base sexps-rewriter)
A field starts with an atom (the field name), and the arguments are in a list of sexps.
By that definition, a stanza is a field itself, and its subfields just as well.
A util to create a handler for an atom field, that is one that expects exactly one required argument that is an Sexp.Atom
.
A util to create a generic field handler that doesn't try to parse its arguments.
A util to create a handler from a sexpable type. The handler will expect exactly one value, which will be parsed and written (or replaced) according to the sexp serializer provided.
Utils
val find :
(module S with type t = 'a) ->
sexps_rewriter:Sexps_rewriter.t ->
fields:Base.Sexp.t Base.list ->
'a Base.option
A convenient wrapper for read
that finds the field to read from a list of fields embedded within a containing list of fields. The first field with the expected name is chosen and then we call read
on it.
val get_args :
field_name:Base.string ->
sexps_rewriter:Sexps_rewriter.t ->
field:Base.Sexp.t ->
Base.Sexp.t Base.list
Destruct the given field and verify it has the correct field name. Return the args then. If the field doesn't have the right shape, and error is raised, using a location found via sexps_rewriter
.
val insert_new_fields :
sexps_rewriter:Sexps_rewriter.t ->
indicative_field_ordering:Base.string Base.list ->
fields:Base.Sexp.t Base.list ->
new_fields:Base.Sexp.t Base.list ->
Base.unit
During a dunolint lint, insert all fields found in new_fields
that are not present in the existing fields
. For those that are already present, it will be necessary to merge them with the expected value, see the rewrite
functions of the module that corresponds to that particular field. For example: Dune_linter.Library.rewrite
.