Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor sherlodoc #1259

Closed
wants to merge 294 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
294 commits
Select commit Hold shift + click to select a range
b5f1aa9
reduce js database size
art-w Apr 23, 2023
601520a
specialize trie for string keys
art-w Apr 23, 2023
c1a2dda
small size optim to js file
art-w Apr 24, 2023
dd8de37
unstash
EmileTrotignon Apr 24, 2023
b04e882
search of types
EmileTrotignon Apr 24, 2023
38dc4b1
now supports search for module
EmileTrotignon Apr 25, 2023
669ce1c
Search for exceptions and module types
EmileTrotignon Apr 25, 2023
55aabde
Compatible with latest odoc version
EmileTrotignon Apr 26, 2023
14b1146
Use odoc index
EmileTrotignon May 2, 2023
857994e
odoc with search integration
EmileTrotignon May 3, 2023
61c298e
package is now optionnal
EmileTrotignon May 4, 2023
567724c
format
EmileTrotignon May 4, 2023
eae585d
odoc compat : links work
EmileTrotignon May 4, 2023
a3bb78b
reogranization
EmileTrotignon May 4, 2023
2cdd2b5
char_list_map separated
EmileTrotignon May 4, 2023
d3bb61b
Adds type based search of constructors and fields
EmileTrotignon May 10, 2023
fa59ab8
Print types
EmileTrotignon May 10, 2023
27faf9b
REfactoring + new sorting system
EmileTrotignon May 15, 2023
0820ee8
Take name length into account to sort results
EmileTrotignon May 15, 2023
88e8e7a
add support to print typedecl (with a hack)
EmileTrotignon May 16, 2023
e71ce73
Remove useless html from search results
EmileTrotignon May 22, 2023
a52a337
add tests
EmileTrotignon May 22, 2023
a58f0d6
Index now binds to odoc instead of having to call it first.
EmileTrotignon May 23, 2023
d665c8b
Compatibilty with odoc 89175b19aeae7e181fd46ce6f74b643367713cfb
EmileTrotignon May 24, 2023
3fafe4a
add size options and size tests
EmileTrotignon May 26, 2023
bf1befa
payloads completely empty (broken)
EmileTrotignon May 30, 2023
8e48c8a
index uses arrays instead of sets
EmileTrotignon May 30, 2023
bae317b
Shares submaps for a big size reduction
EmileTrotignon Jun 2, 2023
19ce128
Uses the browser's decompress api
EmileTrotignon Jun 2, 2023
4d02477
Query uses arrays.
EmileTrotignon Jun 5, 2023
61c2b83
Query arrays directly
EmileTrotignon Jun 5, 2023
e4c6138
Restore static order
EmileTrotignon Jun 5, 2023
dcaa254
Cleanup
EmileTrotignon Jun 6, 2023
05e4211
flat directory hierarchy
art-w Jun 7, 2023
6e1bfc9
restore website
art-w Jun 7, 2023
c73f771
precompute static score
art-w Jun 7, 2023
a5c29f3
add missing dune files
art-w Jun 8, 2023
d5e88e0
Better performance for cache
EmileTrotignon Jun 6, 2023
0a955ff
Remove json_display
EmileTrotignon Jun 8, 2023
f2eb565
sorting ajustments
EmileTrotignon Jun 8, 2023
eca30d9
Sherldoc now has a cli interface
EmileTrotignon Jun 12, 2023
9c15dea
ignore perf data
EmileTrotignon Jun 12, 2023
9f58218
Tests order
EmileTrotignon Jun 13, 2023
d204bf4
CLI : database can be provided as an environment variable
EmileTrotignon Jun 13, 2023
cf3be18
UI update
EmileTrotignon Jun 16, 2023
5fd47a4
sort improvement
EmileTrotignon Jun 16, 2023
15443cb
format
EmileTrotignon Jun 16, 2023
caaf3d2
Trie.find is allowed not to find anything
EmileTrotignon Jun 16, 2023
ad8445e
Tests update
EmileTrotignon Jun 16, 2023
1983d35
remove unwanted printing
EmileTrotignon Jun 16, 2023
9a49ebe
Returns results before type name is complete
EmileTrotignon Jun 19, 2023
d0a258e
Add support for typed search of extension constructors
EmileTrotignon Jun 20, 2023
c842e03
add new suffix tree algorithm
art-w Jun 20, 2023
d4f6c26
Remove Hocc to fix bug regarding occurence higher than 1
EmileTrotignon Jun 21, 2023
b039c45
WIP integrate suffix_tree
EmileTrotignon Jun 21, 2023
66d6107
Bugfix
EmileTrotignon Jun 21, 2023
d6a5912
cleanup
art-w Jun 25, 2023
2cda1ab
tokenize docstring
art-w Jun 25, 2023
7fe9635
db without storage functor
art-w Jun 25, 2023
0e55336
remove index_lib
art-w Jun 25, 2023
56355c0
fix suffix_tree elt equality
art-w Jun 25, 2023
528fea6
add weird sorting test
art-w Jun 25, 2023
1adf050
Does not stackoverflow on the browser
EmileTrotignon Jun 26, 2023
c3367e5
Add deleted tests back
EmileTrotignon Jun 27, 2023
9eadd69
Use rev_map instead of trmc
EmileTrotignon Jun 27, 2023
5efb48d
Occ is abstract
EmileTrotignon Jun 27, 2023
2d8546c
format
EmileTrotignon Jun 27, 2023
58c09c1
format
EmileTrotignon Jun 27, 2023
a9465dc
Bugfix in Succ and make it polymorphic
EmileTrotignon Jun 28, 2023
8728bd4
Adds new test : cli and Succ
EmileTrotignon Jun 28, 2023
f9370af
Make length more important for static cost
EmileTrotignon Jun 28, 2023
e7ceb43
Typo in comment
EmileTrotignon Jun 28, 2023
45c97c8
Add options for testing the static order
EmileTrotignon Jun 28, 2023
4487ea3
Format
EmileTrotignon Jun 28, 2023
6d3608a
temp commit
EmileTrotignon Jun 28, 2023
1dfb39f
Fix prefixname
EmileTrotignon Jul 5, 2023
5321a8e
Type search of exceptions
EmileTrotignon Jul 5, 2023
b74c748
Succ bugfix and better testing
EmileTrotignon Jul 5, 2023
571a01f
format
EmileTrotignon Jul 5, 2023
e83d176
Succ cleanup
EmileTrotignon Jul 6, 2023
1a31504
Cleanup query api
EmileTrotignon Jul 7, 2023
9fe953d
Pass id to entries_of_item
trefis Jul 13, 2023
3fb1411
pretty: fix build, does this module make sense?
trefis Jul 13, 2023
ad04241
WIP compatibility with odoc PR
EmileTrotignon Jul 17, 2023
1e1d1d0
no titles for doc comments
EmileTrotignon Aug 25, 2023
0377e15
Fixes the name of the generated js object of an entry
EmileTrotignon Aug 28, 2023
d9cfda1
New odocls for the base test
EmileTrotignon Aug 28, 2023
4fea97b
Compatibility with odoc cleanup
EmileTrotignon Aug 31, 2023
8b720de
typedecl params are now printed in search results
EmileTrotignon Aug 31, 2023
953cd1f
compatibility with last odoc renaming
EmileTrotignon Sep 7, 2023
6871b21
compatibility with odoc refactoring
EmileTrotignon Sep 7, 2023
8affd98
newlines in cli output
EmileTrotignon Oct 16, 2023
45ef0de
comments and format
EmileTrotignon Oct 17, 2023
ca3eac8
odoc compatibility
EmileTrotignon Oct 24, 2023
cc414ae
fix compilation with tyxml.4.6.0
Khady Oct 27, 2023
5c2c082
removes syntax error
EmileTrotignon Nov 24, 2023
9df6bad
add limit
EmileTrotignon Nov 24, 2023
af73e4a
Just to compile still needs to fix
EmileTrotignon Nov 24, 2023
71429f5
Better error message
EmileTrotignon Nov 24, 2023
ca33a60
install sherlodoc.js
EmileTrotignon Nov 24, 2023
a533e23
I am not sure about this one
EmileTrotignon Nov 24, 2023
ac8556d
wip fix opam dependencies
art-w Nov 24, 2023
23520a8
update tyxml
EmileTrotignon Dec 1, 2023
ae7b10f
remove print and whitespaces
EmileTrotignon Dec 1, 2023
3150a5c
fix tests
EmileTrotignon Dec 1, 2023
5d50cda
add dependencies to opam file
EmileTrotignon Dec 4, 2023
c8aeb6b
add dependency bounds to opam file
EmileTrotignon Dec 4, 2023
6c6dda7
fix extensiondecl case in pretty
EmileTrotignon Dec 4, 2023
4ad17fa
fmt
EmileTrotignon Dec 4, 2023
762cd32
test on switch
EmileTrotignon Dec 4, 2023
b6849e8
update readme
EmileTrotignon Dec 4, 2023
cafb613
whole switch test fix
EmileTrotignon Dec 4, 2023
366ea17
readme improvement
EmileTrotignon Dec 4, 2023
d742a1e
module type entrie have less priority
EmileTrotignon Dec 7, 2023
8939f75
functor
EmileTrotignon Dec 7, 2023
112d32d
readme update
EmileTrotignon Dec 7, 2023
72d7955
readme update
EmileTrotignon Dec 7, 2023
8602308
readme update
EmileTrotignon Dec 12, 2023
4c86eed
better output flag
EmileTrotignon Dec 12, 2023
34e1964
sort test
EmileTrotignon Dec 12, 2023
8c17c81
typedecl params in cli
EmileTrotignon Dec 12, 2023
74c2ed6
simpler interface for succ
EmileTrotignon Dec 12, 2023
4841740
reafctoring and comments
EmileTrotignon Dec 12, 2023
1bec9c5
document dune files
EmileTrotignon Dec 12, 2023
7d318c1
better readme
EmileTrotignon Dec 12, 2023
2945002
add temporary review file
EmileTrotignon Dec 12, 2023
919ad33
better index cli
EmileTrotignon Dec 12, 2023
69b8636
review update
EmileTrotignon Dec 12, 2023
f1cc332
ancient support !
EmileTrotignon Dec 12, 2023
5bbe1fb
Remove Succ.all
EmileTrotignon Dec 13, 2023
4ed6dee
catch all is at jsoo level
EmileTrotignon Dec 13, 2023
abdf7f1
suffix_trie collapse gives a tree
EmileTrotignon Dec 13, 2023
427bb54
fix succ.all removal
EmileTrotignon Dec 13, 2023
4392107
tree leafs for types
EmileTrotignon Dec 13, 2023
863e517
parser/lexer are documented
EmileTrotignon Dec 13, 2023
4777e8c
update review.md
EmileTrotignon Dec 13, 2023
094ac1d
wip refactoring of type paths
EmileTrotignon Dec 13, 2023
fed7a85
review discussions
EmileTrotignon Dec 14, 2023
7fc9556
exceptions bugfix typepath refactoring wip again
EmileTrotignon Dec 14, 2023
1f7e057
cache typeexprs
EmileTrotignon Dec 14, 2023
76554df
cleanup in pretty
EmileTrotignon Dec 14, 2023
4c58e55
refactoring and documentation
EmileTrotignon Dec 15, 2023
7344ec7
score to cost refactoring
EmileTrotignon Dec 15, 2023
5d1af00
opam deps : search odoc
EmileTrotignon Dec 15, 2023
9398d01
installation instruction in readme
EmileTrotignon Dec 15, 2023
30e1fe7
bugfixes, and changes
EmileTrotignon Dec 18, 2023
bc5ff03
remove pretty from api
EmileTrotignon Dec 18, 2023
270a266
update review to be constitant with previous commit
EmileTrotignon Dec 18, 2023
0ed3599
new recursive descent parser
EmileTrotignon Dec 18, 2023
24879e3
fix tests
EmileTrotignon Dec 18, 2023
1d03b3e
new parser works on partial queries
EmileTrotignon Dec 18, 2023
1dce474
better type parser tests
EmileTrotignon Dec 19, 2023
fd308b8
better tests
EmileTrotignon Dec 19, 2023
37e7ebf
bigger size tests
EmileTrotignon Dec 19, 2023
97e2eb1
delete useless files from jsoo
EmileTrotignon Dec 19, 2023
98d1e91
separate tests on base
EmileTrotignon Dec 19, 2023
fa17340
restore menhir parser and handle _ -> int
EmileTrotignon Dec 19, 2023
a06ecb5
improve tests
EmileTrotignon Dec 19, 2023
bfd9a22
review update
EmileTrotignon Dec 19, 2023
abf85e8
review : moving todo to top
EmileTrotignon Dec 19, 2023
d223d60
update readme and resotr compat with last dune rules commit
EmileTrotignon Dec 19, 2023
514a67f
remove unused dependencies
art-w Dec 21, 2023
b9bb6a2
upgrade ocamlformat
art-w Dec 21, 2023
96f325b
refactor db storage with/without ancient dependency
art-w Dec 21, 2023
412a1d7
simplify Db.Entry
art-w Dec 21, 2023
cdfb34d
simplify index typename
art-w Dec 21, 2023
194a4f5
fix ancient segfaults on empty strings / arrays
art-w Dec 29, 2023
a4f0173
remove db_typedef
art-w Dec 29, 2023
b38af8a
fix menhir conflicts
art-w Dec 30, 2023
53c96b1
fix candidate sorting
art-w Jan 2, 2024
12b0296
simplify indexing
art-w Jan 2, 2024
11102a3
single command
art-w Jan 2, 2024
a93155f
optional dependency to dream
art-w Jan 3, 2024
0115e95
fix cmdliner db argument
art-w Jan 3, 2024
abfbdbe
guess db_format from filename extension
art-w Jan 3, 2024
d16f726
interactive cli with colors
art-w Jan 3, 2024
ad6b9d7
allow search with incomplete type names
art-w Jan 3, 2024
3698993
simplify type occurrences
art-w Jan 3, 2024
91c2b04
sort suffix trie children
art-w Jan 8, 2024
62e529a
remove functor from suffix tree and split construction/usage
art-w Jan 9, 2024
b51e61d
optimize search for short queries
art-w Jan 9, 2024
0182637
simplify succ
art-w Jan 10, 2024
ec04144
refactor parts of query
art-w Jan 10, 2024
515b469
fetch more results to improve sort quality
art-w Jan 11, 2024
694c7b0
remove dependency to re,tyxml for smaller sherlodoc.js
art-w Jan 11, 2024
e9f6151
remove dependency to storage_js for smaller sherlodoc.js
art-w Jan 11, 2024
7263e77
move indexing specific code away from db
art-w Jan 11, 2024
8a3018b
remove dependency to printf for smaller sherlodoc.js
art-w Jan 11, 2024
fe52752
fix missing www static files
art-w Jan 3, 2024
496d16b
add cli command to produce sherlodoc.js for dune/odoc integration
art-w Jan 12, 2024
99aec73
lower ocaml version requirement to 4.08
art-w Jan 12, 2024
a0f215c
fix memory leaks
art-w Jan 13, 2024
ff9e9d2
improve fuzzy type search
art-w Jan 13, 2024
819ca4d
index types in lowercase
art-w Jan 13, 2024
26c6ba1
avoid indexing doc paragraphs and functor parameters
art-w Jan 13, 2024
a868412
optimize succ
art-w Jan 14, 2024
2a73215
fix sorting heuristics
art-w Jan 14, 2024
6850f59
prefer names that match query words in order
art-w Jan 15, 2024
c14665a
remove unused array_succ
art-w Jan 15, 2024
beb8c3d
fix jsoo odoc_html_frontend leading dot
art-w Jan 15, 2024
b7a87cf
Update type_polarity.mli comment
EmileTrotignon Jan 15, 2024
4200c91
remove fullfilled todo
EmileTrotignon Jan 16, 2024
ce7a0de
fixes and test empty project bug
EmileTrotignon Jan 16, 2024
421ab5e
delete odocls and use odig instead
EmileTrotignon Jan 16, 2024
fc53742
delete review.md
EmileTrotignon Jan 17, 2024
df8b04d
update readme
EmileTrotignon Jan 17, 2024
bb6d459
updates polarity mli comment
EmileTrotignon Jan 18, 2024
106f8e7
performances and bugs fix thanks to voodoo testing
art-w Jan 16, 2024
a1f640d
Merge pull request #5 from Khady/louis/tyxml460
art-w Jan 30, 2024
a4ee03d
Merge branch 'master' into jsoo
art-w Jan 30, 2024
8b91535
fix missing sort on suffix tree terminals
art-w Jan 30, 2024
cba8ade
fix ancient segfault on empty suffix tree
art-w Jan 30, 2024
1b39bd2
test ancient on empty databases
EmileTrotignon Jan 30, 2024
5193f8a
test dont fail when ancient is absent
EmileTrotignon Jan 30, 2024
20c479f
attempt at testing sherlodoc.js size in ci compatible way
EmileTrotignon Jan 31, 2024
3a35e1a
tighten static test enabling
EmileTrotignon Jan 31, 2024
957f20d
remove unreliable test
EmileTrotignon Jan 31, 2024
65d3761
fix jsoo version in static size test
EmileTrotignon Jan 31, 2024
3570369
base web test is now static
EmileTrotignon Jan 31, 2024
46b2ab0
sort ls output in cram test
EmileTrotignon Jan 31, 2024
17fb107
remove odocl size from cli tests
EmileTrotignon Jan 31, 2024
aef5b5c
Fast tests on base (#7)
EmileTrotignon Jan 31, 2024
38b494b
remove deps from odig docs build
EmileTrotignon Jan 31, 2024
757ad2b
fix CI for various architectures (#10)
art-w Feb 1, 2024
088cede
Merge pull request #4 from art-w/jsoo
art-w Feb 2, 2024
51db06c
add --version to sherlodoc (0.2)
EmileTrotignon Feb 5, 2024
d71cbf2
Merge pull request #18 from EmileTrotignon/version-flag
art-w Feb 5, 2024
032c613
add option to chose a list of favored prefixes
EmileTrotignon Jan 30, 2024
db629c5
add file level favouritism
EmileTrotignon Feb 5, 2024
b14094e
Merge pull request #15 from EmileTrotignon/stdlib_favouritism
art-w Feb 6, 2024
9b06e29
fix result version, thanks to opam CI lower bounds check
art-w Feb 2, 2024
67dd91f
prepare for release
art-w Feb 6, 2024
648c756
tests link in docstrings (#22)
EmileTrotignon Feb 6, 2024
80ded5e
remove weird warnings
EmileTrotignon Feb 6, 2024
d222c61
update readme with dune trick
EmileTrotignon Feb 6, 2024
77ecc82
Merge pull request #25 from art-w/remove_weird_warnings
art-w Feb 7, 2024
184fc92
Fix unvendorable [%blob] path
Julow Oct 4, 2024
555a4f5
Compatibility with ocaml/odoc#1177
panglesd Dec 9, 2024
271f3b9
Compatibility with ocaml/odoc#1081
panglesd Dec 9, 2024
5c2e7db
Compatibility with ocaml/odoc#1242
panglesd Dec 9, 2024
358dc49
Add pretty-printer for entries
panglesd Dec 9, 2024
8f903c7
Compatibility with Odoc 3
panglesd Dec 9, 2024
2f88fa7
Do not rely on odoc's `handle_file`
panglesd Dec 9, 2024
41316e5
Promote tests changed from odoc 3 indexing
panglesd Dec 9, 2024
b1dc7a7
Promote test from odoc 3 indexing
panglesd Dec 9, 2024
451f019
Raise lower bound on odoc following update to odoc 3
panglesd Dec 9, 2024
f446b0c
Add 'vendor/sherlodoc/' from commit '77ecc829dea23a312a50a74852c32633…
Julow Dec 11, 2024
2c3a7cf
Merge commit '451f0197792836d6e5e2ad3679a040d31f4dd30e' into vendor-s…
Julow Dec 11, 2024
8087cf6
Merge commit '184fc921a4dd19c4a402d8450024e909595082ca' into vendor-s…
Julow Dec 11, 2024
e4d74a6
Set Dune rules and Opam dependencies
Julow Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
(progn
(bash "diff doc/driver.mld doc/driver.mld.corrected >&2 || true")
(cat doc/driver-benchmarks.json))))

(vendored_dirs vendor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to consider sherlodoc as vendored: we want the tests to be run, the warnings to be displayed, ...

4 changes: 4 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@
(cram enable)

(using mdx 0.3)

; Sherlodoc
(using menhir 2.1)
(using directory-targets 0.1)
14 changes: 13 additions & 1 deletion odoc-parser.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ depends: [
"dune" {>= "3.7"}
"ocaml" {>= "4.02.0" & < "5.4"}
"astring"
"result"
"result" {>= "1.5"}
"camlp-streams"
"ppx_expect" {with-test}
("ocaml" {< "4.04.1" & with-test} | "sexplib0" {with-test})
# Dependencies for sherlodoc:
"base64" {>= "3.5.1"}
"bigstringaf" {>= "0.9.1"}
"js_of_ocaml" {>= "5.6.0"}
"brr" {>= "0.0.6"}
"cmdliner" {>= "1.2.0"}
"decompress" {>= "1.5.3"}
"fpath" {>= "0.7.3"}
"lwt" {>= "5.7.0"}
"menhir" {>= "20230608"}
"ppx_blob" {>= "0.7.2"}
"tyxml" {>= "4.6.0"}
]
build: [
["dune" "subst"] {dev}
Expand Down
3 changes: 2 additions & 1 deletion src/driver/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(package odoc-driver)
(link_deps
(package odoc)
(package odoc-md))
(package odoc-md)
%{bin:sherlodoc})
(preprocess
(pps ppx_sexp_conv))
(libraries
Expand Down
21 changes: 21 additions & 0 deletions vendor/sherlodoc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa

.merlin
*.install
*.coverage
*.sw[lmnop]

_build/
_doc/
_coverage/
_opam/
**/perf.data
**/perf.data.old
9 changes: 9 additions & 0 deletions vendor/sherlodoc/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 0.26.1
profile = janestreet
let-binding-spacing = compact
sequence-style = separator
doc-comments = after-when-possible
exp-grouping = preserve
break-cases = toplevel
cases-exp-indent = 4
cases-matching-exp-indent = normal
6 changes: 6 additions & 0 deletions vendor/sherlodoc/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ocaml.sandbox": {
"kind": "opam",
"switch": "sherlodoc"
}
}
21 changes: 21 additions & 0 deletions vendor/sherlodoc/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Arthur Wendling, Tarides

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
91 changes: 91 additions & 0 deletions vendor/sherlodoc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
**Try it online at [doc.sherlocode.com](https://doc.sherlocode.com) !**

Sherlodoc is a search engine for OCaml documentation (inspired by [Hoogle](https://hoogle.haskell.org/)), which allows you to search through OCaml libraries by names and approximate type signatures:

- Search by name: [`list map`](https://doc.sherlocode.com/?q=list%20map)
- Search inside documentation comments: [`raise Not_found`](https://doc.sherlocode.com/?q=raise%20Not_found)
- Fuzzy type search is introduced with a colon, e.g. [`: map -> list`](https://doc.sherlocode.com/?q=%3A%20map%20-%3E%20list)
- Search by name and type with a colon separator [`Bogue : Button.t`](https://doc.sherlocode.com/?q=Bogue%20%3A%20Button.t)
- An underscore `_` can be used as a wildcard in type queries: [`(int -> _) -> list -> _`](https://doc.sherlocode.com/?q=(int%20-%3E%20_)%20-%3E%20list%20-%3E%20_)
- Type search supports products and reordering of function arguments: [`array -> ('a * int -> bool) -> array`](https://doc.sherlocode.com/?q=%3A%20array%20-%3E%20(%27a%20*%20int%20-%3E%20bool)%20-%3E%20array)

## Local usage

First, install sherlodoc and odig:

```bash
$ opam pin add 'https://github.com/art-w/sherlodoc.git' # optional

$ opam install sherlodoc odig
```

[Odig](https://erratique.ch/software/odig) can generate the odoc documentation of your current switch with:

```bash
$ odig odoc # followed by `odig doc` to browse your switch documentation
```

Which sherlodoc can then index to create a search database:

```bash
# name your sherlodoc database
$ export SHERLODOC_DB=/tmp/sherlodoc.marshal

# if you are using OCaml 4, we recommend the `ancient` database format:
$ opam install ancient
$ export SHERLODOC_DB=/tmp/sherlodoc.ancient

# index all odoc files generated by odig for your current switch:
$ sherlodoc index $(find $OPAM_SWITCH_PREFIX/var/cache/odig/odoc -name '*.odocl' | grep -v __)
```

Enjoy searching from the command-line or run the webserver:

```bash
$ sherlodoc search "map : list"
$ sherlodoc search # interactice cli

$ opam install dream
$ sherlodoc serve # webserver at http://localhost:1234
```

The different commands support a `--help` argument for more details/options.

In particular, sherlodoc supports three different file formats for its database, which can be specified either in the filename extension or through the `--db-format=` flag:
- `ancient` for fast database loading using mmap, but is only compatible with OCaml 4.
- `marshal` for when ancient is unavailable, with slower database opening.
- `js` for integration with odoc static html documentation for client-side search without a server.

## Integration with Odoc

Odoc 2.4.0 adds a search bar inside the statically generated html documentation. [Integration with dune is in progress](https://github.com/ocaml/dune/pull/9772), you can try it inside a fresh opam switch with: (warning! this will recompile any installed package that depends on dune!)

```bash
$ opam pin https://github.com/emileTrotignon/dune.git#search-odoc-new

$ dune build @doc # in your favorite project
```

Otherwise, manual integration with odoc requires to add to every call of `odoc html-generate` the flags `--search-uri sherlodoc.js --search-uri db.js` to activate the search bar. You'll also need to generate a search database `db.js` and provide the `sherlodoc.js` dependency (a version of the sherlodoc search engine with odoc support, compiled to javascript):

```bash
$ sherlodoc index --db=_build/default/_doc/_html/YOUR_LIB/db.js \
$(find _build/default/_doc/_odocls/YOUR_LIB -name '*.odocl' | grep -v __)

$ sherlodoc js > _build/default/_doc/_html/sherlodoc.js
```

## How it works

The sherlodoc database uses [Suffix Trees](https://en.wikipedia.org/wiki/Suffix_tree) to search for substrings in value names, documentation and types. During indexation, the suffix trees are compressed to state machine automatas. The children of every node are also sorted, such that a sub-tree can be used as a priority queue during search enumeration.

To rank the search results, sherlodoc computes a static evaluation of each candidate during indexation. This static scoring biases the search to favor short names, short types, the presence of documentation, etc. When searching, a dynamic evaluation dependent on the user query is used to adjust the static ordering of the results:

- How similar is the result name to the search query? (to e.g. prefer results which respect the case: [`map`](https://doc.sherlocode.com/?q=map) vs [`Map`](https://doc.sherlocode.com/?q=Map))
- How similar are the types? (using a tree diff algorithm, as for example [`('a -> 'b -> 'a) -> 'a -> 'b list -> 'a`](https://doc.sherlocode.com/?q=(%27a%20-%3E%20%27b%20-%3E%20%27a)%20-%3E%20%27a%20-%3E%20%27b%20list%20-%3E%20%27a) and [`('a -> 'b -> 'b) -> 'a list -> 'b -> 'b`](https://doc.sherlocode.com/?q=(%27a%20-%3E%20%27b%20-%3E%20%27b)%20-%3E%20%27a%20list%20-%3E%20%27b%20-%3E%20%27b) are isomorphic yet point to `fold_left` and `fold_right` respectively)

For fuzzy type search, sherlodoc aims to provide good results without requiring a precise search query, on the basis that the user doesn't know the exact type of the things they are looking for (e.g. [`string -> file_descr`](https://doc.sherlocode.com/?q=string%20-%3E%20file_descr) is incomplete but should still point in the right direction). In particular when exploring a package documentation, the common question "how do I produce a value of type `foo`" can be answered with the query `: foo` (and "which functions consume a value of type `bar`" with `: bar -> _`). This should also work when the type can only be produced indirectly through a callback (for example [`: Eio.Switch.t`](https://doc.sherlocode.com/?q=%3A%20Eio.Switch.t) has no direct constructor). To achieve this, sherlodoc performs a type decomposition based on the polarity of each term: A value produced by a function is said to be positive, while an argument consumed by a function is negative. This simplifies away the tree shape of types, allowing their indexation in the suffix trees. The cardinality of each value type is also indexed, to e.g. differentiate between [`list -> list`](https://doc.sherlocode.com/?q=list%20-%3E%20list) and [`list -> list -> list`](https://doc.sherlocode.com/?q=list%20-%3E%20list%20-%3E%20list).

While the polarity search results are satisfying, sherlodoc offers very limited support for polymorphic variables, type aliases and true type isomorphisms. You should check out the extraordinary [Dowsing](https://github.com/Drup/dowsing) project for this!

And if you speak French, a more detailed [presentation of Sherlodoc](https://www.irill.org/videos/OUPS/2023-03/wendling.html) (and [Sherlocode](https://sherlocode.com)) was given at the [OCaml Users in PariS (OUPS)](https://oups.frama.io/) in March 2023.
20 changes: 20 additions & 0 deletions vendor/sherlodoc/cli/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(ocamllex unescape)

(executable
(name main)
(public_name sherlodoc)
(package odoc-driver)
(libraries
cmdliner
index
query
db_store
unix
(select
serve.ml
from
(www -> serve.available.ml)
(!www -> serve.unavailable.ml)))
(preprocess
(pps ppx_blob))
(preprocessor_deps ../jsoo/sherlodoc.js))
83 changes: 83 additions & 0 deletions vendor/sherlodoc/cli/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
let guess_db_format db_format db_filename =
match db_format with
| Some db_format -> db_format
| None -> begin
let ext = Filename.extension db_filename in
let ext_len = String.length ext in
let ext = if ext_len = 0 then ext else String.sub ext 1 (ext_len - 1) in
try List.assoc ext Db_store.available_backends with
| Not_found ->
Format.fprintf
Format.err_formatter
"Unknown db format extension %S (expected: %s)@."
ext
(String.concat ", " @@ List.map fst Db_store.available_backends) ;
exit 1
end

open Cmdliner

let db_format =
let env =
let doc = "Database format" in
Cmd.Env.info "SHERLODOC_FORMAT" ~doc
in
let kind = Arg.enum Db_store.available_backends in
Arg.(value & opt (some kind) None & info [ "format" ] ~docv:"DB_FORMAT" ~env)

let db_filename =
let env =
let doc = "The database to query" in
Cmd.Env.info "SHERLODOC_DB" ~doc
in
Arg.(required & opt (some string) None & info [ "db"; "o" ] ~docv:"DB" ~env)

let db_path =
let env =
let doc = "The database to query" in
Cmd.Env.info "SHERLODOC_DB" ~doc
in
Arg.(required & opt (some file) None & info [ "db" ] ~docv:"DB" ~env)

let with_db fn db_path =
let apply fn db_format db_filename =
let db_format = guess_db_format db_format db_filename in
fn db_format db_filename
in
Term.(const apply $ fn $ db_format $ db_path)

let cmd_search =
let info = Cmd.info "search" ~doc:"Command-line search" in
Cmd.v info (with_db Search.term db_path)

let cmd_index =
let doc = "Index odocl files to create a Sherlodoc database" in
let info = Cmd.info "index" ~doc in
Cmd.v info (with_db Index.term db_filename)

let cmd_serve =
let doc = "Webserver interface" in
let info = Cmd.info "serve" ~doc in
Cmd.v info (with_db Serve.term db_path)

let cmd_jsoo =
let doc = "For dune/odoc integration, sherlodoc compiled as javascript" in
let info = Cmd.info "js" ~doc in
let target =
let doc = "Name of the file to create" in
Arg.(value & pos 0 string "" & info [] ~docv:"QUERY" ~doc)
in
let emit_js_dep filename =
let close, h = if filename = "" then false, stdout else true, open_out filename in
output_string h [%blob "../jsoo/sherlodoc.js"] ;
if close then close_out h
in
Cmd.v info Term.(const emit_js_dep $ target)

let cmd =
let doc = "Sherlodoc" in
let version = "0.2" in
let info = Cmd.info "sherlodoc" ~version ~doc in
Cmd.group info [ cmd_search; cmd_index; cmd_serve; cmd_jsoo ]

let () = exit (Cmd.eval cmd)
Loading
Loading