package ocp-index
Lightweight completion and documentation browsing for OCaml libraries
Install
Dune Dependency
Authors
Maintainers
Sources
1.3.3.tar.gz
md5=738dd32765ce0b6b6423620cc62b7db9
sha512=6360240c951ac64baf9b3736c9a37c41a5ac8c5ddf52e723019fb5ef294e786e245712fd88f408bd8f6881d8741ab152872181062acd81443eec07d1d703e85a
doc/src/ocp-index.lib/libIndex.ml.html
Source file libIndex.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
(**************************************************************************) (* *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the Lesser GNU Public License version 3.0. *) (* *) (* This software is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (* - Main types - *) include IndexTypes (* - Utility functions - *) module Misc = IndexMisc (* - Trie loading and manipulation functions - *) include IndexBuild (* - Query functions - *) let filter_visible values = let same_kind a b = match a.kind, b.kind with | Field i, Field j | Variant i, Variant j | Method i, Method j -> i.name = j.name | a, b -> a = b in List.fold_left (fun acc info -> if List.exists (fun n -> same_kind info n) acc then acc else info::acc) [] values let trie_to_list trie = IndexTrie.fold0 (fun acc _path values -> List.rev_append (filter_visible values) acc) trie [] let all t = trie_to_list t let filter t f = IndexTrie.fold0 (fun acc _path values -> List.rev_append (filter_visible (List.filter f values)) acc) t [] let get t query = IndexTrie.find t (Misc.string_to_key query) let get_all t query = IndexTrie.find_all t (Misc.string_to_key query) let complete t ?filter:(f = fun _ -> true) query = let completions = filter (IndexTrie.filter_keys ((<>) Misc.dot) (IndexTrie.sub t (Misc.string_to_key query))) f in let file = function { file = Cmt f | Cmi f | Cmti f } -> f in List.sort (fun i j -> let c = compare (file i) (file j) in if c <> 0 then c else let c = compare (Lazy.force i.loc_sig) (Lazy.force j.loc_sig) in if c <> 0 then c else compare i.path j.path) completions (* - Output functions - *) include IndexOut
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>