@@ -249,17 +249,40 @@ protected function writeJsonIndex() {
249249 json_encode ($ descriptions )
250250 );
251251 $ this ->outputHandler ->v ("Index written " , VERBOSE_FORMAT_RENDERING );
252+
253+ $ entries = $ this ->processCombinedJsonIndex ();
254+ file_put_contents (
255+ $ this ->getOutputDir () . "search-combined.json " ,
256+ json_encode ($ entries )
257+ );
258+ $ entries = 'var localSearchIndexes = ' . json_encode ($ entries ) .'; ' ;
259+ file_put_contents (
260+ $ this ->getOutputDir () . "search-combined.js " ,
261+ $ entries
262+ );
263+ $ this ->outputHandler ->v ("Combined Index written " , VERBOSE_FORMAT_RENDERING );
252264 }
253265
254266 /**
255267 * Processes the index to extract entries and descriptions. These are
256268 * used to generate the search index and the descriptions JSON files.
257269 */
258270 private function processJsonIndex (): array {
271+ $ alwaysIncludeElements = [
272+ 'refentry ' ,
273+ 'stream_wrapper ' ,
274+ 'phpdoc:classref ' ,
275+ 'phpdoc:exceptionref ' ,
276+ 'phpdoc:varentry ' ,
277+ ];
278+
259279 $ entries = [];
260280 $ descriptions = [];
261281 foreach ($ this ->indexes as $ id => $ index ) {
262- if (!$ index ["chunk " ]) {
282+ if (
283+ (! $ index ['chunk ' ])
284+ && (! in_array ($ index ['element ' ], $ alwaysIncludeElements , true ))
285+ ) {
263286 continue ;
264287 }
265288
@@ -281,6 +304,80 @@ private function processJsonIndex(): array {
281304 return [$ entries , $ descriptions ];
282305 }
283306
307+ private function processCombinedJsonIndex (): array
308+ {
309+ $ alwaysIncludeElements = [
310+ 'refentry ' ,
311+ 'stream_wrapper ' ,
312+ 'phpdoc:classref ' ,
313+ 'phpdoc:exceptionref ' ,
314+ 'phpdoc:varentry ' ,
315+ ];
316+
317+ $ entries = [];
318+ $ indexes = $ this ->indexRepository ->getIndexesWithDuplicates ();
319+ foreach ($ indexes as $ index ) {
320+ if (
321+ (! $ index ['chunk ' ])
322+ && (! in_array ($ index ['element ' ], $ alwaysIncludeElements , true ))
323+ ) {
324+ continue ;
325+ }
326+
327+ if ($ index ["sdesc " ] === "" && $ index ["ldesc " ] !== "" ) {
328+ $ index ["sdesc " ] = $ index ["ldesc " ];
329+ $ bookOrSet = $ this ->findParentBookOrSet ($ index ['parent_id ' ]);
330+ if ($ bookOrSet ) {
331+ $ index ["ldesc " ] = Format::getLongDescription (
332+ $ bookOrSet ['docbook_id ' ]
333+ );
334+ }
335+ }
336+
337+ $ nameParts = explode (':: ' , $ index ['sdesc ' ]);
338+ $ methodName = array_pop ($ nameParts );
339+
340+ if (str_contains ('wrapper ' , $ index ['filename ' ])) {
341+ print "Combined index: adding " . $ index ['filename ' ] . " :: " . $ index ['sdesc ' ] . "\n" ;
342+ }
343+
344+ $ type = 'General ' ;
345+ switch ($ index ['element ' ]) {
346+ case "phpdoc:varentry " :
347+ $ type = "Variable " ;
348+ break ;
349+
350+ case "refentry " :
351+ $ type = "Function " ;
352+ break ;
353+
354+ case "phpdoc:exceptionref " :
355+ $ type = "Exception " ;
356+ break ;
357+
358+ case "phpdoc:classref " :
359+ $ type = "Class " ;
360+ break ;
361+
362+ case "set " :
363+ case "book " :
364+ case "reference " :
365+ $ type = "Extension " ;
366+ break ;
367+ }
368+
369+ $ entries [] = [
370+ 'id ' => $ index ['filename ' ],
371+ 'name ' => $ index ['sdesc ' ],
372+ 'description ' => html_entity_decode ($ index ['ldesc ' ]),
373+ 'tag ' => $ index ['element ' ],
374+ 'type ' => $ type ,
375+ 'methodName ' => $ methodName ,
376+ ];
377+ }
378+ return $ entries ;
379+ }
380+
284381 /**
285382 * Finds the closest parent book or set in the index hierarchy.
286383 */
0 commit comments