【问题标题】:Is there a correct way to signal an annotation parser to ignore an annotation inside of a docblock?是否有正确的方法来指示注释解析器忽略文档块内的注释?
【发布时间】:2012-07-29 13:33:29
【问题描述】:

假设我有一个 docblock 注释,该注释由例如缘故,phpDocumentor 和任何注释解析器(比如说 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 注释在默认情况下被解析,除非用户希望它被解析......显然我可以做任何事情来阻止它:将它存储在手册页中而不是内联,将其放在非 docblock 注释等中。

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

【问题讨论】:

    标签: php annotations phpdoc


    【解决方案1】:

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

    如果你想创建一个这样的注释的“永久列表”以被忽略,你最好的选择是一个自定义配置文件,你在运行 phpDocumentor 时总是使用它。您可以构建一个不断增长的注释标签列表,以被所有使用配置文件的 phpDocumentor 运行忽略。

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

    【讨论】:

    • 我一定没有看到您的需求。您希望这些注释不会在您生成的文档中显示为通用的“自定义”标签吗?还是您指的是其他一些 docblock 用例?
    • 我指的是 Doctrine Common 和其他注释解析库使用的注释。
    • 是的,我得到了那部分 ;-) ,这是您关心的注释。这就是您希望他们忽略的内容/位置,我一定无法理解。我以为你的意思是“当我运行 phpDocumentor 时,我希望忽略这些注释,而不是让它们出现在我生成的文档中,就好像它们是实际的文档标签一样”。嗯,“任何注释解析器(比如说 Doctrine common)”......是在文件的 PHP runtime 期间使用的东西吗?
    • 啊,那我们现在不在我的估计范围内了 ;-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-29
    • 2012-10-22
    • 2016-08-10
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多