Added a bit of documentation

This commit is contained in:
Stéphane Goetz
2016-07-29 23:46:57 +02:00
parent a6783d41e8
commit c450903b3a
6 changed files with 35 additions and 10 deletions

View File

@ -55,9 +55,8 @@ class Processor implements DocumentProcessorInterface
continue;
}
$id = $this->addId($node);
$headings[] = new Entry($node, $id);
$this->ensureHeadingHasId($node);
$headings[] = new Entry($node);
}
if (count($headings) && (count($tocs) || $this->hasAutoTOC())) {
@ -73,14 +72,17 @@ class Processor implements DocumentProcessorInterface
}
}
protected function addId(Heading $node)
/**
* @param Heading $node
*/
protected function ensureHeadingHasId(Heading $node)
{
// If the node has an ID, no need to generate it
$attributes = $node->getData('attributes', []);
if (array_key_exists('id', $attributes) && !empty($attributes['id'])) {
// TODO :: check for uniqueness
return $attributes['id'];
return;
}
// Well, seems we have to generate an ID
@ -186,7 +188,13 @@ class Processor implements DocumentProcessorInterface
return $list;
}
protected function setNull($object, $property)
/**
* Set the specified property to null on the object.
*
* @param Heading $object The object to modify
* @param string $property The property to nullify
*/
protected function setNull(Heading $object, $property)
{
$prop = new \ReflectionProperty(get_class($object), $property);
$prop->setAccessible(true);

View File

@ -4,10 +4,10 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Todaymade\Daux\Config;
use Todaymade\Daux\Console\RunAction;
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
use Todaymade\Daux\Daux;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Format\Base\LiveGenerator;
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
use Todaymade\Daux\GeneratorHelper;
use Todaymade\Daux\Tree\ComputedRaw;
use Todaymade\Daux\Tree\Directory;
@ -85,6 +85,9 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
* block-level tags to prevent word joining after tag removal.
* Also collapse whitespace to single space and trim result.
* modified from: http://nadeausoftware.com/articles/2007/09/php_tip_how_strip_html_tags_web_page
*
* @param string $text
* @return string
*/
private function strip_html_tags($text)
{