package dunolint
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e4ca7c98db73dd9ab2ae8cba37ee0645f580267484e9893dbce6e28f4f2f0170
sha512=7ca658fb96139a0c41724355ac6aaf83d75468c7df14569b8f6090711f73a8fb2408ed1145384e756418682f0fa660a915842fd2b3f8b42e5ed4990e795b384e
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 single sexpable type. The handler will expect exactly one value, which will be parsed and written (or replaced) according to the sexp serializer provided.
module Make_sexpable_list
(_ : sig ... end)
(M : Base.Sexpable.S) :
S with type t = M.t Base.list
A util to create a handler for multiple args with the same sexpable type. The handler will expect a list of arguments, which will each be parsed and written (or replaced) according to the sexp serializer provided.
module Make_sexpable_ordered_set
(_ : sig ... end)
(M : Base.Sexpable.S) :
S with type t = M.t Ordered_set.t
A util to create a handler for an ordered set where individual elements have the same sexpable type. The handler will expect a list of arguments, will support and parse the ordered set constructors of dune, and parse the elements 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
.