使用 PHPDoc 自动添加 Git 版本

发布于 2024-12-29 03:28:31 字数 68 浏览 4 评论 0原文

我想知道是否有人知道一种将文件/存储库的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-黛色若梦 2025-01-05 03:28:31

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.

一生独一 2025-01-05 03:28:31

您可以创建一个 phing 脚本来查找项目的最新版本。并将令牌替换为每个文件/所选文件中的版本。

例如(我在例子中使用了SVN)
在您的 phing 脚本中

获取最新的 svn 版本

<svnlastrevision workingcopy="${path.to.project.dir}" propertyname="svn.lastrevision" />

在您想要 svn 版本的文件中,放置一个名为 @svn.lastrevision@ 的令牌,

以下代码将用版本号替换此令牌

<!-- Apply the version change to all files. -->
        <reflexive>
            <fileset dir="${dir.to.change.version}">
                 <include name="**/*.*" />
            </fileset>
             <filterchain>
                <replacetokens>
                    <token key="svn.lastrevision" value="${svn.lastrevision}" />
                </replacetokens>
            </filterchain>
        </reflexive>

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

<svnlastrevision workingcopy="${path.to.project.dir}" propertyname="svn.lastrevision" />

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

<!-- Apply the version change to all files. -->
        <reflexive>
            <fileset dir="${dir.to.change.version}">
                 <include name="**/*.*" />
            </fileset>
             <filterchain>
                <replacetokens>
                    <token key="svn.lastrevision" value="${svn.lastrevision}" />
                </replacetokens>
            </filterchain>
        </reflexive>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文