Automatically Add Git Version with PHPDoc

I was wondering if anyone could find out a way to insert a Git version for a file / repository into a comment block so that PHP Doc can automatically reflect it when creating documentation?

+4
source share
2 answers

phpDocumentor is not what puts this information in documents ... it should appear in your docblock already.

It looks like you’re used to having $ Id $ tags in your docs that are automatically populated by CVS and SVN when you check the code ... aka "Keyword Extension".

Git allows this - https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion .

+1
source

You can create a phing script that will find the latest version of your project. And replace the token with the version in each file / selected files.

For example (I used SVN in the example) in a phing script

to get the latest version of svn

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

In your files where you want the svn version, put a marker named @ svn.lastrevision@

the following code will replace this token with the 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> 
0
source

Source: https://habr.com/ru/post/1392873/


All Articles