예제 #1
0
 public function verify()
 {
     $this->out("{:white}Verifying that code matches documentation signatures...{:end}");
     foreach (Code::index() as $ref => $hash) {
         if (Code::hash($ref) != $hash) {
             $this->out("{:error}Warning: {$ref} is out-of-date.{:end}");
         }
     }
     $this->out("{:white}Fin.{:end}");
 }
예제 #2
0
<?php

/**
 * Initialize code index.
 */
use lithium\core\Libraries;
use lithium\action\Dispatcher;
use lithium\console\Dispatcher as ConsoleDispatcher;
use li3_docs\extensions\docs\Code;
$filter = function ($self, $params, $chain) {
    $indexPath = Libraries::get(true, 'path') . '/resources/docs.index.json';
    if (file_exists($indexPath) && is_readable($indexPath)) {
        Code::index((array) json_decode(file_get_contents($indexPath), true));
    }
    $result = $chain->next($self, $params, $chain);
    if (($index = Code::index()) && is_array($index) && is_writable(dirname($indexPath))) {
        file_put_contents($indexPath, json_encode($index));
    }
    return $result;
};
Dispatcher::applyFilter('run', $filter);
ConsoleDispatcher::applyFilter('run', $filter);
/**
 * Setup default options:
 *
 * - `'index'` _array|void_: Allows to restrict indexing to provided set of libraries.
 *   By default all libraries registered in the application are indexed.
 * - `'categories'` _array|void_: Allows manually provide a set of category names. By
 *    default categories are extracted from all indexed libraries.
 */
Libraries::add('li3_docs', array('bootstrap' => false) + Libraries::get('li3_docs') + array('url' => '/docs', 'index' => null, 'categories' => null));