自动生成 PHP 文档?

发布于 2024-07-06 06:59:38 字数 1557 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

盗梦空间 2024-07-13 06:59:38

ApiGen

http://apigen.org/

ApiGen 支持 PHP 5.3 命名空间、包、文档之间的链接、对 PHP 标准类和常规的交叉引用文档、创建突出显示的源代码以及对 PHP 5.4 特性的实验性支持。

DocBlox

http://www.docblox-project.org/

PHP 5.3 兼容的 API 文档生成器,针对各种规模和连续的项目一体化。

能够完全解析和转换Zend Framework 2

ApiGen

http://apigen.org/

ApiGen has support for PHP 5.3 namespaces, packages, linking between documentation, cross referencing to PHP standard classes and general documentation, creation of highlighted source code and experimental support for PHP 5.4 traits.

DocBlox

http://www.docblox-project.org/

PHP 5.3 compatible API Documentation generator aimed at projects of all sizes and Continuous Integration.

able to fully parse and transform Zend Framework 2

思念绕指尖 2024-07-13 06:59:38

有两个众所周知且常用的工具可以从 docblocks 生成 API 文档:

  • phpDocumentor,这是特定于 PHP,可能是 PHP 项目中最常用的工具之一
  • Doxygen 更适合C,但也被一些人用于 PHP。

关于“指南”:我想说这取决于您的项目,但是,至少,我希望看到:

  • 方法/函数的参数的描述
  • ,以及参数的 @param 类型名称描述< /code>
  • 返回值,带有返回值的@return 类型描述
  • 异常,带有可以抛出的异常的@throws 类型描述

最近的 IDE 很棒(例如Eclipse PDT,可以读取和解释这些标记,在编码时提供提示;-)

此外,越来越多的 PHP 工具将 php docblocks 用于文档以外的其他目的。

例如,PHPUnit 允许您使用某些特定标签指定一些与测试相关的内容 - 请参阅 注释

There are two well-known and often-used tool that can generate API doc from docblocks :

  • phpDocumentor, which is specific to PHP, and is probably one of the most used tool for PHP projects
  • and Doxygen, which is more for C, but is used for PHP by some people.

About the "guidelines" : I would say it depends on your projects, but, at least, I would expect to see :

  • a description of what the method/function does
  • parameters, with @param type name description of the parameter
  • return value, with @return type description of the return value
  • exceptions, with @throws type description of the exception that can be thrown

A great thing being that recent IDE (like Eclipse PDT, for instance), can read and interpret those markers, to provide hints when you're coding ;-)

Also, there are more and more PHP tools that use php docblocks for some other purpose than documentation.

For instance, PHPUnit allows you to specify some test-related stuff using some specific tags -- see Annotations.

陈甜 2024-07-13 06:59:38

PHPDoc 在 Javadoc 风格的内联注释方面可能与您所得到的一样好。 您可能还想查看 PHPXRef

PHPDoc is probably as good as you'll get it in terms of Javadoc style inline commenting. You might also want to look at PHPXRef.

愿与i 2024-07-13 06:59:38

是的,phpDocumentor (http://www.phpdoc.org/) 是可接受的 PHP 自动文档标准工具。 这是事实上的标准。

在记录 PHP 代码时,遵循一般 JavaDoc 代码指南是可以接受的。 但是,您可能会遇到这样的情况:这还不够,因为 PHP 和 Java 是不同的语言。

例如,PHP 函数没有返回类型,函数不可避免地(有时是可取的)在一个上下文中返回一种类型,在第二个上下文中返回另一种类型。 JavaDoc 指南对此无济于事,因为在 Java 中这是不可能做到的。

Yes, phpDocumentor (http://www.phpdoc.org/) is an acceptable standard tool for PHP autodocs. It's the de-facto standard.

It's acceptable to follow the general JavaDoc guidelines for code when documenting PHP code. However, you're going to run into cases where that's not enough because PHP and Java are different languages.

For example, PHP functions have no return type and it's inevitable (and sometimes desirable) for a function to return one type with one context, and another type with in a second context. JavaDoc guidelines aren't going to help with that, because it's impossible to do in Java.

硪扪都還晓 2024-07-13 06:59:38

phpDocumentor 可以以类似于 php.net 文档的风格输出(并且内置 smarty 和非 smarty 布局)

phpDocumentor can output in a style similar to the php.net documentation (and its built in with both smarty and non smarty layouts)

稍尽春風 2024-07-13 06:59:38

查看 PHPDoctor http://peej.github.com/phpdoctor/,一个简单但功能齐全的 Javadoc PHP 的克隆。

Check out PHPDoctor http://peej.github.com/phpdoctor/, a simple yet full features Javadoc clone for PHP.

哎呦我呸! 2024-07-13 06:59:38

Wordpress 代码库使用 phpdoc 标签进行记录(请参阅 this),并且它通常相当不错 - 它已呈现此处使用phpDocumentor

我编写的大部分代码足够多,以至于我需要考虑自动生成文档,这些代码都是在 .Net 中完成的,因此我无法给出太多文档编写者的观点

The Wordpress code-base is documented using phpdoc tags (see this) and it's generally pretty good - it's rendered here using phpDocumentor.

Most of the code that I write that's substantial enough that I need to think about autogenerating docs for is done in .Net, so I can't give much of a documentation writer's perspective though

↘人皮目录ツ 2024-07-13 06:59:38

如果丑陋是一个问题,我只需将样式表切换为自定义样式表即可。 如果您不想覆盖生成的插件,可以使用 Firefox 插件,例如 时尚

If ugly's a problem, I'd just switch the stylesheet for a custom one. If you don't want to overwrite the generated one, you can use a Firefox plugin like Stylish.

烟酒忠诚 2024-07-13 06:59:38

您可以编辑模板文件以添加您自己的样式表来覆盖现有样式表。

You could edit the template file to add your own stylesheet to override the existing one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文