Skip to content

Commit 0740717

Browse files
committed
Add Markdown output format for PHP documentation
1 parent 3c077f9 commit 0740717

3 files changed

Lines changed: 1585 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
namespace phpdotnet\phd;
3+
4+
class PI_MarkdownPHPDOCHandler extends PI_PHPDOCHandler {
5+
6+
protected function generateChangelogMarkup($changelogs): string {
7+
usort($changelogs, [PI_PHPDOCHandler::class, '_sortByVersion']);
8+
9+
$ret = "| Version | Function | Description |\n| --- | --- | --- |\n";
10+
$desc = "";
11+
$lastVersion = "";
12+
foreach ($changelogs as $entry) {
13+
if (!$this->_changelogSince || version_compare($entry["version"], $this->_changelogSince) >= 0) {
14+
$link = $this->format->createLink($entry["docbook_id"], $desc);
15+
$version = ($entry["version"] === $lastVersion) ? "" : $entry["version"];
16+
$description = html_entity_decode($entry["description"], ENT_QUOTES | ENT_HTML5, 'UTF-8');
17+
$description = preg_replace('/\s+/', ' ', trim($description));
18+
$description = str_replace('|', '\\|', $description);
19+
$ret .= sprintf("| %s | [%s](%s) | %s |\n", $version, $desc, $link, $description);
20+
$lastVersion = $entry["version"];
21+
}
22+
}
23+
$this->_changelogSince = null;
24+
return $ret;
25+
}
26+
}

phpdotnet/phd/Package/PHP/Factory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Package_PHP_Factory extends Format_Factory {
1313
'tocfeed' => 'Package_PHP_TocFeed',
1414
'epub' => 'Package_PHP_Epub',
1515
'enhancedchm' => 'Package_PHP_EnhancedCHM',
16+
'markdown' => 'Package_PHP_Markdown',
1617
);
1718

1819
/**

0 commit comments

Comments
 (0)