Class yii\apidoc\helpers\ApiIndexer

Inheritanceyii\apidoc\helpers\ApiIndexer » cebe\jssearch\Indexer
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/helpers/ApiIndexer.php

ApiIndexer indexes framework API

Public Methods

Hide inherited methods

Method Description Defined By
getTokenizer() yii\apidoc\helpers\ApiIndexer

Protected Methods

Hide inherited methods

Method Description Defined By
generateFileInfo() yii\apidoc\helpers\ApiIndexer

Method Details

Hide inherited methods

generateFileInfo() protected method

protected array generateFileInfo ( $file, $contents, $basePath, $baseUrl )
$file string
$contents string
$basePath string
$baseUrl string

                protected function generateFileInfo($file, $contents, $basePath, $baseUrl)
{
    // create file entry
    if (preg_match('~<h1>(.*?)</h1>~s', $contents, $matches)) {
        $title = str_replace('&para;', '', strip_tags($matches[1]));
    } elseif (preg_match('~<title>(.*?)</title>~s', $contents, $matches)) {
        $title = strip_tags($matches[1]);
    } else {
        $title = '<i>No title</i>';
    }
    if (preg_match('~<div id="classDescription">\s*<strong>(.*?)</strong>~s', $contents, $matches)) {
        $description = strip_tags($matches[1]);
    } elseif (preg_match('~<p>(.*?)</p>~s', $contents, $matches)) {
        $description = StringHelper::truncate(strip_tags($matches[1]), 1000, '...', 'UTF-8');
    } else {
        $description = '';
    }
    return [
        'u' => $baseUrl . str_replace('\\', '/', substr($file, strlen(rtrim($basePath, '\\/')))),
        't' => $title,
        'd' => $description,
    ];
}

            
getTokenizer() public method

public \cebe\jssearch\TokenizerInterface getTokenizer ( )

                public function getTokenizer()
{
    $tokenizer = parent::getTokenizer();
    if ($tokenizer instanceof StandardTokenizer) {
        // yii is part of every doc and makes weird search results
        $tokenizer->stopWords[] = 'yii';
        $tokenizer->stopWords = array_unique($tokenizer->stopWords);
    }
    return $tokenizer;
}