Added documentation

This commit is contained in:
Stéphane Goetz 2015-07-18 21:45:38 +02:00
parent 667747a610
commit e87c86d9aa
3 changed files with 35 additions and 11 deletions

View File

@ -9,33 +9,42 @@ class Daux
const STATIC_MODE = 'DAUX_STATIC'; const STATIC_MODE = 'DAUX_STATIC';
const LIVE_MODE = 'DAUX_LIVE'; const LIVE_MODE = 'DAUX_LIVE';
/** @var string[] */
public static $VALID_MARKDOWN_EXTENSIONS; public static $VALID_MARKDOWN_EXTENSIONS;
/** @var string */
public $local_base; public $local_base;
/** @var string */
public $internal_base; public $internal_base;
/** @var string */
private $docs_path; private $docs_path;
/** /** @var Processor */
* @var Processor
*/
protected $processor; protected $processor;
/** /** @var Tree\Root */
* @var Tree\Directory
*/
public $tree; public $tree;
/** /** @var Config */
* @var Config
*/
public $options; public $options;
/** @var string */
private $mode; private $mode;
/**
* @param string $mode
*/
public function __construct($mode) public function __construct($mode)
{ {
$this->mode = $mode; $this->mode = $mode;
$this->local_base = $this->internal_base = dirname(__DIR__); $this->local_base = $this->internal_base = dirname(__DIR__);
// In case we're inside the phar archive
// we save the path to the directory
// in which it is contained
if (defined('PHAR_DIR')) { if (defined('PHAR_DIR')) {
$this->local_base = PHAR_DIR; $this->local_base = PHAR_DIR;
} }
@ -46,6 +55,10 @@ class Daux
define("DS", DIRECTORY_SEPARATOR); define("DS", DIRECTORY_SEPARATOR);
} }
/**
* @param string $override_file
* @throws Exception
*/
public function initialize($override_file = 'config.json') public function initialize($override_file = 'config.json')
{ {
//global.json (docs dir, markdown files) //global.json (docs dir, markdown files)
@ -57,6 +70,11 @@ class Daux
$this->generateTree(); $this->generateTree();
} }
/**
* Load and validate the global configuration
*
* @throws Exception
*/
private function loadConfig() private function loadConfig()
{ {
$default_config = [ $default_config = [
@ -123,6 +141,9 @@ class Daux
} }
} }
/**
* Generate the tree that will be used
*/
private function generateTree() private function generateTree()
{ {
$this->tree = new Root($this->docs_path); $this->tree = new Root($this->docs_path);
@ -130,7 +151,7 @@ class Daux
if (!empty($this->options['languages'])) { if (!empty($this->options['languages'])) {
foreach ($this->options['languages'] as $key => $node) { foreach ($this->options['languages'] as $key => $node) {
$this->tree->getEntries()[$key]->title = $node; $this->tree->getEntries()[$key]->setTitle($node);
} }
} }
} }

View File

@ -98,7 +98,7 @@ class DauxHelper
* *
* @param Directory $tree * @param Directory $tree
* @param string $request * @param string $request
* @return Tree\Content|Tree\Raw * @return Tree\Content|Tree\Raw|false
*/ */
public static function getFile($tree, $request) public static function getFile($tree, $request)
{ {

View File

@ -9,6 +9,9 @@ class Directory extends Entry
uasort($this->children, array($this, 'compareEntries')); uasort($this->children, array($this, 'compareEntries'));
} }
/**
* @return Entry[]
*/
public function getEntries() public function getEntries()
{ {
return $this->children; return $this->children;