使用 PHPDoc 自动添加 Git 版本
我想知道是否有人知道一种将文件/存储库的 Git 版本插入注释块的方法,以便 PHP Doc 在生成文档时可以自动反映它?
I was wondering if anyone might know of a way to insert the Git version for a file / repository to a comment block so PHP Doc can automatically reflect it when generating documentation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
phpDocumentor 并不是将该信息放入文档中的原因...它必须已经出现在您的文档块中。
听起来您似乎习惯在文档块中包含 $Id$ 标签,当您查看代码时,CVS 和 SVN 会自动填充这些标签......又名“关键字扩展”。
Git 确实允许这样做 - https://git -scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion。
phpDocumentor is not what puts that info into the docs... it would have to appear in your docblock already.
It sounds like you're used to having $Id$ tags in your docblocks, that get populated automatically by CVS and SVN when you check out the code... aka "Keyword Expansion".
Git does allow for that -- https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion.
您可以创建一个 phing 脚本来查找项目的最新版本。并将令牌替换为每个文件/所选文件中的版本。
例如(我在例子中使用了SVN)
在您的 phing 脚本中
获取最新的 svn 版本
在您想要 svn 版本的文件中,放置一个名为
@svn.lastrevision@
的令牌,以下代码将用版本号替换此令牌
You can create a phing script which will find the latest version of your project. And replace a token with the version in each file/selected files.
For example (I have used SVN in example)
in you phing script
to get latest svn version
In your files where you want to svn version, put a token with name
@svn.lastrevision@
following code will replace this token with version number