Skip to content

Conversation

@davesnx
Copy link
Contributor

@davesnx davesnx commented Sep 19, 2025

This PR extends odoc to support markdown-generate implemented here ocaml/odoc#1341 and supported since odoc.3.1.0

dune build @doc-markdown

Added the odoc version check, similar to other tools.

The implementation itself tried to be very similar to the html generation, except the directory targets on a flat package (it needed to be a system action that groups all markdown-genetaration)

* 'main' of github.com:/ocaml/dune: (946 commits)
  refactor(boot): some helpers for command line flags (ocaml#12375)
  refactor(boot): move file exists check to one place (ocaml#12395)
  Check for parameterised libraries from the compiler config (ocaml#12393)
  Update test/blackbox-tests/test-cases/ocaml-config-ox.t
  Update test/blackbox-tests/test-cases/oxcaml/ocaml-config-ox-true.t
  Add changes
  Turn the %{ocaml-config:ox} test into one file, and add a +ve test case
  Clarify variable vars in ocaml_config.ml
  Expose the ocamlc -config parameter "ox"
  doc: changing heading levels for sub-sections (ocaml#12389)
  chore(deps): bump actions/checkout from 4 to 5 (ocaml#12380)
  refactor(boot): remove pointless [assert false] (ocaml#12378)
  refactor(boot): mangling simplification (ocaml#12377)
  refactor(boot): move ocaml-config bindings (ocaml#12376)
  refactor(boot): simplify blake3 flag handling (ocaml#12379)
  refactor(boot): use [Module_name.t] in ocamldep parsing (ocaml#12373)
  refactor(boot): replace concat + filter_map with concat_map (ocaml#12374)
  chore: move tests to dune-init
  move test to virtual-libraries
  chore: move test to directory-targets
  ...
@Alizter
Copy link
Collaborator

Alizter commented Sep 19, 2025

I think a version check is a good idea. We have such things for ocaml, git, coq and perhaps others.

* 'main' of github.com:/ocaml/dune: (147 commits)
  cram test: test only parameter flags in merlin generation
  fix(oxcaml): import eta-expansion changes from opam-repo (ocaml#12563)
  address review comments
  Mask the path to the stdlib
  fix(oxcaml): generate merlin config for library parameters
  fix(melange + include_qualified): track correct `.cmj` dependencies in emit (ocaml#12531)
  refactor: remove some unused code in [Path] (ocaml#12558)
  dep_rules: don't run (transitive) `ocamldep` on single module buildables (ocaml#12555)
  fix(pkg): ignore project settings for building packages
  test(pkg): reproduce ocaml#12131
  melange: add a test for module cycle checks (ocaml#12554)
  chore: lint check for new changes entries (ocaml#12553)
  feature(cram): allow for conflict detection (ocaml#12538)
  ci: update for ocaml 5.4 release (ocaml#12552)
  chore(script): generate changelog from structure (ocaml#12516)
  Reuse dependencies between project and tools (ocaml#12526)
  Introduce Io.overwrite_file
  test: fix dune install requiring a mandir
  Enable package management for more tests
  Add a `dune tools env` command to add dev tools to PATH (ocaml#12521)
  ...
Comment on lines +1105 to +1130
let setup_lib_markdown_rules sctx lib =
let* markdown_supported = supports_doc_markdown sctx in
if not markdown_supported
then Memo.return ()
else (
let target = Lib lib in
let* odocs = odoc_artefacts sctx target in
let* () =
(* because libraries with a package are handled in the package-level rule with the system shell script for all directory target, we skip packages *)
match Lib_info.package (Lib.Local.info lib) with
| Some _ -> Memo.return ()
| None ->
(* when there's no package, we still need have rules for each odoc file *)
Memo.parallel_iter odocs ~f:(fun odoc -> setup_generate_markdown sctx odoc)
in
Memo.With_implicit_output.exec setup_lib_markdown_rules_def (sctx, lib))
;;

let markdown_shell_command odoc_path all_odocs ~markdown_root =
List.map all_odocs ~f:(fun odoc ->
let odocl_rel =
Path.reach (Path.build odoc.odocl_file) ~from:(Path.build markdown_root)
in
Printf.sprintf "%s markdown-generate -o . %s" odoc_path odocl_rel)
|> String.concat ~sep:" && "
;;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is technically working, but I don't think is a proper solution.

I pushed a new PR #12581 assuming that odoc supports multiple inputs as implemented here ocaml/odoc#1388

It's a bit unforunate since we will need to wait for this PR to merge (and increase the version check)

@rgrinberg
Copy link
Member

Has been subsumed by #12581

@rgrinberg rgrinberg closed this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants