ahrefs / ahrefs/atd

atdml: provide option to write output files in the same folder as the source

Open
#511 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement target:ocaml
Dominant language
OCaml
Stars
352
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Problem: the following dune file works but produces error messages referencing ./types.atd rather than the path from the workspace root or project root:

(rule
  (targets types.ml types.mli)
  (deps types.atd)
  (action
    (run atdml %{deps})
  )
)

A solution is to change directory using (chdir ...) which takes care of adjusting the %{deps} paths:

(rule
  (targets types.ml types.mli)
  (deps types.atd)

  ; Run this preprocessing command from the project root so as to get
  ; usable paths to the source file in error messages.
  (action
    (chdir %{workspace_root} (run atdml %{deps}))
  )
)

but now the problem is that the targets are created at the workspace root (<root>/types.ml) instead of at <root>/path/to/types.ml which is not where dune expects them.

Proposed solution:

  • Add an option to atdml that makes it write the output files in the same folder as the atd source file (I like this better than making it a default, even if backward compatibility wasn't an issue)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating atdml's command-line option handling and output-file generation, then reproduce the issue with the shown dune rule and a nested types.atd source. Done means an option causes generated files to be written beside the source while diagnostics still use project-root paths and dune finds the declared targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system, cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.