Skip to content

doc: Add documentation for the package dir field - #16818

Merged
Alizter merged 1 commit into
ocaml:mainfrom
punchagan:doc-package-dir-field
Nov 4, 2026
Merged

Alizter merged 1 commit into
ocaml:mainfrom
punchagan:doc-package-dir-field

Conversation

@punchagan

Copy link
Copy Markdown
Contributor

The dir field was added to the package stanza in #12614. This commit adds documentation for the field.

Checklist

  • [ ] Tests added, if applicable.
  • [ ] Change log entry added for any user-facing changes.
  • Documentation added for any user-facing changes.

@Alizter

Alizter commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

I guess the main question from the user would be: "Why would I want to do something like this?"

@Alizter

Alizter commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

To answer our hypothetical user:

  • Using (dir) allows the (package) fields of various stanzas to be clearly inferred.
  • Allows for build isolation, i.e. preventing multiple packages built in opam builds using -p.

@punchagan

Copy link
Copy Markdown
Contributor Author

Using (dir) allows the (package) fields of various stanzas to be clearly inferred.

Could you explain what we mean by package fields being clearly inferred?

I tried dropping the field from some stanzas like (executable) and (install) in packages with the (dir) field, but they failed in the same way they would fail without the (dir) field.

@Alizter

Alizter commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Using (dir) allows the (package) fields of various stanzas to be clearly inferred.

Could you explain what we mean by package fields being clearly inferred?

I tried dropping the field from some stanzas like (executable) and (install) in packages with the (dir) field, but they failed in the same way they would fail without the (dir) field.

Sorry I was imprecise. It's rather than stanzas that have optional (package) fields can be inferred into belonging in a particular package. From a non-user perspective, this allows us to filter package more clearly. Here I am talking about (rule), (test) and (cram).

@punchagan
punchagan force-pushed the doc-package-dir-field branch 2 times, most recently from 2472d45 to c04ffb3 Compare October 30, 2026 06:27
@Alizter
Alizter self-requested a review October 30, 2026 09:37
Comment thread doc/reference/dune-project/package.rst Resolved
@punchagan
punchagan force-pushed the doc-package-dir-field branch from c04ffb3 to fd5be9b Compare October 30, 2026 10:42
@punchagan

Copy link
Copy Markdown
Contributor Author

@Alizter could you take another look at this?

Comment thread doc/reference/dune-project/package.rst Outdated
Comment on lines +50 to +55
Stanzas in the directory whose ``(package)`` field is optional, such as
``(rule)``, ``(test)`` and ``(cram)``, belong to the package even when
the field is omitted. Stanzas that need a package, such as ``(install)``,
still require an explicit ``(package)`` field when the project defines
more than one package.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should drop this paragraph and add above that -p filters unrelated stanzas.

@Alizter Alizter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, suggestion on remaining wording.

The dir field was added to the package stanza in ocaml#12614. This commit
adds documentation for the field.

Co-authored-by: Ali Caglayan <[email protected]>
Signed-off-by: Puneeth Chaganti <[email protected]>
@punchagan
punchagan force-pushed the doc-package-dir-field branch from fd5be9b to 35f25b7 Compare November 4, 2026 12:07
@Alizter
Alizter merged commit 52fb4da into ocaml:main Nov 4, 2026
35 of 36 checks passed
@Alizter Alizter added this to the 3.26.0 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants