Skip to content

Commit

Permalink
Added a bit of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Jul 29, 2016
1 parent a6783d4 commit c450903
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libs/ContentTypes/Markdown/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(Config $config)
}

/**
* @return array
* @return string[]
*/
public function getExtensions()
{
Expand Down
2 changes: 1 addition & 1 deletion libs/ContentTypes/Markdown/LinkRenderer.php
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 14 additions & 0 deletions libs/DauxHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public static function getTheme(Config $params, $current_url)
}

/**
* Remove all '/./' and '/../' in a path, without actually checking the path
*
* @param string $path
* @return string
*/
Expand All @@ -143,6 +145,13 @@ public static function getCleanPath($path)
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';
Expand Down Expand Up @@ -391,6 +400,11 @@ public static function charsArray()
];
}

/**
* @param string $from
* @param string $to
* @return string
*/
public static function getRelativePath($from, $to)
{
// some compatibility fixes for Windows paths
Expand Down
20 changes: 14 additions & 6 deletions libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public function processDocument(Document $document)
continue;
}

$id = $this->addId($node);

$headings[] = new Entry($node, $id);
$this->ensureHeadingHasId($node);
$headings[] = new Entry($node);
}

if (count($headings) && (count($tocs) || $this->hasAutoTOC())) {
Expand All @@ -73,14 +72,17 @@ public function processDocument(Document $document)
}
}

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
Expand Down Expand Up @@ -186,7 +188,13 @@ protected function render(array $entries)
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);
Expand Down
5 changes: 4 additions & 1 deletion libs/Format/HTML/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
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;
Expand Down Expand Up @@ -85,6 +85,9 @@ function () use ($destination) {
* 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)
{
Expand Down
2 changes: 1 addition & 1 deletion libs/Format/HTMLFile/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit c450903

Please sign in to comment.