-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Config defaults for dune-project (#10835)
* support for authors default from config Signed-off-by: teague hansen <[email protected]>
- Loading branch information
Showing
13 changed files
with
251 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- Add support for specifying default values of the `authors`, `maintainers`, and | ||
`license` stanzas of the `dune-project` file via the dune config file. Default | ||
values are set using the `(project_defaults)` stanza (#10835, @H-ANSEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
project_defaults | ||
---------------- | ||
|
||
.. versionadded:: 3.17 | ||
|
||
Specify default values for stanzas ``authors``, ``maintainers``, and ``license`` | ||
of the :doc:`../dune-project/index` file when initializing a project with | ||
``dune init proj``. The format of the 'project_defaults' stanza is as follows: | ||
|
||
.. code:: dune | ||
(project_defaults | ||
<optional-fields>) | ||
``<optional-fields>`` are: | ||
|
||
.. describe:: (authors <string(s)>) | ||
|
||
Specify authors. | ||
|
||
Example: | ||
|
||
.. code:: dune | ||
(project_defaults | ||
(authors | ||
"Jane Doe <[email protected]>" | ||
"John Doe <[email protected]>")) | ||
.. describe:: (maintainers <string(s)>) | ||
|
||
Specify maintainers. | ||
|
||
Example: | ||
|
||
.. code:: dune | ||
(project_defaults | ||
(maintainers | ||
"Jane Doe <[email protected]>" | ||
"John Doe <[email protected]>")) | ||
.. describe:: (license <string(s)>) | ||
|
||
Specify license, ideally as an identifier from the `SPDX License List | ||
<https://spdx.org/licenses/>`__. | ||
|
||
Example: | ||
|
||
.. code:: dune | ||
(project_defaults | ||
(license "MIT")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,28 @@ module Dune_config = struct | |
simplicity *) | ||
let syntax = Stanza.syntax | ||
|
||
module Project_defaults = struct | ||
type t = | ||
{ authors : string list option | ||
; maintainers : string list option | ||
; license : string list option | ||
} | ||
|
||
let decode = | ||
fields | ||
(let+ authors = field_o "authors" (repeat string) | ||
and+ maintainers = field_o "maintainers" (repeat string) | ||
and+ license = field_o "license" (repeat string) in | ||
{ authors; maintainers; license }) | ||
;; | ||
|
||
let to_dyn t = | ||
let f = Dyn.(option (list string)) in | ||
Dyn.record | ||
[ "authors", f t.authors; "maintainers", f t.maintainers; "license", f t.license ] | ||
;; | ||
end | ||
|
||
module Terminal_persistence = struct | ||
type t = | ||
| Preserve | ||
|
@@ -136,6 +158,7 @@ module Dune_config = struct | |
; cache_storage_mode : Cache.Storage_mode.t field | ||
; action_stdout_on_success : Action_output_on_success.t field | ||
; action_stderr_on_success : Action_output_on_success.t field | ||
; project_defaults : Project_defaults.t field | ||
; experimental : (string * (Loc.t * string)) list field | ||
} | ||
end | ||
|
@@ -163,6 +186,7 @@ module Dune_config = struct | |
field a.action_stdout_on_success b.action_stdout_on_success | ||
; action_stderr_on_success = | ||
field a.action_stderr_on_success b.action_stderr_on_success | ||
; project_defaults = field a.project_defaults b.project_defaults | ||
; experimental = field a.experimental b.experimental | ||
} | ||
;; | ||
|
@@ -186,6 +210,7 @@ module Dune_config = struct | |
; cache_storage_mode | ||
; action_stdout_on_success | ||
; action_stderr_on_success | ||
; project_defaults | ||
; experimental | ||
} | ||
= | ||
|
@@ -205,6 +230,7 @@ module Dune_config = struct | |
, field Action_output_on_success.to_dyn action_stdout_on_success ) | ||
; ( "action_stderr_on_success" | ||
, field Action_output_on_success.to_dyn action_stderr_on_success ) | ||
; "project_defaults", field Project_defaults.to_dyn project_defaults | ||
; ( "experimental" | ||
, field Dyn.(list (pair string (fun (_, v) -> string v))) experimental ) | ||
] | ||
|
@@ -228,6 +254,7 @@ module Dune_config = struct | |
; cache_storage_mode = None | ||
; action_stdout_on_success = None | ||
; action_stderr_on_success = None | ||
; project_defaults = None | ||
; experimental = None | ||
} | ||
;; | ||
|
@@ -294,6 +321,11 @@ module Dune_config = struct | |
; cache_storage_mode = Some (Dune_cache_storage.Mode.default ()) | ||
; action_stdout_on_success = Print | ||
; action_stderr_on_success = Print | ||
; project_defaults = | ||
{ authors = Some [ "Author Name <[email protected]>" ] | ||
; maintainers = Some [ "Maintainer Name <[email protected]>" ] | ||
; license = Some [ "LICENSE" ] | ||
} | ||
; experimental = [] | ||
} | ||
;; | ||
|
@@ -357,6 +389,7 @@ module Dune_config = struct | |
field_o "action_stdout_on_success" (3, 0) Action_output_on_success.decode | ||
and+ action_stderr_on_success = | ||
field_o "action_stderr_on_success" (3, 0) Action_output_on_success.decode | ||
and+ project_defaults = field_o "project_defaults" (3, 17) Project_defaults.decode | ||
and+ experimental = | ||
field_o "experimental" (3, 8) (repeat (pair string (located string))) | ||
in | ||
|
@@ -377,6 +410,7 @@ module Dune_config = struct | |
; cache_storage_mode | ||
; action_stdout_on_success | ||
; action_stderr_on_success | ||
; project_defaults | ||
; experimental | ||
} | ||
;; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,12 +41,14 @@ let empty = | |
} | ||
;; | ||
|
||
let example = | ||
let example ~authors ~maintainers ~license = | ||
{ source = | ||
Some (Host (Source_kind.Host.Github { user = "username"; repo = "reponame" })) | ||
; license = Some [ "LICENSE" ] | ||
; authors = Some [ "Author Name <[email protected]>" ] | ||
; maintainers = Some [ "Maintainer Name <[email protected]>" ] | ||
; license = Some (Option.value license ~default:[ "LICENSE" ]) | ||
; authors = Some (Option.value authors ~default:[ "Author Name <[email protected]>" ]) | ||
; maintainers = | ||
Some | ||
(Option.value maintainers ~default:[ "Maintainer Name <[email protected]>" ]) | ||
; documentation = | ||
Some "https://url/to/documentation" | ||
(* homepage and bug_reports are inferred from the source *) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.