Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/PatternLab/PatternData/Rules/DocumentationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use \PatternLab\PatternData;
use \PatternLab\Parsers\Documentation;
use \PatternLab\Timer;
use \PatternLab\Data;

class DocumentationRule extends \PatternLab\PatternData\Rule {

Expand Down Expand Up @@ -49,7 +50,6 @@ public function run($depth, $ext, $path, $pathName, $name) {

// parse data
$text = file_get_contents($patternSourceDir.DIRECTORY_SEPARATOR.$pathName);
list($yaml,$markdown) = Documentation::parse($text);

// grab the title and unset it from the yaml so it doesn't get duped in the meta
if (isset($yaml["title"])) {
Expand All @@ -73,6 +73,20 @@ public function run($depth, $ext, $path, $pathName, $name) {

$category = ($patternSubtypeDoc) ? "patternSubtype" : "pattern";
$patternStoreKey = ($patternSubtypeDoc) ? $docPartial."-plsubtype" : $docPartial;

//Setup the Pattern Loader so we can pre-render template markup used in our markdown files, prior to being rendered in Markdown.
$patternEngineBasePath = \PatternLab\PatternEngine::getInstance()->getBasePath();
$patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader";
$patternLoader = new $patternLoaderClass($options);

//Setup the default pattern data.
$data = Data::getPatternSpecificData($patternStoreKey);

//Render the markdown content as a pattern, piping in the pattern-specific data from above.
$text = $patternLoader->render(array("pattern" => $text, "data" => $data));

//Finally parse the resulting content as normal markup; continue as usual.
list($yaml,$markdown) = Documentation::parse($text);

$patternStoreData = array("category" => $category,
"desc" => trim($markdown),
Expand Down