Added a bit of documentation
This commit is contained in:
parent
a6783d41e8
commit
c450903b3a
@ -18,7 +18,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getExtensions()
|
public function getExtensions()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
||||||
|
|
||||||
use League\CommonMark\HtmlElement;
|
|
||||||
use League\CommonMark\ElementRendererInterface;
|
use League\CommonMark\ElementRendererInterface;
|
||||||
|
use League\CommonMark\HtmlElement;
|
||||||
use League\CommonMark\Inline\Element\AbstractInline;
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
use League\CommonMark\Inline\Element\Link;
|
use League\CommonMark\Inline\Element\Link;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
|
@ -121,6 +121,8 @@ class DauxHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Remove all '/./' and '/../' in a path, without actually checking the path
|
||||||
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -143,6 +145,13 @@ class DauxHelper
|
|||||||
return implode(DIRECTORY_SEPARATOR, $absolutes);
|
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)
|
public static function getFilenames(Config $config, $part)
|
||||||
{
|
{
|
||||||
$extensions = implode('|', array_map('preg_quote', $config['valid_content_extensions'])) . '|html';
|
$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)
|
public static function getRelativePath($from, $to)
|
||||||
{
|
{
|
||||||
// some compatibility fixes for Windows paths
|
// some compatibility fixes for Windows paths
|
||||||
|
@ -55,9 +55,8 @@ class Processor implements DocumentProcessorInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->addId($node);
|
$this->ensureHeadingHasId($node);
|
||||||
|
$headings[] = new Entry($node);
|
||||||
$headings[] = new Entry($node, $id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($headings) && (count($tocs) || $this->hasAutoTOC())) {
|
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
|
// If the node has an ID, no need to generate it
|
||||||
$attributes = $node->getData('attributes', []);
|
$attributes = $node->getData('attributes', []);
|
||||||
if (array_key_exists('id', $attributes) && !empty($attributes['id'])) {
|
if (array_key_exists('id', $attributes) && !empty($attributes['id'])) {
|
||||||
// TODO :: check for uniqueness
|
// TODO :: check for uniqueness
|
||||||
|
|
||||||
return $attributes['id'];
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Well, seems we have to generate an ID
|
// Well, seems we have to generate an ID
|
||||||
@ -186,7 +188,13 @@ class Processor implements DocumentProcessorInterface
|
|||||||
return $list;
|
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 = new \ReflectionProperty(get_class($object), $property);
|
||||||
$prop->setAccessible(true);
|
$prop->setAccessible(true);
|
||||||
|
@ -4,10 +4,10 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
use Todaymade\Daux\Console\RunAction;
|
use Todaymade\Daux\Console\RunAction;
|
||||||
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
|
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\DauxHelper;
|
use Todaymade\Daux\DauxHelper;
|
||||||
use Todaymade\Daux\Format\Base\LiveGenerator;
|
use Todaymade\Daux\Format\Base\LiveGenerator;
|
||||||
|
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
|
||||||
use Todaymade\Daux\GeneratorHelper;
|
use Todaymade\Daux\GeneratorHelper;
|
||||||
use Todaymade\Daux\Tree\ComputedRaw;
|
use Todaymade\Daux\Tree\ComputedRaw;
|
||||||
use Todaymade\Daux\Tree\Directory;
|
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.
|
* block-level tags to prevent word joining after tag removal.
|
||||||
* Also collapse whitespace to single space and trim result.
|
* 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
|
* 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)
|
private function strip_html_tags($text)
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\Console\RunAction;
|
use Todaymade\Daux\Console\RunAction;
|
||||||
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
|
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
|
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\ContentType;
|
||||||
|
|
||||||
class Generator implements \Todaymade\Daux\Format\Base\Generator
|
class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user