@@ -48,14 +48,21 @@ we will generate.
4848 $ odoc html-generate --search-uri fuse.js.js --search-uri index .js -o html page-page.odocl
4949 $ odoc support-files -o html
5050
51- We now focus on how to generate the index .js file. There are mainly two ways: by
52- using odoc as a library, or by using the the ` compile-index` command. This
53- command generates a json index containing all .odocl given as input, to be
54- consumed later by a search engine. If -o is not provided, the file is saved as
55- index .json.
56- Odocl files can be given either in a list (using --file-list,
57- passing a file with the list of line-separated files), or by passing directly
58- the name of the files.
51+ We now focus on how to generate the index .js file.
52+
53+ For this, we compute an index of all the values contained in a given list of
54+ odoc files, using the ` compile-index` command.
55+
56+ This command generates has two output format: a json output for consumption by
57+ external search engine, and an ` odoc` specific extension. The odoc file is
58+ meant to be consumed either by search engine written in OCaml, which would
59+ depend on ` odoc` as a library, or by ` odoc` itself to build a global index
60+ incrementally: the ` compile-index` command can take indexes as input!
61+
62+ If -o is not provided, the file is saved as index .json, or index -index .odoc if
63+ the --marshall flag is passed. Odocl files can be given either in a list (using
64+ --file-list, passing a file with the list of line-separated files), or by
65+ passing directly the name of the files.
5966
6067 $ printf " main.odocl\n page-page.odocl\n j.odocl\n " > index_map
6168 $ odoc compile-index -o index1.json --file-list index_map
@@ -74,7 +81,48 @@ Let's check that the previous commands are indeed independent:
7481 $ diff index.json index1.json
7582 $ diff index.json index2.json
7683
77- The index file contains a json array, each element of the array corresponding to
84+ Let' s now test the --marshall flag.
85+ We compare:
86+ - the result of outputing as a marshalled file, and then use that to output a json file.
87+ - Directly outputing a json file
88+
89+ $ odoc compile-index -o index -main.odoc --marshall main.odocl
90+ $ odoc compile-index -o main.json index -main.odoc
91+ $ cat main.json | jq sort | jq ' .[]' -c | sort > main1.json
92+
93+ $ odoc compile-index -o main.json main.odocl
94+ $ cat main.json | jq sort | jq ' .[]' -c | sort > main2.json
95+
96+ $ diff main1.json main2.json
97+
98+ $ odoc compile-index -o index -j.odoc --marshall j.odocl
99+ $ odoc compile-index -o j.json index -j.odoc
100+ $ cat j.json | jq sort | jq ' .[]' -c | sort > j1.json
101+
102+ $ odoc compile-index -o j.json j.odocl
103+ $ cat j.json | jq sort | jq ' .[]' -c | sort > j2.json
104+
105+ $ diff j1.json j2.json
106+
107+ $ odoc compile-index -o index -page.odoc --marshall page-page.odocl
108+ $ odoc compile-index -o page.json index -page.odoc
109+ $ cat page.json | jq sort | jq ' .[]' -c | sort > page1.json
110+
111+ $ odoc compile-index -o page.json page-page.odocl
112+ $ cat page.json | jq sort | jq ' .[]' -c | sort > page2.json
113+
114+ $ diff page1.json page2.json
115+
116+ Now, we compare the combination of the three marshalled files (index -main.odoc,
117+ index -page.odoc, index -j.odoc).
118+
119+ $ odoc compile-index -o all.json index -page.odoc index -j.odoc index -main.odoc
120+ $ cat all.json | jq sort | jq ' .[]' -c | sort > all1.json
121+
122+ $ cat index .json | jq sort | jq ' .[]' -c | sort > all2.json
123+ $ diff all1.json all2.json
124+
125+ The json index file contains a json array, each element of the array corresponding to
78126a search entry.
79127An index entry contains:
80128- an ID,
0 commit comments