package odoc
OCaml Documentation Generator
Install
Dune Dependency
Authors
Maintainers
Sources
odoc-3.0.0.tbz
sha256=ce84fa7e0cc5f3e8a54e6adeb10826152798b602057b9e46c5ae7e5d5206812b
sha512=9febd413450ca2e3824c9ef7e1c9ae8d8094aa72ed71327a69d8d6b42f6f197b3f3f40d674de0d11fa1242ee0df95c693b5d74467d530704e1339f3a523452f6
doc/src/odoc.xref2/component.ml.html
Source file component.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731
module Maps = Odoc_model.Paths.Identifier.Maps module ModuleMap = Map.Make (struct type t = Ident.module_ let compare a b = Ident.compare (a :> Ident.any) (b :> Ident.any) end) module TypeMap = Map.Make (struct type t = Ident.type_ let compare a b = Ident.compare (a :> Ident.any) (b :> Ident.any) end) module ModuleTypeMap = Map.Make (struct type t = Ident.module_type let compare a b = Ident.compare (a :> Ident.any) (b :> Ident.any) end) module ValueMap = Map.Make (struct type t = Ident.value let compare a b = Ident.compare (a :> Ident.any) (b :> Ident.any) end) module IdentMap = Map.Make (struct type t = Ident.any let compare = Ident.compare end) module Delayed = struct let eager = ref false type 'a t = { mutable v : 'a option; mutable get : (unit -> 'a) option } let get : 'a t -> 'a = fun x -> match (x.v, x.get) with | Some x, _ -> x | None, Some get -> let v = get () in x.v <- Some v; x.get <- None; v | _, _ -> failwith "bad delayed" let put : (unit -> 'a) -> 'a t = fun f -> if !eager then { v = Some (f ()); get = None } else { v = None; get = Some f } let put_val : 'a -> 'a t = fun v -> { v = Some v; get = None } end module Opt = struct let map f = function Some x -> Some (f x) | None -> None end module rec Module : sig type decl = | Alias of Cpath.module_ * ModuleType.simple_expansion option | ModuleType of ModuleType.expr type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; type_ : decl; canonical : Odoc_model.Paths.Path.Module.t option; hidden : bool; } end = Module and ModuleSubstitution : sig type t = { doc : CComment.docs; manifest : Cpath.module_ } end = ModuleSubstitution and ModuleTypeSubstitution : sig type t = { doc : CComment.docs; manifest : ModuleType.expr } end = ModuleTypeSubstitution and TypeExpr : sig module Polymorphic_variant : sig type kind = Odoc_model.Lang.TypeExpr.Polymorphic_variant.kind module Constructor : sig type t = { name : string; constant : bool; arguments : TypeExpr.t list; doc : CComment.docs; } end type element = Type of TypeExpr.t | Constructor of Constructor.t type t = { kind : kind; elements : element list } end module Object : sig type method_ = { name : string; type_ : TypeExpr.t } type field = Method of method_ | Inherit of TypeExpr.t type t = { fields : field list; open_ : bool } end module Package : sig type substitution = Cfrag.type_ * TypeExpr.t type t = { path : Cpath.module_type; substitutions : substitution list } end type label = Odoc_model.Lang.TypeExpr.label type t = | Var of string | Any | Alias of t * string | Arrow of label option * t * t | Tuple of t list | Constr of Cpath.type_ * t list | Polymorphic_variant of TypeExpr.Polymorphic_variant.t | Object of TypeExpr.Object.t | Class of Cpath.class_type * t list | Poly of string list * t | Package of TypeExpr.Package.t end = TypeExpr and Extension : sig module Constructor : sig type t = { name : string; source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; args : TypeDecl.Constructor.argument; res : TypeExpr.t option; } end type t = { type_path : Cpath.type_; doc : CComment.docs; type_params : TypeDecl.param list; private_ : bool; constructors : Constructor.t list; } end = Extension and Exception : sig type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; args : TypeDecl.Constructor.argument; res : TypeExpr.t option; } end = Exception and FunctorParameter : sig type parameter = { id : Ident.module_; expr : ModuleType.expr } type t = Named of parameter | Unit end = FunctorParameter and ModuleType : sig type substitution = | ModuleEq of Cfrag.module_ * Module.decl | ModuleSubst of Cfrag.module_ * Cpath.module_ | ModuleTypeEq of Cfrag.module_type * ModuleType.expr | ModuleTypeSubst of Cfrag.module_type * ModuleType.expr | TypeEq of Cfrag.type_ * TypeDecl.Equation.t | TypeSubst of Cfrag.type_ * TypeDecl.Equation.t type type_of_desc = | ModPath of Cpath.module_ | StructInclude of Cpath.module_ type simple_expansion = | Signature of Signature.t | Functor of FunctorParameter.t * simple_expansion type typeof_t = { t_desc : type_of_desc; t_original_path : Cpath.module_; t_expansion : simple_expansion option; } module U : sig type expr = | Path of Cpath.module_type | Signature of Signature.t | With of substitution list * expr | TypeOf of type_of_desc * Cpath.module_ end type path_t = { p_expansion : simple_expansion option; p_path : Cpath.module_type; } type with_t = { w_substitutions : substitution list; w_expansion : simple_expansion option; w_expr : U.expr; } type expr = | Path of path_t | Signature of Signature.t | With of with_t | Functor of FunctorParameter.t * expr | TypeOf of typeof_t type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; canonical : Odoc_model.Paths.Path.ModuleType.t option; expr : expr option; } end = ModuleType and TypeDecl : sig module Field : sig type t = { name : string; doc : CComment.docs; mutable_ : bool; type_ : TypeExpr.t; } end module Constructor : sig type argument = Tuple of TypeExpr.t list | Record of Field.t list type t = { name : string; doc : CComment.docs; args : argument; res : TypeExpr.t option; } end module Representation : sig type t = | Variant of Constructor.t list | Record of Field.t list | Extensible end type param = Odoc_model.Lang.TypeDecl.param module Equation : sig type t = { params : param list; private_ : bool; manifest : TypeExpr.t option; constraints : (TypeExpr.t * TypeExpr.t) list; } end type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; canonical : Odoc_model.Paths.Path.Type.t option; equation : Equation.t; representation : Representation.t option; } end = TypeDecl and Value : sig type value = Odoc_model.Lang.Value.value type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; type_ : TypeExpr.t; value : value; } end = Value and Signature : sig type recursive = Odoc_model.Lang.Signature.recursive type item = | Module of Ident.module_ * recursive * Module.t Delayed.t | ModuleSubstitution of Ident.module_ * ModuleSubstitution.t | ModuleType of Ident.module_type * ModuleType.t Delayed.t | ModuleTypeSubstitution of Ident.module_type * ModuleTypeSubstitution.t | Type of Ident.type_ * recursive * TypeDecl.t Delayed.t | TypeSubstitution of Ident.type_ * TypeDecl.t | Exception of Ident.exception_ * Exception.t | TypExt of Extension.t | Value of Ident.value * Value.t Delayed.t | Class of Ident.type_ * recursive * Class.t | ClassType of Ident.type_ * recursive * ClassType.t | Include of Include.t | Open of Open.t | Comment of CComment.docs_or_stop (* When doing destructive substitution we keep track of the items that have been removed, and the path they've been substituted with *) type removed_item = | RModule of Odoc_model.Names.ModuleName.t * Cpath.module_ | RType of Odoc_model.Names.TypeName.t * TypeExpr.t * TypeDecl.Equation.t (** [RType (_, texpr, eq)], [eq.manifest = Some texpr] *) | RModuleType of Odoc_model.Names.ModuleTypeName.t * ModuleType.expr type t = { items : item list; compiled : bool; removed : removed_item list; doc : CComment.docs; } end = Signature and Open : sig type t = { expansion : Signature.t; doc : CComment.docs } end = Open and Include : sig type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr type t = { parent : Odoc_model.Paths.Identifier.Signature.t; strengthened : Cpath.module_ option; doc : CComment.docs; status : [ `Default | `Inline | `Closed | `Open ]; shadowed : Odoc_model.Lang.Include.shadowed; expansion_ : Signature.t; decl : decl; loc : Odoc_model.Location_.span; } end = Include and Class : sig type decl = | ClassType of ClassType.expr | Arrow of TypeExpr.label option * TypeExpr.t * decl type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; virtual_ : bool; params : TypeDecl.param list; type_ : decl; expansion : ClassSignature.t option; } end = Class and ClassType : sig type expr = | Constr of Cpath.class_type * TypeExpr.t list | Signature of ClassSignature.t type t = { source_loc : Odoc_model.Paths.Identifier.SourceLocation.t option; doc : CComment.docs; virtual_ : bool; params : TypeDecl.param list; expr : expr; expansion : ClassSignature.t option; } end = ClassType and ClassSignature : sig module Constraint : sig type t = { left : TypeExpr.t; right : TypeExpr.t; doc : CComment.docs } end module Inherit : sig type t = { expr : ClassType.expr; doc : CComment.docs } end type item = | Method of Ident.method_ * Method.t | InstanceVariable of Ident.instance_variable * InstanceVariable.t | Constraint of Constraint.t | Inherit of Inherit.t | Comment of CComment.docs_or_stop type t = { self : TypeExpr.t option; items : item list; doc : CComment.docs } end = ClassSignature and Method : sig type t = { doc : CComment.docs; private_ : bool; virtual_ : bool; type_ : TypeExpr.t; } end = Method and InstanceVariable : sig type t = { doc : CComment.docs; mutable_ : bool; virtual_ : bool; type_ : TypeExpr.t; } end = InstanceVariable and Substitution : sig type subst_module = [ `Prefixed of Cpath.module_ * Cpath.Resolved.module_ | `Substituted | `Renamed of Ident.module_ ] type subst_module_type = [ `Prefixed of Cpath.module_type * Cpath.Resolved.module_type | `Renamed of Ident.module_type ] type subst_type = [ `Prefixed of Cpath.type_ * Cpath.Resolved.type_ | `Renamed of Ident.type_ ] type subst_class_type = [ `Prefixed of Cpath.class_type * Cpath.Resolved.class_type | `Renamed of Ident.type_ ] type t = { module_ : subst_module ModuleMap.t; module_type : subst_module_type ModuleTypeMap.t; type_ : subst_type TypeMap.t; class_type : subst_class_type TypeMap.t; type_replacement : (TypeExpr.t * TypeDecl.Equation.t) TypeMap.t; module_type_replacement : ModuleType.expr ModuleTypeMap.t; path_invalidating_modules : Ident.module_ list; unresolve_opaque_paths : bool; } end = Substitution and CComment : sig type block_element = [ Odoc_model.Comment.nestable_block_element | `Heading of Label.t | `Tag of Odoc_model.Comment.tag | `Media of Odoc_model.Comment.media_href * Odoc_model.Comment.media * string ] type docs = { elements : block_element Odoc_model.Comment.with_location list; warnings_tag : string option; } type docs_or_stop = [ `Docs of docs | `Stop ] end = CComment and Label : sig type t = { attrs : Odoc_model.Comment.heading_attrs; label : Ident.label; text : Odoc_model.Comment.paragraph; location : Odoc_model.Location_.span; } end = Label module Element = struct open Odoc_model.Paths type module_ = [ `Module of Identifier.Path.Module.t * Module.t Delayed.t ] type module_type = [ `ModuleType of Identifier.ModuleType.t * ModuleType.t ] type datatype = [ `Type of Identifier.Type.t * TypeDecl.t ] type value = [ `Value of Identifier.Value.t * Value.t ] type label = [ `Label of Identifier.Label.t * Label.t ] type class_ = [ `Class of Identifier.Class.t * Class.t ] type class_type = [ `ClassType of Identifier.ClassType.t * ClassType.t ] type type_ = [ datatype | class_ | class_type ] type signature = [ module_ | module_type ] type constructor = [ `Constructor of Identifier.Constructor.t * TypeDecl.Constructor.t ] type exception_ = [ `Exception of Identifier.Exception.t * Exception.t ] type extension = [ `Extension of Identifier.Extension.t * Extension.Constructor.t * Extension.t ] type extension_decl = [ `ExtensionDecl of Identifier.Extension.t * Extension.Constructor.t ] type field = [ `Field of Identifier.Field.t * TypeDecl.Field.t ] (* No component for pages yet *) type page = [ `Page of Identifier.Page.t * Odoc_model.Lang.Page.t ] type label_parent = [ signature | type_ | page ] type fragment_type_parent = [ signature | datatype ] type any = [ signature | value | datatype | label | class_ | class_type | constructor | exception_ | extension | extension_decl | field | page ] let identifier : [< any ] -> Odoc_model.Paths.Identifier.t = let open Odoc_model.Paths.Identifier in function | `Module (id, _) -> (id :> t) | `ModuleType (id, _) -> (id :> t) | `Type (id, _) -> (id :> t) | `ClassType (id, _) -> (id :> t) | `Class (id, _) -> (id :> t) | `Value (id, _) -> (id :> t) | `Label (id, _) -> (id :> t) | `Constructor (id, _) -> (id :> t) | `Exception (id, _) -> (id :> t) | `Field (id, _) -> (id :> t) | `Extension (id, _, _) -> (id :> t) | `ExtensionDecl (id, _) -> (id :> t) | `Page (id, _) -> (id :> t) end module Fmt = struct type config = { short_paths : bool; show_canonical : bool; show_removed : bool; show_expansions : bool; show_include_expansions : bool; } let default = { short_paths = false; show_canonical = true; show_removed = true; show_expansions = true; show_include_expansions = true; } type id = Odoc_model.Paths.Identifier.t type path = Odoc_model.Paths.Path.t type rpath = Odoc_model.Paths.Path.Resolved.t open Odoc_model.Names open Odoc_model.Paths let fpf = Format.fprintf let fpp_opt (c : config) fmt pp_a ppf = function | Some t -> fpf ppf fmt (pp_a c) t | None -> () let fpp_list fmt_sep fmt_outer pp_a ppf t = let pp_sep ppf () = fpf ppf fmt_sep in match t with | [] -> () | t -> fpf ppf fmt_outer (Format.pp_print_list ~pp_sep pp_a) t (* Three helper functions to help with paths. Generally paths have constructors of the form [`Hidden(p1)] or [`Alias(p1,p2)]. When printing these paths, if we're printing a short path we often want to just ignore the constructor and print one of the inner paths, [p1] or [p2]. These functions do that. If [short_paths] is set in the config, we skip to one of the inner paths - in [wrap] there's no choice, but in [wrap2] we pick [p1] and in [wrap2r] we pick [p2]. If [short_paths] is not set, we print a string representing the constructor, and one or both paths with brackets. *) let wrap : type a. config -> string -> (config -> Format.formatter -> a -> unit) -> Format.formatter -> a -> unit = fun c txt fn ppf x -> if c.short_paths then Format.fprintf ppf "%a" (fn c) x else Format.fprintf ppf "%s(%a)" txt (fn c) x let wrap2 : type a b. config -> string -> (config -> Format.formatter -> a -> unit) -> (config -> Format.formatter -> b -> unit) -> Format.formatter -> a -> b -> unit = fun c txt fn1 fn2 ppf x y -> if c.short_paths then Format.fprintf ppf "%a" (fn1 c) x else Format.fprintf ppf "%s(%a,%a)" txt (fn1 c) x (fn2 c) y let wrap2r : type a b. config -> string -> (config -> Format.formatter -> a -> unit) -> (config -> Format.formatter -> b -> unit) -> Format.formatter -> a -> b -> unit = fun c txt fn1 fn2 ppf x y -> if c.short_paths then Format.fprintf ppf "%a" (fn2 c) y else Format.fprintf ppf "%s(%a,%a)" txt (fn1 c) x (fn2 c) y let str : config -> Format.formatter -> string -> unit = fun _ ppf s -> Format.fprintf ppf "%s" s let bool : config -> Format.formatter -> bool -> unit = fun _ ppf b -> Format.fprintf ppf "%b" b let ident_fmt : config -> Format.formatter -> [< Ident.any ] -> unit = fun c ppf i -> if c.short_paths then Ident.short_fmt ppf i else Ident.fmt ppf i let rec model_identifier c ppf (p : id) = match p.iv with | `Root (_, unit_name) -> wrap c "root" (fun _ -> ModuleName.fmt) ppf unit_name | `Module (parent, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (parent :> id) (ModuleName.to_string name) | `ModuleType (parent, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (parent :> id) (ModuleTypeName.to_string name) | `Type (parent, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (parent :> id) (TypeName.to_string name) | `Parameter (parent, name) -> Format.fprintf ppf "(param %a %s)" (model_identifier c) (parent :> id) (ModuleName.to_string name) | `Result parent -> if c.short_paths then model_identifier c ppf (parent :> id) else Format.fprintf ppf "%a.result" (model_identifier c) (parent :> id) | `Constructor (ty, x) -> Format.fprintf ppf "%a.%s" (model_identifier c) (ty :> id) (ConstructorName.to_string x) | `Value (parent, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (parent :> id) (ValueName.to_string name) | `Class (sg, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (sg :> id) (TypeName.to_string name) | `ClassType (sg, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (sg :> id) (TypeName.to_string name) | `InstanceVariable (sg, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (sg :> id) (InstanceVariableName.to_string name) | `Method (sg, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (sg :> id) (MethodName.to_string name) | `Label (parent, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (parent :> id) (LabelName.to_string name) | `Field (ty, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (ty :> id) (FieldName.to_string name) | `Exception (p, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (p :> id) (ExceptionName.to_string name) | `Extension (p, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (p :> id) (ExtensionName.to_string name) | `ExtensionDecl (p, _, name) -> Format.fprintf ppf "%a.%s" (model_identifier c) (p :> id) (ExtensionName.to_string name) | `Page (_, name) | `LeafPage (_, name) -> Format.fprintf ppf "%s" (PageName.to_string name) | `SourcePage (p, name) -> Format.fprintf ppf "%a/%s" (model_identifier c) (p :> id) name | `SourceLocation (p, def) -> Format.fprintf ppf "%a#%s" (model_identifier c) (p :> id) (DefName.to_string def) | `SourceLocationInternal (p, def) -> Format.fprintf ppf "%a#%s" (model_identifier c) (p :> id) (LocalName.to_string def) | `SourceLocationMod p -> Format.fprintf ppf "%a#" (model_identifier c) (p :> id) | `AssetFile (p, name) -> Format.fprintf ppf "%a/%s" (model_identifier c) (p :> id) (AssetName.to_string name) let rec signature : config -> Format.formatter -> Signature.t -> unit = fun c ppf sg -> let open Signature in let ident_fmt = if c.short_paths then Ident.short_fmt else Ident.fmt in let sig_item ppf = function | Module (id, _, m) -> Format.fprintf ppf "@[<hov 2>module %a %a@]" ident_fmt id (module_ c) (Delayed.get m) | ModuleSubstitution (id, m) -> Format.fprintf ppf "@[<v 2>module %a := %a@]" ident_fmt id (module_path c) m.ModuleSubstitution.manifest | ModuleType (id, mt) -> Format.fprintf ppf "@[<hov 2>module type %a %a@]" ident_fmt id (module_type c) (Delayed.get mt) | ModuleTypeSubstitution (id, mts) -> Format.fprintf ppf "@[<v 2>module type %a := %a@]" ident_fmt id (module_type_expr c) mts.ModuleTypeSubstitution.manifest | Type (id, _, t) -> Format.fprintf ppf "@[<v 2>type %a%a@]" ident_fmt id (type_decl c) (Delayed.get t) | TypeSubstitution (id, t) -> Format.fprintf ppf "@[<v 2>type %a :=%a@]" ident_fmt id (type_decl c) t | Exception (id, e) -> Format.fprintf ppf "@[<v 2>exception %a %a@]" ident_fmt id (exception_ c) e | TypExt e -> Format.fprintf ppf "@[<v 2>type_extension %a@]" (extension c) e | Value (id, v) -> Format.fprintf ppf "@[<v 2>val %a %a@]" ident_fmt id (value c) (Delayed.get v) | Class (id, _, cls) -> Format.fprintf ppf "@[<v 2>class %a %a@]" ident_fmt id (class_ c) cls | ClassType (id, _, cty) -> Format.fprintf ppf "@[<v 2>class type %a %a@]" ident_fmt id (class_type c) cty | Include i -> Format.fprintf ppf "@[<hov 2>include %a@]" (include_ c) i | Open o -> Format.fprintf ppf "open [ %a ]" (signature c) o.expansion | Comment _c -> () in let rec inner ppf = function | [ x ] -> sig_item ppf x | x :: xs -> Format.fprintf ppf "%a@ %a" sig_item x inner xs | [] -> () in let removed_fmt ppf removed = match (c.show_removed, removed) with | false, _ | _, [] -> () | true, items -> Format.fprintf ppf "@ (removed=%a)" (removed_item_list c) items in Format.fprintf ppf "%a%a" inner sg.items removed_fmt sg.removed and option : type a. config -> (config -> Format.formatter -> a -> unit) -> Format.formatter -> a option -> unit = fun c pp ppf x -> match x with | Some x -> Format.fprintf ppf "Some(%a)" (pp c) x | None -> Format.fprintf ppf "None" and class_signature c ppf sg = let open ClassSignature in Format.fprintf ppf "@[<v>self=%a@," (option c type_expr) sg.self; List.iter (function | Method (id, m) -> Format.fprintf ppf "@[<v 2>method %a : %a@]@," Ident.fmt id (method_ c) m | InstanceVariable (id, i) -> Format.fprintf ppf "@[<v 2>instance variable %a : %a@]@," Ident.fmt id (instance_variable c) i | Constraint cst -> Format.fprintf ppf "@[<v 2>constraint %a = %a@]@," (type_expr c) cst.Constraint.left (type_expr c) cst.right | Inherit i -> Format.fprintf ppf "@[<v 2>inherit %a" (class_type_expr c) i.Inherit.expr | Comment _ -> ()) sg.items and method_ c ppf m = let open Method in Format.fprintf ppf "%s%s%a" (if m.private_ then "private " else "") (if m.virtual_ then "virtual " else "") (type_expr c) m.type_ and instance_variable c ppf i = let open InstanceVariable in Format.fprintf ppf "%s%s%a" (if i.mutable_ then "mutable " else "") (if i.virtual_ then "virtual " else "") (type_expr c) i.type_ and list c pp ppf ls = match ls with | x :: y :: rest -> Format.fprintf ppf "%a, %a" (pp c) x (list c pp) (y :: rest) | [ x ] -> Format.fprintf ppf "%a" (pp c) x | [] -> () and class_type_expr c ppf cty = let open ClassType in match cty with | Constr (p, ts) -> Format.fprintf ppf "constr(%a,%a)" (class_type_path c) p (list c type_expr) ts | Signature sg -> Format.fprintf ppf "(%a)" (class_signature c) sg and removed_item c ppf r = let open Signature in match r with | RModule (id, path) -> Format.fprintf ppf "module %a (%a)" ModuleName.fmt id (module_path c) path | RType (id, texpr, eq) -> Format.fprintf ppf "type %a %a = (%a)" type_params eq.params TypeName.fmt id (type_expr c) texpr | RModuleType (id, mty) -> Format.fprintf ppf "module type %a = %a" ModuleTypeName.fmt id (module_type_expr c) mty and removed_item_list c ppf r = match r with | [] -> () | [ x ] -> Format.fprintf ppf "%a" (removed_item c) x | x :: ys -> Format.fprintf ppf "%a;%a" (removed_item c) x (removed_item_list c) ys and class_decl c ppf cls = let open Class in match cls with | ClassType cty -> Format.fprintf ppf "%a" (class_type_expr c) cty | Arrow (lbl, ty, decl) -> Format.fprintf ppf "%a%a -> %a" type_expr_label lbl (type_expr c) ty (class_decl c) decl and class_ c ppf cls = Format.fprintf ppf "%a" (class_decl c) cls.type_ and class_type _c ppf _ = Format.fprintf ppf "<todo>" and include_ c ppf i = Format.fprintf ppf "%a@ %a" (include_decl c) i.decl (simple_expansion c true) (ModuleType.Signature i.expansion_ : ModuleType.simple_expansion) and include_decl c ppf = let open Include in function | Alias p -> Format.fprintf ppf "%a" (module_path c) p | ModuleType mt -> Format.fprintf ppf "%a" (u_module_type_expr c) mt and value c ppf v = let open Value in Format.fprintf ppf ": %a" (type_expr c) v.type_ and module_decl c ppf d = let open Module in match d with | Alias (p, Some e) -> Format.fprintf ppf "=@ %a@ %a" (module_path c) p (simple_expansion c false) e | Alias (p, None) -> Format.fprintf ppf "=@ %a" (module_path c) p | ModuleType mt -> Format.fprintf ppf ": %a%a" (module_type_expr c) mt (module_type_expansion c) mt and module_ c ppf m = let fmt_canonical ppf popt = if c.show_canonical then Format.fprintf ppf "@ (canonical=%a)" (option c model_path) popt else () in Format.fprintf ppf "%a%a" (module_decl c) m.type_ fmt_canonical (m.canonical :> path option) and simple_expansion c is_include ppf (m : ModuleType.simple_expansion) = if c.show_expansions || (is_include && c.show_include_expansions) then match m with | ModuleType.Signature sg -> Format.fprintf ppf "@[<hv 2>(sig :@ %a@;<1 -1>end@])" (signature c) sg | Functor (arg, sg) -> Format.fprintf ppf "(functor: (%a) -> %a)" (functor_parameter c) arg (simple_expansion c is_include) sg else () and module_type c ppf mt = match mt.expr with | Some x -> Format.fprintf ppf "= %a%a" (module_type_expr c) x (module_type_expansion c) x | None -> () and module_type_type_of_desc c ppf t = match t with | ModuleType.ModPath p -> Format.fprintf ppf "module type of %a" (module_path c) p | StructInclude p -> Format.fprintf ppf "module type of struct include %a end" (module_path c) p and u_module_type_expr c ppf mt = let open ModuleType.U in match mt with | Path p -> module_type_path c ppf p | Signature sg -> Format.fprintf ppf "sig@,@[<v 2>%a@]end" (signature c) sg | With (subs, e) -> Format.fprintf ppf "%a with [%a]" (u_module_type_expr c) e (substitution_list c) subs | TypeOf (t_desc, _) -> module_type_type_of_desc c ppf t_desc and module_type_expr c ppf mt = let open ModuleType in match mt with | Path { p_path; _ } -> module_type_path c ppf p_path | Signature sg -> Format.fprintf ppf "@,@[<hv 2>sig@ %a@;<1 -2>end@]" (signature c) sg | With { w_substitutions = subs; w_expr; _ } -> Format.fprintf ppf "%a with @[<hov 2>%a@]" (u_module_type_expr c) w_expr (substitution_list c) subs | Functor (arg, res) -> Format.fprintf ppf "(%a) -> %a" (functor_parameter c) arg (module_type_expr c) res | TypeOf { t_desc = ModPath p; _ } -> Format.fprintf ppf "module type of %a" (module_path c) p | TypeOf { t_desc = StructInclude p; _ } -> Format.fprintf ppf "module type of struct include %a end" (module_path c) p and module_type_expansion c ppf mt = let open ModuleType in match mt with | Signature _ -> () | Path { p_expansion = Some e; _ } | With { w_expansion = Some e; _ } | TypeOf { t_expansion = Some e; _ } -> Format.fprintf ppf "@ %a" (simple_expansion c false) e | _ -> () and functor_parameter c ppf x = let open FunctorParameter in match x with | Unit -> () | Named x -> Format.fprintf ppf "%a" (functor_parameter_parameter c) x and functor_parameter_parameter c ppf x = Format.fprintf ppf "%a : %a" Ident.fmt x.FunctorParameter.id (module_type_expr c) x.FunctorParameter.expr and type_decl c ppf t = let open TypeDecl in match t.representation with | Some repr -> Format.fprintf ppf "%a = %a" (fpp_opt c " : %a" type_expr) t.equation.Equation.manifest (type_decl_repr c) repr | None -> (fpp_opt c " = %a" type_expr) ppf t.equation.Equation.manifest and type_decl_repr c ppf = let open TypeDecl.Representation in function | Variant cs -> fpp_list " | " "%a" (type_decl_constructor c) ppf cs | Record fs -> type_decl_fields c ppf fs | Extensible -> Format.fprintf ppf ".." and type_decl_constructor c ppf t = let open TypeDecl.Constructor in match t.res with | Some res -> fpf ppf "%s : %a -> %a" t.name (type_decl_constructor_arg c) t.args (type_expr c) res | None -> fpf ppf "%s of %a" t.name (type_decl_constructor_arg c) t.args and type_decl_constructor_arg c ppf = let open TypeDecl.Constructor in function | Tuple ts -> type_tuple c ppf ts | Record fs -> type_decl_fields c ppf fs and type_decl_field c ppf t = let open TypeDecl.Field in let mutable_ = if t.mutable_ then "mutable " else "" in fpf ppf "%s%s : %a" mutable_ t.name (type_expr c) t.type_ and type_decl_fields c ppf fs = fpp_list "; " "{ %a }" (type_decl_field c) ppf fs and type_tuple c ppf ts = fpp_list " * " "%a" (type_expr c) ppf ts and type_param ppf t = let desc = match t.Odoc_model.Lang.TypeDecl.desc with Any -> "_" | Var n -> n and variance = match t.variance with Some Pos -> "+" | Some Neg -> "-" | None -> "" and injectivity = if t.injectivity then "!" else "" in Format.fprintf ppf "%s%s%s" variance injectivity desc and type_params ppf ts = let pp_sep ppf () = Format.fprintf ppf ", " in Format.fprintf ppf "(%a)" (Format.pp_print_list ~pp_sep type_param) ts and type_equation c ppf t = match t.TypeDecl.Equation.manifest with | None -> () | Some m -> Format.fprintf ppf " = %a" (type_expr c) m and exception_ _c _ppf _e = () and extension c ppf e = Format.fprintf ppf "%a" (type_path c) e.Extension.type_path and substitution c ppf t = let open ModuleType in match t with | ModuleEq (frag, decl) -> Format.fprintf ppf "%a %a" (module_fragment c) frag (module_decl c) decl | ModuleSubst (frag, mpath) -> Format.fprintf ppf "%a := %a" (module_fragment c) frag (module_path c) mpath | ModuleTypeEq (frag, mty) -> Format.fprintf ppf "%a = %a" (module_type_fragment c) frag (module_type_expr c) mty | ModuleTypeSubst (frag, mty) -> Format.fprintf ppf "%a := %a" (module_type_fragment c) frag (module_type_expr c) mty | TypeEq (frag, decl) -> Format.fprintf ppf "%a%a" (type_fragment c) frag (type_equation c) decl | TypeSubst (frag, decl) -> Format.fprintf ppf "%a%a" (type_fragment c) frag (type_equation c) decl and substitution_list c ppf l = match l with | [ sub ] -> Format.fprintf ppf "%a" (substitution c) sub | sub :: subs -> Format.fprintf ppf "%a; %a" (substitution c) sub (substitution_list c) subs | [] -> () and type_expr_label ppf l = match l with | Some (Odoc_model.Lang.TypeExpr.Label l) -> Format.fprintf ppf "%s:" l | Some (RawOptional o) -> Format.fprintf ppf "?(%s):" o | Some (Optional o) -> Format.fprintf ppf "?%s:" o | None -> () and type_expr_list c ppf l = match l with | [ t ] -> Format.fprintf ppf "%a" (type_expr c) t | t :: ts -> Format.fprintf ppf "%a * %a" (type_expr c) t (type_expr_list c) ts | [] -> () and type_object _c ppf _o = Format.fprintf ppf "(object)" and type_class c ppf (x, ys) = Format.fprintf ppf "(class %a %a)" (class_type_path c) x (type_expr_list c) ys and type_package _c ppf _p = Format.fprintf ppf "(package)" and type_expr_polymorphic_variant c ppf p = let open TypeExpr.Polymorphic_variant in let pp_element ppf = function | Type t -> type_expr c ppf t | Constructor cstr -> fpf ppf "`%s%a" cstr.Constructor.name (fpp_list " * " " of %a" (type_expr c)) cstr.arguments in let pp_elements = fpp_list " | " "%a" pp_element in match p.kind with | Fixed -> fpf ppf "[ %a ]" pp_elements p.elements | Closed xs -> fpf ppf "[ %a > %a ]" pp_elements p.elements (fpp_list " " "%a" Format.pp_print_string) xs | Open -> fpf ppf "[> %a ]" pp_elements p.elements and type_expr c ppf e = let open TypeExpr in match e with | Var x -> Format.fprintf ppf "%s" x | Any -> Format.fprintf ppf "_" | Alias (x, y) -> Format.fprintf ppf "(alias %a %s)" (type_expr c) x y | Arrow (l, t1, t2) -> Format.fprintf ppf "%a(%a) -> %a" type_expr_label l (type_expr c) t1 (type_expr c) t2 | Tuple ts -> Format.fprintf ppf "(%a)" (type_expr_list c) ts | Constr (p, args) -> ( match args with | [] -> Format.fprintf ppf "%a" (type_path c) p | _ -> Format.fprintf ppf "[%a] %a" (type_expr_list c) args (type_path c) p ) | Polymorphic_variant poly -> Format.fprintf ppf "(poly_var %a)" (type_expr_polymorphic_variant c) poly | Object x -> type_object c ppf x | Class (x, y) -> type_class c ppf (x, y) | Poly (_ss, _t) -> Format.fprintf ppf "(poly)" | Package x -> type_package c ppf x and resolved_module_path : config -> Format.formatter -> Cpath.Resolved.module_ -> unit = fun c ppf p -> match p with | `Local ident -> ident_fmt c ppf ident | `Apply (p1, p2) -> Format.fprintf ppf "%a(%a)" (resolved_module_path c) p1 (resolved_module_path c) p2 | `Gpath p -> Format.fprintf ppf "%a" (model_resolved_path c) (p :> rpath) | `Substituted p -> wrap c "substituted" resolved_module_path ppf p | `Module (p, m) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (ModuleName.to_string m) | `Alias (p1, p2, _) -> wrap2r c "alias" resolved_module_path module_path ppf p1 p2 | `Subst (p1, p2) -> wrap2r c "subst" resolved_module_type_path resolved_module_path ppf p1 p2 | `Hidden p1 -> wrap c "hidden" resolved_module_path ppf p1 | `Canonical (p1, p2) -> wrap2 c "canonical" resolved_module_path model_path ppf p1 (p2 :> path) | `OpaqueModule m -> wrap c "opaquemodule" resolved_module_path ppf m and module_path : config -> Format.formatter -> Cpath.module_ -> unit = fun c ppf p -> match p with | `Resolved p -> wrap c "resolved" resolved_module_path ppf p | `Dot (p, n) -> Format.fprintf ppf "%a.%a" (module_path c) p ModuleName.fmt n | `Module (p, n) -> Format.fprintf ppf "%a.%a" (resolved_parent_path c) p ModuleName.fmt n | `Apply (p1, p2) -> Format.fprintf ppf "%a(%a)" (module_path c) p1 (module_path c) p2 | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b | `Local (id, b) -> wrap2 c "local" ident_fmt bool ppf id b | `Substituted p -> wrap c "substituted" module_path ppf p | `Forward s -> wrap c "forward" str ppf s | `Root r -> wrap c "unresolvedroot" str ppf (ModuleName.to_string r) and resolved_module_type_path : config -> Format.formatter -> Cpath.Resolved.module_type -> unit = fun c ppf p -> match p with | `Local id -> ident_fmt c ppf id | `Gpath p -> model_resolved_path c ppf (p :> rpath) | `Substituted x -> wrap c "substituted" resolved_module_type_path ppf x | `ModuleType (p, m) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (ModuleTypeName.to_string m) | `CanonicalModuleType (m1, m2) -> wrap2 c "canonicalt" resolved_module_type_path model_path ppf m1 (m2 :> path) | `OpaqueModuleType m -> wrap c "opaquemoduletype" resolved_module_type_path ppf m | `AliasModuleType (mt1, mt2) -> wrap2 c "aliasmoduletype" resolved_module_type_path resolved_module_type_path ppf mt1 mt2 | `SubstT (mt1, mt2) -> wrap2 c "substt" resolved_module_type_path resolved_module_type_path ppf mt1 mt2 and module_type_path : config -> Format.formatter -> Cpath.module_type -> unit = fun c ppf m -> match m with | `Resolved p -> wrap c "r" resolved_module_type_path ppf p | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b | `Local (id, b) -> wrap2 c "local" ident_fmt bool ppf id b | `Substituted s -> wrap c "substituted" module_type_path ppf s | `DotMT (m, s) -> Format.fprintf ppf "%a.%a" (module_path c) m ModuleTypeName.fmt s | `ModuleType (m, n) -> Format.fprintf ppf "%a.%a" (resolved_parent_path c) m ModuleTypeName.fmt n and resolved_type_path : config -> Format.formatter -> Cpath.Resolved.type_ -> unit = fun c ppf p -> match p with | `CoreType n -> Format.fprintf ppf "%s" (TypeName.to_string n) | `Local id -> ident_fmt c ppf id | `Gpath p -> model_resolved_path c ppf (p :> rpath) | `Substituted x -> wrap c "substituted" resolved_type_path ppf x | `CanonicalType (t1, t2) -> wrap2 c "canonicaltype" resolved_type_path model_path ppf t1 (t2 :> path) | `Class (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `ClassType (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `Type (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) and resolved_value_path : config -> Format.formatter -> Cpath.Resolved.value -> unit = fun c ppf p -> match p with | `Value (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (ValueName.to_string t) | `Gpath p -> Format.fprintf ppf "%a" (model_resolved_path c) (p :> rpath) and resolved_parent_path : config -> Format.formatter -> Cpath.Resolved.parent -> unit = fun c ppf p -> match p with | `Module m -> resolved_module_path c ppf m | `ModuleType m -> if c.short_paths then resolved_module_type_path c ppf m else Format.fprintf ppf ">>%a<<" (resolved_module_type_path c) m | `FragmentRoot -> Format.fprintf ppf "FragmentRoot" and type_path : config -> Format.formatter -> Cpath.type_ -> unit = fun c ppf p -> match p with | `Resolved r -> wrap c "resolved" resolved_type_path ppf r | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b | `Local (id, b) -> wrap2 c "local" ident_fmt bool ppf id b | `Substituted s -> wrap c "substituted" type_path ppf s | `DotT (m, s) -> Format.fprintf ppf "%a.%a" (module_path c) m TypeName.fmt s | `Class (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `ClassType (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `Type (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) and value_path : config -> Format.formatter -> Cpath.value -> unit = fun c ppf p -> match p with | `Resolved r -> wrap c "resolved" resolved_value_path ppf r | `DotV (m, s) -> Format.fprintf ppf "%a.%a" (module_path c) m ValueName.fmt s | `Value (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (ValueName.to_string t) | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b and resolved_class_type_path : config -> Format.formatter -> Cpath.Resolved.class_type -> unit = fun c ppf p -> match p with | `Local id -> Format.fprintf ppf "%a" Ident.fmt id | `Gpath p -> Format.fprintf ppf "%a" (model_resolved_path c) (p :> rpath) | `Substituted s -> wrap c "substituted" resolved_class_type_path ppf s | `Class (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `ClassType (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) and class_type_path : config -> Format.formatter -> Cpath.class_type -> unit = fun c ppf p -> match p with | `Resolved r -> Format.fprintf ppf "%a" (resolved_class_type_path c) r | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b | `Local (id, b) -> wrap2 c "local" ident_fmt bool ppf id b | `Substituted s -> wrap c "substituted" class_type_path ppf s | `DotT (m, s) -> Format.fprintf ppf "%a.%a" (module_path c) m TypeName.fmt s | `Class (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) | `ClassType (p, t) -> Format.fprintf ppf "%a.%s" (resolved_parent_path c) p (TypeName.to_string t) and model_path : config -> Format.formatter -> path -> unit = fun c ppf (p : path) -> let dot p s = Format.fprintf ppf "%a.%s" (model_path c) (p : Odoc_model.Paths.Path.Module.t :> path) s in match p with | `Resolved rp -> wrap c "resolved" model_resolved_path ppf rp | `Identifier (id, b) -> wrap2 c "identifier" model_identifier bool ppf (id :> id) b | `Root s -> wrap c "root" str ppf (ModuleName.to_string s) | `Forward s -> wrap c "forward" str ppf s | `Dot (p, s) -> dot p (ModuleName.to_string s) | `DotMT (p, s) -> dot p (ModuleTypeName.to_string s) | `DotT (p, s) -> dot p (TypeName.to_string s) | `DotV (p, s) -> dot p (ValueName.to_string s) | `Apply (func, arg) -> Format.fprintf ppf "%a(%a)" (model_path c) (func :> path) (model_path c) (arg :> path) | `Substituted m -> wrap c "substituted" model_path ppf (m :> Odoc_model.Paths.Path.t) | `SubstitutedMT m -> wrap c "substitutedmt" model_path ppf (m :> Odoc_model.Paths.Path.t) | `SubstitutedT m -> wrap c "substitutedt" model_path ppf (m :> Odoc_model.Paths.Path.t) | `SubstitutedCT m -> wrap c "substitutedct" model_path ppf (m :> Odoc_model.Paths.Path.t) and model_resolved_path (c : config) ppf (p : rpath) = let open Odoc_model.Paths.Path.Resolved in match p with | `CoreType x -> Format.fprintf ppf "%s" (TypeName.to_string x) | `Identifier id -> Format.fprintf ppf "%a" (model_identifier c) (id :> id) | `Module (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (ModuleName.to_string name) | `ModuleType (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (ModuleTypeName.to_string name) | `Type (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (TypeName.to_string name) | `Value (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (ValueName.to_string name) | `Alias (dest, src) -> wrap2r c "alias" model_resolved_path model_path ppf (dest :> t) (src :> path) | `AliasModuleType (path, realpath) -> wrap2r c "aliasmoduletype" model_resolved_path model_resolved_path ppf (path :> t) (realpath :> t) | `Subst (modty, m) -> wrap2 c "subst" model_resolved_path model_resolved_path ppf (modty :> t) (m :> t) | `SubstT (t1, t2) -> wrap2 c "substt" model_resolved_path model_resolved_path ppf (t1 :> t) (t2 :> t) | `CanonicalModuleType (t1, t2) -> wrap2 c "canonicalmoduletype" model_resolved_path model_path ppf (t1 :> t) (t2 :> path) | `CanonicalType (t1, t2) -> wrap2 c "canonicaltype" model_resolved_path model_path ppf (t1 :> t) (t2 :> path) | `Apply (funct, arg) -> Format.fprintf ppf "%a(%a)" (model_resolved_path c) (funct :> t) (model_resolved_path c) (arg :> t) | `Canonical (p1, p2) -> wrap2 c "canonical" model_resolved_path model_path ppf (p1 :> t) (p2 :> path) | `Hidden p -> wrap c "hidden" model_resolved_path ppf (p :> t) | `Class (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (TypeName.to_string name) | `ClassType (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_path c) (parent :> t) (TypeName.to_string name) | `OpaqueModule m -> wrap c "opaquemodule" model_resolved_path ppf (m :> t) | `OpaqueModuleType m -> wrap c "opaquemoduletype" model_resolved_path ppf (m :> t) | `Substituted m -> wrap c "substituted" model_resolved_path ppf (m :> t) | `SubstitutedMT m -> wrap c "substitutedmt" model_resolved_path ppf (m :> t) | `SubstitutedT m -> wrap c "substitutedt" model_resolved_path ppf (m :> t) | `SubstitutedCT m -> wrap c "substitutedct" model_resolved_path ppf (m :> t) and model_fragment c ppf (f : Odoc_model.Paths.Fragment.t) = match f with | `Resolved rf -> model_resolved_fragment c ppf rf | `Dot (sg, d) -> Format.fprintf ppf "*%a.%s" (model_fragment c) (sg :> Odoc_model.Paths.Fragment.t) d | `Root -> () and model_resolved_fragment c ppf (f : Odoc_model.Paths.Fragment.Resolved.t) = let open Odoc_model.Paths.Fragment.Resolved in match f with | `Root (`ModuleType p) -> Format.fprintf ppf "root(%a)" (model_resolved_path c) (p :> rpath) | `Root (`Module p) -> Format.fprintf ppf "root(%a)" (model_resolved_path c) (p :> rpath) | `Module (`Root _, m) when c.short_paths -> Format.fprintf ppf "%s" (ModuleName.to_string m) | `Module (sg, m) -> Format.fprintf ppf "%a.%s" (model_resolved_fragment c) (sg :> t) (ModuleName.to_string m) | `Module_type (`Root _, m) when c.short_paths -> Format.fprintf ppf "%s" (ModuleTypeName.to_string m) | `Module_type (sg, mty) -> Format.fprintf ppf "%a.%s" (model_resolved_fragment c) (sg :> t) (ModuleTypeName.to_string mty) | `Type (`Root _, t) when c.short_paths -> Format.fprintf ppf "%s" (TypeName.to_string t) | `Type (sg, t) -> Format.fprintf ppf "%a.%s" (model_resolved_fragment c) (sg :> t) (TypeName.to_string t) | `Subst (path, m) -> Format.fprintf ppf "(%a subst -> %a)" (model_resolved_path c) (path :> rpath) (model_resolved_fragment c) (m :> t) | `Alias (_, _) -> Format.fprintf ppf "UNIMPLEMENTED subst alias!?" | `Class (sg, cls) -> Format.fprintf ppf "%a.%s" (model_resolved_fragment c) (sg :> t) (TypeName.to_string cls) | `ClassType (sg, cls) -> Format.fprintf ppf "%a.%s" (model_resolved_fragment c) (sg :> t) (TypeName.to_string cls) | `OpaqueModule m -> Format.fprintf ppf "opaquemodule(%a)" (model_resolved_fragment c) (m :> Odoc_model.Paths.Fragment.Resolved.t) and resolved_root_fragment c ppf (f : Cfrag.root) = match f with | `ModuleType p -> Format.fprintf ppf "root(%a)" (resolved_module_type_path c) p | `Module p -> Format.fprintf ppf "root(%a)" (resolved_module_path c) p and resolved_signature_fragment c ppf (f : Cfrag.resolved_signature) = match f with | `Root r -> Format.fprintf ppf "%a" (resolved_root_fragment c) r | (`Subst _ | `Alias _ | `Module _) as x -> resolved_module_fragment c ppf x | `OpaqueModule m -> Format.fprintf ppf "opaquemodule(%a)" (resolved_module_fragment c) m and resolved_module_fragment c ppf (f : Cfrag.resolved_module) = match f with | `Subst (s, f) -> wrap2r c "subst" resolved_module_type_path resolved_module_fragment ppf s f | `Alias (m, f) -> wrap2r c "alias" resolved_module_path resolved_module_fragment ppf m f | `Module (`Root _, n) when c.short_paths -> Format.fprintf ppf "%s" (ModuleName.to_string n) | `Module (p, n) -> Format.fprintf ppf "%a.%s" (resolved_signature_fragment c) p (ModuleName.to_string n) | `OpaqueModule m -> wrap c "opaquemodule" resolved_module_fragment ppf m and resolved_module_type_fragment c ppf (f : Cfrag.resolved_module_type) = match f with | `ModuleType (`Root _, n) when c.short_paths -> Format.fprintf ppf "%s" (ModuleTypeName.to_string n) | `ModuleType (p, n) -> Format.fprintf ppf "%a.%s" (resolved_signature_fragment c) p (ModuleTypeName.to_string n) and resolved_type_fragment c ppf (f : Cfrag.resolved_type) = match f with | `Type (`Root _, n) when c.short_paths -> Format.fprintf ppf "%s" (TypeName.to_string n) | `Class (`Root _, n) when c.short_paths -> Format.fprintf ppf "%s" (TypeName.to_string n) | `ClassType (`Root _, n) when c.short_paths -> Format.fprintf ppf "%s" (TypeName.to_string n) | `Type (s, n) -> Format.fprintf ppf "%a.%s" (resolved_signature_fragment c) s (TypeName.to_string n) | `Class (s, n) -> Format.fprintf ppf "%a.%s" (resolved_signature_fragment c) s (TypeName.to_string n) | `ClassType (s, n) -> Format.fprintf ppf "%a.%s" (resolved_signature_fragment c) s (TypeName.to_string n) and signature_fragment c ppf (f : Cfrag.signature) = match f with | `Resolved r -> Format.fprintf ppf "r(%a)" (resolved_signature_fragment c) r | `Dot (s, n) -> Format.fprintf ppf "%a.%s" (signature_fragment c) s n | `Root -> Format.fprintf ppf "root" and module_fragment c ppf (f : Cfrag.module_) = match f with | `Resolved r -> wrap c "resolved" resolved_module_fragment ppf r | `Dot (`Root, n) when c.short_paths -> Format.fprintf ppf "%s" n | `Dot (s, n) -> Format.fprintf ppf "%a.%s" (signature_fragment c) s n and module_type_fragment c ppf (f : Cfrag.module_type) = match f with | `Resolved r -> wrap c "resolved" resolved_module_type_fragment ppf r | `Dot (`Root, n) when c.short_paths -> Format.fprintf ppf "%s" n | `Dot (s, n) -> Format.fprintf ppf "%a.%s" (signature_fragment c) s n and type_fragment c ppf (f : Cfrag.type_) = match f with | `Resolved r -> wrap c "resolved" resolved_type_fragment ppf r | `Dot (`Root, n) when c.short_paths -> Format.fprintf ppf "%s" n | `Dot (s, n) -> Format.fprintf ppf "%a.%s" (signature_fragment c) s n and model_resolved_reference c ppf (r : Odoc_model.Paths.Reference.Resolved.t) = let open Odoc_model.Paths.Reference.Resolved in match r with | `Identifier id -> Format.fprintf ppf "%a" (model_identifier c) id | `Hidden p -> Format.fprintf ppf "hidden(%a)" (model_resolved_reference c) (p :> t) | `Module (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ModuleName.to_string name) | `ModuleType (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ModuleTypeName.to_string name) | `Type (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (TypeName.to_string name) | `Constructor (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ConstructorName.to_string name) | `PolyConstructor (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ConstructorName.to_string name) | `Field (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (FieldName.to_string name) | `Extension (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ExtensionName.to_string name) | `ExtensionDecl (parent, name, _) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ExtensionName.to_string name) | `Exception (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ExceptionName.to_string name) | `Value (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (ValueName.to_string name) | `Class (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (TypeName.to_string name) | `ClassType (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (TypeName.to_string name) | `Method (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (MethodName.to_string name) | `InstanceVariable (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (InstanceVariableName.to_string name) | `Alias (x, y) -> Format.fprintf ppf "alias(%a,%a)" (model_resolved_path c) (x :> rpath) (model_resolved_reference c) (y :> Odoc_model.Paths.Reference.Resolved.t) | `AliasModuleType (x, y) -> Format.fprintf ppf "aliasmoduletype(%a,%a)" (model_resolved_path c) (x :> rpath) (model_resolved_reference c) (y :> Odoc_model.Paths.Reference.Resolved.t) | `Label (parent, name) -> Format.fprintf ppf "%a.%s" (model_resolved_reference c) (parent :> t) (LabelName.to_string name) and model_reference_hierarchy _c ppf ((tag, components) : Reference.Hierarchy.t) = (match tag with | `TRelativePath -> fpf ppf "./" | `TAbsolutePath -> fpf ppf "/" | `TCurrentPackage -> fpf ppf "//"); let pp_sep ppf () = fpf ppf "/" in Format.pp_print_list ~pp_sep Format.pp_print_string ppf components and model_reference c ppf (r : Reference.t) = let open Reference in match r with | `Resolved r' -> Format.fprintf ppf "r(%a)" (model_resolved_reference c) r' | `Root (name, _) -> Format.fprintf ppf "unresolvedroot(%s)" name | `Dot (parent, str) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) str | `Page_path p -> model_reference_hierarchy c ppf p | `Asset_path p -> model_reference_hierarchy c ppf p | `Module_path p -> model_reference_hierarchy c ppf p | `Any_path p -> model_reference_hierarchy c ppf p | `Module (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ModuleName.to_string name) | `ModuleType (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ModuleTypeName.to_string name) | `Type (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (TypeName.to_string name) | `Constructor (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ConstructorName.to_string name) | `Field (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (FieldName.to_string name) | `Extension (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ExtensionName.to_string name) | `ExtensionDecl (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ExtensionName.to_string name) | `Exception (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ExceptionName.to_string name) | `Value (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (ValueName.to_string name) | `Class (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (TypeName.to_string name) | `ClassType (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (TypeName.to_string name) | `Method (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (MethodName.to_string name) | `InstanceVariable (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (InstanceVariableName.to_string name) | `Label (parent, name) -> Format.fprintf ppf "%a.%s" (model_reference c) (parent :> t) (LabelName.to_string name) end module LocalIdents = struct open Odoc_model (** The purpose of this module is to extract identifiers that could be referenced in Paths - that is, modules, module types, types, classes and class types. That way we can assign them an Ident.t ahead of time and be self-consistent. Because we don't need _all_ of the identifiers we don't traverse the entire structure. Additionally, we stop at (class_)signature boundaries since identifiers within these won't be referenced except within them, so we only do that on demand. *) type t = { modules : Paths.Identifier.Module.t list; module_types : Paths.Identifier.ModuleType.t list; types : Paths.Identifier.Type.t list; classes : Paths.Identifier.Class.t list; class_types : Paths.Identifier.ClassType.t list; } let empty = { modules = []; module_types = []; types = []; classes = []; class_types = []; } open Lang let rec signature_items s ids = let open Signature in List.fold_left (fun ids c -> match c with | Module (_, { Module.id; _ }) -> { ids with modules = id :: ids.modules } | ModuleType m -> { ids with module_types = m.ModuleType.id :: ids.module_types } | ModuleSubstitution { ModuleSubstitution.id; _ } -> { ids with modules = id :: ids.modules } | ModuleTypeSubstitution { ModuleTypeSubstitution.id; _ } -> { ids with module_types = id :: ids.module_types } | Type (_, t) -> { ids with types = t.TypeDecl.id :: ids.types } | TypeSubstitution t -> { ids with types = t.TypeDecl.id :: ids.types } | Class (_, c) -> { ids with classes = c.Class.id :: ids.classes } | ClassType (_, c) -> { ids with class_types = c.ClassType.id :: ids.class_types } | TypExt _ | Exception _ | Value _ | Comment _ -> ids | Include i -> signature i.Include.expansion.content ids | Open o -> signature o.Open.expansion ids) ids s and signature s ids = signature_items s.items ids end module Of_Lang = struct open Odoc_model type map = { modules : Ident.module_ Paths.Identifier.Maps.Module.t; module_types : Ident.module_type Paths.Identifier.Maps.ModuleType.t; functor_parameters : Ident.module_ Paths.Identifier.Maps.FunctorParameter.t; types : Ident.type_ Paths.Identifier.Maps.Type.t; path_types : Ident.type_ Paths.Identifier.Maps.Path.Type.t; path_class_types : Ident.type_ Paths.Identifier.Maps.Path.ClassType.t; classes : Ident.type_ Paths.Identifier.Maps.Class.t; class_types : Ident.type_ Paths.Identifier.Maps.ClassType.t; } let empty () = let open Paths.Identifier.Maps in { modules = Module.empty; module_types = ModuleType.empty; functor_parameters = FunctorParameter.empty; types = Type.empty; path_types = Path.Type.empty; path_class_types = Path.ClassType.empty; classes = Class.empty; class_types = ClassType.empty; } let map_of_idents ids map = let open Paths.Identifier in (* New types go into [types_new] and [path_types_new] New classes go into [classes_new] and [path_class_types_new] New class_types go into [class_types_new], [path_types_new] and [path_class_types_new] *) let types_new, path_types_new = List.fold_left (fun (types, path_types) i -> let id = Ident.Of_Identifier.type_ i in ( Maps.Type.add i id types, Maps.Path.Type.add (i :> Path.Type.t) id path_types )) (map.types, map.path_types) ids.LocalIdents.types in let classes_new, path_class_types_new = List.fold_left (fun (classes, path_class_types) i -> let id = Ident.Of_Identifier.class_ i in ( Maps.Class.add i id classes, Maps.Path.ClassType.add (i :> Path.ClassType.t) id path_class_types )) (map.classes, map.path_class_types) ids.LocalIdents.classes in let class_types_new, path_types_new, path_class_types_new = List.fold_left (fun (class_types, path_types, path_class_types) i -> let id = Ident.Of_Identifier.class_type i in ( Maps.ClassType.add i id class_types, Maps.Path.Type.add (i :> Path.Type.t) id path_types, Maps.Path.ClassType.add (i :> Path.ClassType.t) id path_class_types )) (map.class_types, path_types_new, path_class_types_new) ids.LocalIdents.class_types in let modules_new = List.fold_left (fun acc i -> Maps.Module.add (i :> Module.t) (Ident.Of_Identifier.module_ i) acc) map.modules ids.LocalIdents.modules in let module_types_new = List.fold_left (fun acc i -> Maps.ModuleType.add i (Ident.Of_Identifier.module_type i) acc) map.module_types ids.LocalIdents.module_types in let modules = modules_new in let module_types = module_types_new in let functor_parameters = map.functor_parameters in let types = types_new in let classes = classes_new in let class_types = class_types_new in let path_types = path_types_new in let path_class_types = path_class_types_new in { modules; module_types; functor_parameters; types; classes; class_types; path_types; path_class_types; } let option conv ident_map x = match x with None -> None | Some x' -> Some (conv ident_map x') let identifier lookup map i = match lookup i map with | x -> `Local x | exception Not_found -> `Identifier i let find_any_module i ident_map = match i with | { Odoc_model.Paths.Identifier.iv = `Root _ | `Module _; _ } as id -> Maps.Module.find id ident_map.modules | { Odoc_model.Paths.Identifier.iv = #Paths.Identifier.FunctorParameter.t_pv; _; } as id -> Maps.FunctorParameter.find id ident_map.functor_parameters | _ -> raise Not_found let rec resolved_module_path : _ -> Odoc_model.Paths.Path.Resolved.Module.t -> Cpath.Resolved.module_ = fun ident_map p -> let recurse = resolved_module_path ident_map in match p with | `Identifier i -> ( match identifier find_any_module ident_map i with | `Local l -> `Local l | `Identifier _ -> `Gpath p) | `Module (p, name) -> `Module (`Module (recurse p), name) | `Apply (p1, p2) -> `Apply (recurse p1, recurse p2) | `Alias (p1, p2) -> `Alias (recurse p1, module_path ident_map p2, None) | `Subst (p1, p2) -> `Subst (resolved_module_type_path ident_map p1, recurse p2) | `Canonical (p1, p2) -> `Canonical (recurse p1, p2) | `Hidden p1 -> `Hidden (recurse p1) | `OpaqueModule m -> `OpaqueModule (recurse m) | `Substituted m -> `Substituted (recurse m) and resolved_module_type_path : _ -> Odoc_model.Paths.Path.Resolved.ModuleType.t -> Cpath.Resolved.module_type = fun ident_map p -> match p with | `Identifier i -> ( match identifier Maps.ModuleType.find ident_map.module_types i with | `Local l -> `Local l | `Identifier _ -> `Gpath p) | `ModuleType (p, name) -> `ModuleType (`Module (resolved_module_path ident_map p), name) | `CanonicalModuleType (p1, p2) -> `CanonicalModuleType (resolved_module_type_path ident_map p1, p2) | `OpaqueModuleType m -> `OpaqueModuleType (resolved_module_type_path ident_map m) | `AliasModuleType (m1, m2) -> `AliasModuleType ( resolved_module_type_path ident_map m1, resolved_module_type_path ident_map m2 ) | `SubstT (p1, p2) -> `SubstT ( resolved_module_type_path ident_map p1, resolved_module_type_path ident_map p2 ) | `SubstitutedMT m -> `Substituted (resolved_module_type_path ident_map m) and resolved_type_path : _ -> Odoc_model.Paths.Path.Resolved.Type.t -> Cpath.Resolved.type_ = fun ident_map p -> match p with | `CoreType _ as c -> c | `Identifier i -> ( match identifier Maps.Path.Type.find ident_map.path_types i with | `Local l -> `Local l | `Identifier _ -> `Gpath p) | `CanonicalType (p1, p2) -> `CanonicalType (resolved_type_path ident_map p1, p2) | `Type (p, name) -> `Type (`Module (resolved_module_path ident_map p), name) | `Class (p, name) -> `Class (`Module (resolved_module_path ident_map p), name) | `ClassType (p, name) -> `ClassType (`Module (resolved_module_path ident_map p), name) | `SubstitutedT m -> `Substituted (resolved_type_path ident_map m) | `SubstitutedCT m -> `Substituted (resolved_class_type_path ident_map m :> Cpath.Resolved.type_) and resolved_value_path : _ -> Odoc_model.Paths.Path.Resolved.Value.t -> Cpath.Resolved.value = fun ident_map p -> match p with | `Value (p, name) -> `Value (`Module (resolved_module_path ident_map p), name) | `Identifier _ -> `Gpath p and resolved_class_type_path : _ -> Odoc_model.Paths.Path.Resolved.ClassType.t -> Cpath.Resolved.class_type = fun ident_map p -> match p with | `Identifier i -> ( match identifier Maps.Path.ClassType.find ident_map.path_class_types i with | `Local l -> `Local l | `Identifier _ -> `Gpath p) | `Class (p, name) -> `Class (`Module (resolved_module_path ident_map p), name) | `ClassType (p, name) -> `ClassType (`Module (resolved_module_path ident_map p), name) | `SubstitutedCT c -> `Substituted (resolved_class_type_path ident_map c) and module_path : _ -> Odoc_model.Paths.Path.Module.t -> Cpath.module_ = fun ident_map p -> match p with | `Resolved r -> `Resolved (resolved_module_path ident_map r) | `Substituted m -> `Substituted (module_path ident_map m) | `Identifier (i, b) -> ( match identifier find_any_module ident_map i with | `Identifier i -> `Identifier (i, b) | `Local i -> `Local (i, b)) | `Dot (path', x) -> `Dot (module_path ident_map path', x) | `Apply (p1, p2) -> `Apply (module_path ident_map p1, module_path ident_map p2) | `Forward str -> `Forward str | `Root str -> `Root str and module_type_path : _ -> Odoc_model.Paths.Path.ModuleType.t -> Cpath.module_type = fun ident_map p -> match p with | `Resolved r -> `Resolved (resolved_module_type_path ident_map r) | `SubstitutedMT m -> `Substituted (module_type_path ident_map m) | `Identifier (i, b) -> ( match identifier Maps.ModuleType.find ident_map.module_types i with | `Identifier i -> `Identifier (i, b) | `Local i -> `Local (i, b)) | `DotMT (path', x) -> `DotMT (module_path ident_map path', x) and type_path : _ -> Odoc_model.Paths.Path.Type.t -> Cpath.type_ = fun ident_map p -> match p with | `Resolved r -> `Resolved (resolved_type_path ident_map r) | `SubstitutedT t -> `Substituted (type_path ident_map t) | `Identifier (i, b) -> ( match identifier Maps.Path.Type.find ident_map.path_types i with | `Identifier i -> `Identifier (i, b) | `Local i -> `Local (i, b)) | `DotT (path', x) -> `DotT (module_path ident_map path', x) and value_path : _ -> Odoc_model.Paths.Path.Value.t -> Cpath.value = fun ident_map p -> match p with | `Resolved r -> `Resolved (resolved_value_path ident_map r) | `DotV (path', x) -> `DotV (module_path ident_map path', x) | `Identifier (i, b) -> `Identifier (i, b) and class_type_path : _ -> Odoc_model.Paths.Path.ClassType.t -> Cpath.class_type = fun ident_map p -> match p with | `Resolved r -> `Resolved (resolved_class_type_path ident_map r) | `SubstitutedCT c -> `Substituted (class_type_path ident_map c) | `Identifier (i, b) -> ( match identifier Maps.Path.ClassType.find ident_map.path_class_types i with | `Identifier i -> `Identifier (i, b) | `Local i -> `Local (i, b)) | `DotT (path', x) -> `DotT (module_path ident_map path', x) let rec resolved_signature_fragment : map -> Odoc_model.Paths.Fragment.Resolved.Signature.t -> Cfrag.resolved_signature = fun ident_map ty -> match ty with | `Root (`ModuleType path) -> `Root (`ModuleType (resolved_module_type_path ident_map path)) | `Root (`Module path) -> `Root (`Module (resolved_module_path ident_map path)) | (`Alias _ | `Subst _ | `Module _ | `OpaqueModule _) as x -> (resolved_module_fragment ident_map x :> Cfrag.resolved_signature) and resolved_module_fragment : _ -> Odoc_model.Paths.Fragment.Resolved.Module.t -> Cfrag.resolved_module = fun ident_map ty -> match ty with | `Subst (p, m) -> `Subst ( resolved_module_type_path ident_map p, resolved_module_fragment ident_map m ) | `Alias (p, m) -> `Alias ( resolved_module_path ident_map p, resolved_module_fragment ident_map m ) | `Module (p, m) -> `Module (resolved_signature_fragment ident_map p, m) | `OpaqueModule m -> `OpaqueModule (resolved_module_fragment ident_map m) and resolved_module_type_fragment : _ -> Odoc_model.Paths.Fragment.Resolved.ModuleType.t -> Cfrag.resolved_module_type = fun ident_map ty -> match ty with | `Module_type (p, m) -> `ModuleType (resolved_signature_fragment ident_map p, m) and resolved_type_fragment : _ -> Odoc_model.Paths.Fragment.Resolved.Type.t -> Cfrag.resolved_type = fun ident_map ty -> match ty with | `Type (p, n) -> `Type (resolved_signature_fragment ident_map p, n) | `Class (p, n) -> `Class (resolved_signature_fragment ident_map p, n) | `ClassType (p, n) -> `ClassType (resolved_signature_fragment ident_map p, n) let rec signature_fragment : _ -> Odoc_model.Paths.Fragment.Signature.t -> Cfrag.signature = fun ident_map ty -> match ty with | `Resolved r -> `Resolved (resolved_signature_fragment ident_map r) | `Dot (p, n) -> `Dot (signature_fragment ident_map p, n) | `Root -> `Root let module_fragment : _ -> Odoc_model.Paths.Fragment.Module.t -> Cfrag.module_ = fun ident_map ty -> match ty with | `Resolved r -> `Resolved (resolved_module_fragment ident_map r) | `Dot (p, n) -> `Dot (signature_fragment ident_map p, n) let module_type_fragment : _ -> Odoc_model.Paths.Fragment.ModuleType.t -> Cfrag.module_type = fun ident_map ty -> match ty with | `Resolved r -> `Resolved (resolved_module_type_fragment ident_map r) | `Dot (p, n) -> `Dot (signature_fragment ident_map p, n) let type_fragment : _ -> Odoc_model.Paths.Fragment.Type.t -> Cfrag.type_ = fun ident_map ty -> match ty with | `Resolved r -> `Resolved (resolved_type_fragment ident_map r) | `Dot (p, n) -> `Dot (signature_fragment ident_map p, n) let rec type_decl ident_map ty = let open Odoc_model.Lang.TypeDecl in { TypeDecl.source_loc = ty.source_loc; doc = docs ident_map ty.doc; canonical = ty.canonical; equation = type_equation ident_map ty.equation; representation = Opt.map (type_decl_representation ident_map) ty.representation; } and type_decl_representation ident_map r = let open Odoc_model.Lang.TypeDecl.Representation in match r with | Variant cs -> TypeDecl.Representation.Variant (List.map (type_decl_constructor ident_map) cs) | Record fs -> Record (List.map (type_decl_field ident_map) fs) | Extensible -> Extensible and type_decl_constructor ident_map t = let open Odoc_model.Lang.TypeDecl.Constructor in let args = type_decl_constructor_argument ident_map t.args in let res = Opt.map (type_expression ident_map) t.res in { TypeDecl.Constructor.name = Paths.Identifier.name t.id; doc = docs ident_map t.doc; args; res; } and type_decl_constructor_argument ident_map a = let open Odoc_model.Lang.TypeDecl.Constructor in match a with | Tuple ts -> TypeDecl.Constructor.Tuple (List.map (type_expression ident_map) ts) | Record fs -> Record (List.map (type_decl_field ident_map) fs) and type_decl_field ident_map f = let open Odoc_model.Lang.TypeDecl.Field in let type_ = type_expression ident_map f.type_ in { TypeDecl.Field.name = Paths.Identifier.name f.id; doc = docs ident_map f.doc; mutable_ = f.mutable_; type_; } and type_equation ident_map teq = let open Odoc_model.Lang.TypeDecl.Equation in { TypeDecl.Equation.params = teq.params; private_ = teq.private_; manifest = option type_expression ident_map teq.manifest; constraints = List.map (fun (x, y) -> (type_expression ident_map x, type_expression ident_map y)) teq.constraints; } and type_expr_polyvar ident_map v = let open Odoc_model.Lang.TypeExpr.Polymorphic_variant in let map_element = function | Type expr -> TypeExpr.Polymorphic_variant.Type (type_expression ident_map expr) | Constructor c -> Constructor TypeExpr.Polymorphic_variant.Constructor. { name = c.name; constant = c.constant; arguments = List.map (type_expression ident_map) c.arguments; doc = docs ident_map c.doc; } in { TypeExpr.Polymorphic_variant.kind = v.kind; elements = List.map map_element v.elements; } and type_object ident_map o = let open Odoc_model.Lang.TypeExpr.Object in let map_field = function | Method m -> TypeExpr.( Object.Method { Object.name = m.name; type_ = type_expression ident_map m.type_; }) | Inherit i -> Inherit (type_expression ident_map i) in { TypeExpr.Object.open_ = o.open_; fields = List.map map_field o.fields } and type_package ident_map pkg = let open Odoc_model.Lang.TypeExpr.Package in { TypeExpr.Package.path = module_type_path ident_map pkg.path; substitutions = List.map (fun (x, y) -> let f = type_fragment ident_map x in (f, type_expression ident_map y)) pkg.substitutions; } and type_expression ident_map expr = let open Odoc_model.Lang.TypeExpr in match expr with | Var s -> TypeExpr.Var s | Any -> Any | Constr (p, xs) -> Constr (type_path ident_map p, List.map (type_expression ident_map) xs) | Arrow (lbl, t1, t2) -> Arrow (lbl, type_expression ident_map t1, type_expression ident_map t2) | Tuple ts -> Tuple (List.map (type_expression ident_map) ts) | Polymorphic_variant v -> Polymorphic_variant (type_expr_polyvar ident_map v) | Poly (s, ts) -> Poly (s, type_expression ident_map ts) | Alias (t, s) -> Alias (type_expression ident_map t, s) | Class (p, ts) -> Class (class_type_path ident_map p, List.map (type_expression ident_map) ts) | Object o -> Object (type_object ident_map o) | Package p -> Package (type_package ident_map p) and module_decl ident_map m = match m with | Lang.Module.Alias (p, e) -> Module.Alias (module_path ident_map p, option simple_expansion ident_map e) | Lang.Module.ModuleType s -> Module.ModuleType (module_type_expr ident_map s) and include_decl ident_map m = match m with | Odoc_model.Lang.Include.Alias p -> Include.Alias (module_path ident_map p) | ModuleType s -> ModuleType (u_module_type_expr ident_map s) and simple_expansion ident_map (f : Odoc_model.Lang.ModuleType.simple_expansion) : ModuleType.simple_expansion = let open Odoc_model.Lang.ModuleType in let open Odoc_model.Lang.FunctorParameter in match f with | Signature t -> Signature (signature ident_map t) | Functor (arg, sg) -> ( match arg with | Named arg -> let identifier = arg.Odoc_model.Lang.FunctorParameter.id in let id = Ident.Of_Identifier.functor_parameter identifier in let ident_map' = { ident_map with functor_parameters = Maps.FunctorParameter.add identifier id ident_map.functor_parameters; } in let arg' = functor_parameter ident_map' id arg in Functor (FunctorParameter.Named arg', simple_expansion ident_map' sg) | Unit -> Functor (FunctorParameter.Unit, simple_expansion ident_map sg) ) and module_ ident_map m = let type_ = module_decl ident_map m.Odoc_model.Lang.Module.type_ in let canonical = m.Odoc_model.Lang.Module.canonical in { Module.source_loc = m.source_loc; doc = docs ident_map m.doc; type_; canonical; hidden = m.hidden; } and with_module_type_substitution ident_map m = let open Odoc_model.Lang.ModuleType in match m with | ModuleEq (frag, decl) -> ModuleType.ModuleEq (module_fragment ident_map frag, module_decl ident_map decl) | ModuleSubst (frag, p) -> ModuleType.ModuleSubst (module_fragment ident_map frag, module_path ident_map p) | ModuleTypeEq (frag, mty) -> ModuleType.ModuleTypeEq (module_type_fragment ident_map frag, module_type_expr ident_map mty) | ModuleTypeSubst (frag, mty) -> ModuleType.ModuleTypeSubst (module_type_fragment ident_map frag, module_type_expr ident_map mty) | TypeEq (frag, eqn) -> ModuleType.TypeEq (type_fragment ident_map frag, type_equation ident_map eqn) | TypeSubst (frag, eqn) -> ModuleType.TypeSubst (type_fragment ident_map frag, type_equation ident_map eqn) and functor_parameter ident_map id a = let expr' = module_type_expr ident_map a.Odoc_model.Lang.FunctorParameter.expr in { FunctorParameter.id; expr = expr' } and extension ident_map e = let open Odoc_model.Lang.Extension in let type_path = type_path ident_map e.type_path in let constructors = List.map (extension_constructor ident_map) e.constructors in { Extension.type_path; doc = docs ident_map e.doc; type_params = e.type_params; private_ = e.private_; constructors; } and extension_constructor ident_map c = let open Odoc_model.Lang.Extension.Constructor in let args = type_decl_constructor_argument ident_map c.args in let res = Opt.map (type_expression ident_map) c.res in { Extension.Constructor.name = Paths.Identifier.name c.id; source_loc = c.source_loc; doc = docs ident_map c.doc; args; res; } and exception_ ident_map e = let open Odoc_model.Lang.Exception in let args = type_decl_constructor_argument ident_map e.args in let res = Opt.map (type_expression ident_map) e.res in { Exception.source_loc = e.source_loc; doc = docs ident_map e.doc; args; res; } and u_module_type_expr ident_map m = let open Odoc_model in match m with | Lang.ModuleType.U.Signature s -> let s = signature ident_map s in ModuleType.U.Signature s | Path p -> let p' = module_type_path ident_map p in Path p' | With (w, e) -> let w' = List.map (with_module_type_substitution ident_map) w in With (w', u_module_type_expr ident_map e) | TypeOf (t_desc, t_original_path) -> let t_desc = match t_desc with | ModPath p -> ModuleType.ModPath (module_path ident_map p) | StructInclude p -> StructInclude (module_path ident_map p) in (* see comment in module_type_expr below *) let t_original_path = module_path (empty ()) t_original_path in TypeOf (t_desc, t_original_path) and module_type_expr ident_map m = let open Odoc_model in let open Paths in match m with | Lang.ModuleType.Signature s -> let s = signature ident_map s in ModuleType.Signature s | Lang.ModuleType.Path p -> let p' = ModuleType. { p_path = module_type_path ident_map p.p_path; p_expansion = option simple_expansion ident_map p.p_expansion; } in ModuleType.Path p' | Lang.ModuleType.With w -> let w' = ModuleType. { w_substitutions = List.map (with_module_type_substitution ident_map) w.w_substitutions; w_expansion = option simple_expansion ident_map w.w_expansion; w_expr = u_module_type_expr ident_map w.w_expr; } in ModuleType.With w' | Lang.ModuleType.Functor (Named arg, expr) -> let identifier = arg.Lang.FunctorParameter.id in let id = Ident.Of_Identifier.functor_parameter identifier in let ident_map' = { ident_map with functor_parameters = Identifier.Maps.FunctorParameter.add identifier id ident_map.functor_parameters; } in let arg' = functor_parameter ident_map' id arg in let expr' = module_type_expr ident_map' expr in ModuleType.Functor (Named arg', expr') | Lang.ModuleType.Functor (Unit, expr) -> let expr' = module_type_expr ident_map expr in ModuleType.Functor (Unit, expr') | Lang.ModuleType.TypeOf { t_desc; t_original_path; t_expansion } -> let t_desc = match t_desc with | ModPath p -> ModuleType.ModPath (module_path ident_map p) | StructInclude p -> StructInclude (module_path ident_map p) in let t_expansion = option simple_expansion ident_map t_expansion in (* Nb, we _never_ want to relativize this path, because this should always be the _original_ path. That's why we're passing in (empty()) rather than ident_map. We don't leave it as a Lang path because we'll occasionally _create_ a `TypeOf` expression as part of fragmap *) let t_original_path = module_path (empty ()) t_original_path in ModuleType.(TypeOf { t_desc; t_original_path; t_expansion }) and module_type ident_map m = let expr = Opt.map (module_type_expr ident_map) m.Odoc_model.Lang.ModuleType.expr in { ModuleType.source_loc = m.source_loc; doc = docs ident_map m.doc; canonical = m.canonical; expr; } and value ident_map v = let type_ = type_expression ident_map v.Lang.Value.type_ in { Value.type_; doc = docs ident_map v.doc; value = v.value; source_loc = v.source_loc; } and include_ ident_map i = let open Odoc_model.Lang.Include in let decl = include_decl ident_map i.decl in { Include.parent = i.parent; doc = docs ident_map i.doc; shadowed = i.expansion.shadowed; expansion_ = apply_sig_map ident_map i.expansion.content; status = i.status; strengthened = option module_path ident_map i.strengthened; decl; loc = i.loc; } and class_ ident_map c = let open Odoc_model.Lang.Class in let expansion = Opt.map (class_signature ident_map) c.expansion in { Class.source_loc = c.source_loc; doc = docs ident_map c.doc; virtual_ = c.virtual_; params = c.params; type_ = class_decl ident_map c.type_; expansion; } and class_decl ident_map c = let open Odoc_model.Lang.Class in match c with | ClassType e -> Class.ClassType (class_type_expr ident_map e) | Arrow (lbl, e, d) -> Arrow (lbl, type_expression ident_map e, class_decl ident_map d) and class_type_expr ident_map e = let open Odoc_model.Lang.ClassType in match e with | Constr (p, ts) -> ClassType.Constr (class_type_path ident_map p, List.map (type_expression ident_map) ts) | Signature s -> Signature (class_signature ident_map s) and class_type ident_map t = let open Odoc_model.Lang.ClassType in let expansion = Opt.map (class_signature ident_map) t.expansion in { ClassType.source_loc = t.source_loc; doc = docs ident_map t.doc; virtual_ = t.virtual_; params = t.params; expr = class_type_expr ident_map t.expr; expansion; } and class_signature ident_map sg = let open Odoc_model.Lang.ClassSignature in let items = List.map (function | Method m -> let id = Ident.Of_Identifier.method_ m.id in let m' = method_ ident_map m in ClassSignature.Method (id, m') | InstanceVariable i -> let id = Ident.Of_Identifier.instance_variable i.id in let i' = instance_variable ident_map i in ClassSignature.InstanceVariable (id, i') | Constraint cst -> Constraint (class_constraint ident_map cst) | Inherit e -> Inherit (inherit_ ident_map e) | Comment c -> Comment (docs_or_stop ident_map c)) sg.items in { ClassSignature.self = Opt.map (type_expression ident_map) sg.self; items; doc = docs ident_map sg.doc; } and method_ ident_map m = let open Odoc_model.Lang.Method in { Method.doc = docs ident_map m.doc; private_ = m.private_; virtual_ = m.virtual_; type_ = type_expression ident_map m.type_; } and instance_variable ident_map i = { InstanceVariable.doc = docs ident_map i.doc; mutable_ = i.mutable_; virtual_ = i.virtual_; type_ = type_expression ident_map i.type_; } and class_constraint ident_map cst = { ClassSignature.Constraint.doc = docs ident_map cst.doc; left = type_expression ident_map cst.left; right = type_expression ident_map cst.right; } and inherit_ ident_map ih = { ClassSignature.Inherit.doc = docs ident_map ih.doc; expr = class_type_expr ident_map ih.expr; } and module_substitution ident_map (t : Odoc_model.Lang.ModuleSubstitution.t) = { ModuleSubstitution.doc = docs ident_map t.doc; manifest = module_path ident_map t.manifest; } and module_type_substitution ident_map (t : Odoc_model.Lang.ModuleTypeSubstitution.t) = { ModuleTypeSubstitution.doc = docs ident_map t.doc; manifest = module_type_expr ident_map t.manifest; } and module_of_module_substitution ident_map (t : Odoc_model.Lang.ModuleSubstitution.t) = let manifest = module_path ident_map t.manifest in { Module.source_loc = None; doc = docs ident_map t.doc; type_ = Alias (manifest, None); canonical = None; hidden = false; } and signature : _ -> Odoc_model.Lang.Signature.t -> Signature.t = fun ident_map items -> (* First we construct a list of brand new [Ident.t]s for each item in the signature *) let ident_map = map_of_idents (LocalIdents.signature items LocalIdents.empty) ident_map in (* Now we construct the Components for each item, converting all paths containing Identifiers pointing at our elements to local paths *) apply_sig_map ident_map items and open_ ident_map o = Open. { expansion = apply_sig_map ident_map o.Odoc_model.Lang.Open.expansion; doc = docs ident_map o.Odoc_model.Lang.Open.doc; } and removed_item ident_map r = let open Odoc_model.Lang.Signature in match r with | RModule (id, p) -> Signature.RModule (id, module_path ident_map p) | RType (id, texpr, eqn) -> RType (id, type_expression ident_map texpr, type_equation ident_map eqn) | RModuleType (id, m) -> RModuleType (id, module_type_expr ident_map m) and apply_sig_map ident_map sg = let items = List.rev_map (let open Odoc_model.Lang.Signature in let open Odoc_model.Paths in function | Type (r, t) -> let id = Identifier.Maps.Type.find t.id ident_map.types in let t' = Delayed.put (fun () -> type_decl ident_map t) in Signature.Type (id, r, t') | TypeSubstitution t -> let id = Identifier.Maps.Type.find t.id ident_map.types in let t' = type_decl ident_map t in Signature.TypeSubstitution (id, t') | Module (r, m) -> let id = Identifier.Maps.Module.find (m.id :> Identifier.Module.t) ident_map.modules in let m' = Delayed.put (fun () -> module_ ident_map m) in Signature.Module (id, r, m') | ModuleSubstitution m -> let id = Identifier.Maps.Module.find m.id ident_map.modules in let m' = module_substitution ident_map m in Signature.ModuleSubstitution (id, m') | ModuleTypeSubstitution m -> let id = Identifier.Maps.ModuleType.find m.id ident_map.module_types in let m' = module_type_substitution ident_map m in Signature.ModuleTypeSubstitution (id, m') | ModuleType m -> let id = Identifier.Maps.ModuleType.find m.id ident_map.module_types in let m' = Delayed.put (fun () -> module_type ident_map m) in Signature.ModuleType (id, m') | Value v -> let id = Ident.Of_Identifier.value v.id in let v' = Delayed.put (fun () -> value ident_map v) in Signature.Value (id, v') | Comment c -> Comment (docs_or_stop ident_map c) | TypExt e -> TypExt (extension ident_map e) | Exception e -> let id = Ident.Of_Identifier.exception_ e.id in Exception (id, exception_ ident_map e) | Class (r, c) -> let id = Identifier.Maps.Class.find c.id ident_map.classes in Class (id, r, class_ ident_map c) | ClassType (r, c) -> let id = Identifier.Maps.ClassType.find c.id ident_map.class_types in ClassType (id, r, class_type ident_map c) | Open o -> Open (open_ ident_map o) | Include i -> Include (include_ ident_map i)) sg.items |> List.rev in let removed = List.map (removed_item ident_map) sg.removed in { items; removed; compiled = sg.compiled; doc = docs ident_map sg.doc } and block_element _ b : CComment.block_element Odoc_model.Comment.with_location = match b with | { Odoc_model.Location_.value = `Heading (attrs, label, text); location } -> let label = Ident.Of_Identifier.label label in Odoc_model.Location_.same b (`Heading { Label.attrs; label; text; location }) | { value = `Tag _ | `Media _; _ } as t -> t | { value = #Odoc_model.Comment.nestable_block_element; _ } as n -> n and docs ident_map d = { elements = List.map (block_element ident_map) d.elements; warnings_tag = d.warnings_tag; } and docs_or_stop ident_map = function | `Docs d -> `Docs (docs ident_map d) | `Stop -> `Stop end let module_of_functor_argument (arg : FunctorParameter.parameter) = { Module.source_loc = None; doc = { elements = []; warnings_tag = None }; type_ = ModuleType arg.expr; canonical = None; hidden = false; } (** This is equivalent to {!Lang.extract_signature_doc}. *) let extract_signature_doc (s : Signature.t) = match (s.doc, s.items) with | { elements = []; _ }, Include { expansion_; status = `Inline; _ } :: _ -> expansion_.doc | doc, _ -> doc
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>