Skip to content

Commit 7e320d5

Browse files
authored
doc: mention opam file templates (#12710)
Fixes #11177 Signed-off-by: Ali Caglayan <[email protected]>
1 parent eef3831 commit 7e320d5

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

doc/reference/dune-project/generate_opam_files.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ generate_opam_files
2020
With this field, every time one calls Dune to execute some rules (either via
2121
``dune build``, ``dune runtest``, or something else), the opam files get
2222
generated.
23+
24+
To add opam fields not directly supported by ``dune-project``, you can use
25+
``<package-name>.opam.template`` files (see :doc:`/reference/packages`).
26+
27+
.. seealso::
28+
29+
:doc:`/reference/dune-project/package` for fields supported by
30+
``dune-project``
31+
32+
:doc:`/reference/packages` for more information on ``opam.template`` files

doc/reference/packages.rst

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,47 @@ How Dune Knows About Packages
1010

1111
Packages can be defined in two ways:
1212

13-
- If a ``pkg.opam`` file is found, it signals the existence of the ``pkg``
14-
package to Dune. The contents of the opam file are not interpreted by Dune.
15-
- In ``dune-project``, a ``(package)`` stanza with ``(name pkg)`` defines the
16-
``pkg`` package.
13+
- If a ``<package-name>.opam`` file is found, it signals the existence of the
14+
``<package-name>`` package to Dune. The contents of the opam file are not
15+
interpreted by Dune, unless :doc:`package management
16+
<../explanation/package-management>` is :doc:`enabled <config/pkg>`.
17+
18+
- In ``dune-project``, a :doc:`(package) <dune-project/package>` stanza with
19+
``(name <package-name>)`` defines the ``<package-name>`` package.
1720

1821
.. note::
1922

2023
If you want to define public elements but are not interested in publishing
2124
to opam, it is not necessary to write empty ``*.opam`` files. Instead,
22-
prefer declaring it in ``dune-project`` as a ``(package)`` with just a
23-
``(name)``.
25+
prefer declaring it in ``dune-project`` as a :doc:`(package)
26+
<dune-project/package>` with just a ``(name)``.
2427

2528
Generating Opam Files
2629
---------------------
2730

28-
In the latter case, if ``(generate_opam_files)`` is present in
29-
``(dune-project)``, Dune will generate ``pkg.opam`` using the metadata in found in ``(package)`` stanzas and global fields such as ``(source)``.
31+
In the latter case, if :doc:`(generate_opam_files)
32+
<dune-project/generate_opam_files>` is present in ``(dune-project)``, Dune will
33+
generate ``<package-name>.opam`` using the metadata in found in :doc:`(package)
34+
<dune-project/package>` stanzas and global fields such as ``(source)``.
3035

3136
.. seealso:: :doc:`../howto/opam-file-generation`
3237

33-
If a ``pkg.opam.template`` file is found, the fields found in this opam file
34-
are added to the generated file, overriding the generated ones in case of
35-
collision. This can be used as an escape hatch to add arbitrary opam fields.
38+
If a ``<package-name>.opam.template`` file is found, the fields found in this
39+
opam file are added to the generated file, overriding the generated ones in
40+
case of collision. This can be used as an escape hatch to add arbitrary opam
41+
fields.
42+
43+
.. seealso:: :doc:`dune-project/package` for fields supported by ``dune-project``
3644

3745
What Dune Installs
3846
------------------
3947

4048
Dune will install the following files:
4149

4250
- ``(library)`` stanzas which have a ``(public_name)``. The package name is the
43-
first component of the dot-separated public name: ``(public_name pkg)`` and
44-
``(public_name pkg.sub)`` will look for a package named ``pkg`` to install
45-
their contents.
51+
first component of the dot-separated public name: ``(public_name
52+
<package-name>)`` and ``(public_name <package-name>.sub)`` will look for a
53+
package named ``<package-name>`` to install their contents.
4654
- ``(executable)`` and ``(test)`` stanzas with a ``(public_name)``. The package
4755
to install the files in is determined by the ``(package)`` field, which can
4856
be omitted if there is only one package.

0 commit comments

Comments
 (0)