是否有正确的方法来通知注释解析器忽略文档块内的注释? [英] Is there a correct way to signal an annotation parser to ignore an annotation inside of a docblock?

查看:23
本文介绍了是否有正确的方法来通知注释解析器忽略文档块内的注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 docblock 注释,例如,它被 phpDocumentor 和任何注释解析器(假设是 Doctrine common)解析.

Say I have a docblock comment that is parsed by, for example's sake, phpDocumentor and any annotation parser (let's say Doctrine common).

<?php
/**
 * @author Blah <blah@example.com>
 * Class to handle the generation of lorem ipsum text for our templates
 * To declare as a service in the DIC, __uncomment__ the following annotation
 * @DIC\Service("textgenerator.loremipsum")
 */
 class LipsumGenerator implements TextGeneratorInterface { }

现在,我不希望 @DIC\Service 注释被默认解析,除非用户希望它被解析......显然我可以做任何事情来防止它:存储它在手册页而不是内联页中,将其放在非文档块注释中,等等.

是否有一种正确且相对标准的方式来通知注释解析器内联,以忽略文档块内的注释?

Now, I don't want the @DIC\Service annotation to get parsed by default unless a user wants it parsed...obviously I could do any number things to prevent it: store it in a manual page instead of inline, put it in a non-docblock comment, etc.

Is there a correct and relatively standard way to signal an annotation parser, inline, to ignore an annotation inside of a docblock?

推荐答案

试试 --ignore-tags 参数 -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.command-line.ignore-tags

Try the --ignore-tags arg -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.command-line.ignore-tags

如果您想让此类注释的永久列表"被忽略,您最好的选择是运行 phpDocumentor 时始终使用的自定义配置文件.您可以构建一个不断增长的注释标签列表,以便所有使用该配置文件的 phpDocumentor 运行忽略.

If you want to make a "permanent list" of such annotations to be ignored, your best bet is a custom config file that you always use when running phpDocumentor. You can build a growing list of annotation tags to be ignored by all phpDocumentor runs that use the config file.

http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.config-files

这篇关于是否有正确的方法来通知注释解析器忽略文档块内的注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆