nystudio107 / changelog
此包的最新版本(0.13.0)没有可用的许可证信息。
适用于普通开发者的 http://keepachangelog.com/ 解析器
0.13.0
2020-07-03 19:23 UTC
Requires
- php: >=7.1.3
- league/commonmark: ^1.0
- symfony/css-selector: ^3.0.0
- symfony/dom-crawler: ^3.0.0
Requires (Dev)
- phpspec/phpspec: ~6
README
像专业人士一样解析变更日志
此包使得解析 keepachangelog.com 格式的变更日志变得简单
安装
composer require bramdevries/changelog
用法
解析整个变更日志
以下变更日志
# Change Log A change log for the change log parser ## 0.2.0 - 2014-11-22 ### Added * `getChanges` method to retrieve a single release ## 0.1.0 - 2014-11-22 ### Added * `getReleases` method that retrieves the releases described in a change log * `toJson` method that creates a json representation of a change log.
$parser = new Changelog\Parser(file_get_contents('CHANGELOG.md'); echo $parser->toJson();
将返回
{
"description": "A change log for the change log parser",
"releases": [
{
"name": "0.0.1",
"date": "2014-11-22",
"changes": {
"added": [
"<code>getReleases</code> method that retrieves the releases described in a change log",
"<code>toJson</code> method that creates a json representation of a change log."
]
}
}
]
}
解析单个版本号的变更日志
例如:如果你想解析以下格式的 pull request
### Added - Addition 1 - Addition 2 ### Changed - Change 1 - Change 2 ### Removed - Removal 1 - Removal 2
// Assuming $content contains the above markdown $parser = new Changelog\Parser($content); echo $parser->getChanges();
返回
{
"added": [
"Addition 1",
"Addition 2"
],
"changed": [
"Change 1",
"Change 2"
],
"removed": [
"Removal 1",
"Removal 2"
]
}