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

@ -18,7 +18,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
}
/**
* @return array
* @return string[]
*/
public function getExtensions()
{

View File

@ -1,7 +1,7 @@
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
use League\CommonMark\HtmlElement;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Link;
use Todaymade\Daux\Config;

View File

@ -121,6 +121,8 @@ class DauxHelper
}
/**
* Remove all '/./' and '/../' in a path, without actually checking the path
*
* @param string $path
* @return string
*/
@ -143,6 +145,13 @@ class DauxHelper
return implode(DIRECTORY_SEPARATOR, $absolutes);
}
/**
* Get the possible output file names for a source file.
*
* @param Config $config
* @param string $part
* @return string[]
*/
public static function getFilenames(Config $config, $part)
{
$extensions = implode('|', array_map('preg_quote', $config['valid_content_extensions'])) . '|html';
@ -391,6 +400,11 @@ class DauxHelper
];
}
/**
* @param string $from
* @param string $to
* @return string
*/
public static function getRelativePath($from, $to)
{
// some compatibility fixes for Windows paths

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)
{

View File

@ -3,8 +3,8 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Todaymade\Daux\Console\RunAction;
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
use Todaymade\Daux\Daux;
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
class Generator implements \Todaymade\Daux\Format\Base\Generator
{