有没有PHP DocBlock解析器工具可用? [英] Are there any PHP DocBlock parser tools available?

查看:513
本文介绍了有没有PHP DocBlock解析器工具可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为几个项目构建一些较小规模但高度定制的文档站点。 PhpDocumentor 非常棒,但很重。我想到要调整模板,但花了几分钟时间才看出来,我决定这将会太多工作。



理想情况下,我会喜欢看到可以传递一堆文件的东西,并让它返回所有的文件,类和属性和方法,以及它们的元数据,以便我可以根据数据构建一些简单的模板。 p>

是否有任何DocBlock解析器的项目将帮助我完成这项任务,或者我是否重新开发了这个轮?

解决方案

您可以轻松地使用反思API:

  / ** 
*这是一个示例类
* /
class示例
{
/ **
*这是一个示例函数
* /
public function fn()
{
// void
}
}

$ reflector = new ReflectionClass('Example');

//获取类DocBlock
echo $ reflector-> getDocComment()

//获取方法DocBlock
$ reflector- > getMethod( 'FN') - > getDocComment();

请参阅本教程: http://www.phpriot.com/articles/reflection-api



还有一个可以解析DocBlocks的PEAR包


I would like to build some smaller scale but hightly customized documentation sites for a few projects. PhpDocumentor is pretty great but it is very heavy. I thought about trying to tweak the templates for that but after spending only a couple of minutes looking into it I decided that it would be too much work.

Ideally I'd like to see something to which I could pass a bunch of files and have it return all of the files, classes and properties and methods, along with their meta data, so that I could build out some simple templates based on the data.

Are there any DocBlock parser-only projects that will help me in this task, or am I stuck reinventing that wheel?

解决方案

You can do this easily yourself with the Reflection API:

/**
 * This is an Example class
 */
class Example
{
    /**
     * This is an example function
     */
    public function fn() 
    {
        // void
    }
}

$reflector = new ReflectionClass('Example');

// to get the Class DocBlock
echo $reflector->getDocComment()

// to get the Method DocBlock
$reflector->getMethod('fn')->getDocComment();

See this tutorial: http://www.phpriot.com/articles/reflection-api

There is also a PEAR package that can parse DocBlocks.

这篇关于有没有PHP DocBlock解析器工具可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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