Odoc plugins for jon.recoil.org
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add link-phase validation to @page-tags

Page_tags now uses register_with_link so it gets access to the
cross-reference environment at link time. For each tag, it calls
Env.lookup_page_by_path with (TCurrentPackage, ["tags"; tag]) to
verify that a corresponding tag page exists under site/tags/.

If the lookup fails, the build crashes with a clear message:

@page-tags: no page found for tag 'foo'. Create
site/tags/foo.mld before using this tag.

This enforces the invariant that tag chip links always resolve —
you can't use a tag until you've created its index page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+18 -1
+18 -1
src/odoc_jons_plugins.ml
··· 529 529 resources = [ Api.Css_inline page_tags_css ]; 530 530 assets = []; 531 531 } 532 + 533 + let link ~tag:_ env content = 534 + let tags = extract_tags content in 535 + List.iter (fun tag -> 536 + let hierarchy : Odoc_model.Paths.Reference.Hierarchy.t = 537 + (`TCurrentPackage, [ "tags"; tag ]) 538 + in 539 + match Api.Env.lookup_page_by_path hierarchy env with 540 + | Ok _ -> () 541 + | Error _ -> 542 + failwith 543 + (Printf.sprintf 544 + "@page-tags: no page found for tag '%s'. Create \ 545 + site/tags/%s.mld before using this tag." 546 + tag tag) 547 + ) tags; 548 + content 532 549 end 533 550 534 551 let () = 535 - Api.Registry.register (module Page_tags) 552 + Api.Registry.register_with_link (module Page_tags) 536 553 537 554 (* Whitespace-separated tokeniser with support for double-quoted 538 555 values. Used by @figure and the image / linked-image inlines. *)