使用PHPDoc自动添加Git版本

时间:2022-11-05 15:31:51

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?

我想知道是否有人可能知道将文件/存储库的Git版本插入注释块的方法,以便PHP Doc可以在生成文档时自动反映它?

2 个解决方案

#1


1  

phpDocumentor is not what puts that info into the docs... it would have to appear in your docblock already.

phpDocumentor不是将这些信息放入文档的内容......它必须已经出现在你的文档块中。

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".

听起来你已经习惯在你的docblock中拥有$ Id $标签,当你查看代码时,CVS和SVN会自动填充...也就是“Keyword Expansion”。

Git does allow for that -- https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion.

Git允许这样做 - https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion。

#2


0  

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.

您可以创建一个phing脚本,它将找到项目的最新版本。并使用每个文件/所选文件中的版本替换令牌。

For example (I have used SVN in example) in you phing script

例如(我在示例中使用了SVN)你的脚本

to get latest svn version

获取最新的svn版本

<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@

在你想要svn版本的文件中,输入一个名为@ 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>

#1


1  

phpDocumentor is not what puts that info into the docs... it would have to appear in your docblock already.

phpDocumentor不是将这些信息放入文档的内容......它必须已经出现在你的文档块中。

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".

听起来你已经习惯在你的docblock中拥有$ Id $标签,当你查看代码时,CVS和SVN会自动填充...也就是“Keyword Expansion”。

Git does allow for that -- https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion.

Git允许这样做 - https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion。

#2


0  

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.

您可以创建一个phing脚本,它将找到项目的最新版本。并使用每个文件/所选文件中的版本替换令牌。

For example (I have used SVN in example) in you phing script

例如(我在示例中使用了SVN)你的脚本

to get latest svn version

获取最新的svn版本

<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@

在你想要svn版本的文件中,输入一个名为@ 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>