我用 C 编写了一个 PHP 扩展,我想创建 PHPdoc文档,以便我的用户在调用我的扩展时将在他们的 PHP IDE(在本例中为 Netbeans)中获得内联文档。
理想情况下,我希望通过在 C 代码中嵌入 PHPdocs 来实现这一点,以便将实现和文档放在一起。
假设可以将 PHPdocs 嵌入到 C 中,需要哪些额外步骤才能使文档出现在 Netbeans 中(就像 PHP 代码的 PHPdocs 一样)?
编辑:
O'Reilly Programming PHP指的是文档生成中使用的 /* {{{ proto
注释格式,尽管我不确定所引用的脚本是否生成 PHPdocs:
The {{{ proto line is not only used for folding in the editor, but is also parsed by the genfunclist and genfuncsummary scripts that are part of the PHP documentation project. If you are never going to distribute your extension and have no ambitions to have it bundled with PHP, you can remove these comments.
最佳答案
一种可行的方法是使用适当的 PHPdoc 生成一个带有 stub 函数的 PHP 文件,然后不要将其包含在 PHP 应用程序中,但务必将其添加到 Netbean 的 PHP 包含路径(在 File->Project属性->PHP 包含路径
)。
这样类型完成和内联文档可以工作,但 PHP 不会被函数的多个声明所混淆。
这看起来有点 hacky,因为最好将文档与实现放在同一个文件中,但实际上这似乎是正确的方法,因为这就是内置函数和扩展的记录方式 - 参见 ~/netbeans-6.7/php1/phpstubs/phpruntime/*.php
例如:
在C文件中:
PHP_FUNCTION(myFunctionStringFunction)
{
// extension implementation
}
然后在 PHP 文件中, stub 声明:
/**
* My docs here
* @param string $myString
*/
function myFunctionStringFunction($myString)
{
die("Empty stub function for documenation purposes only. This file shouldn't be included in an app.");
}
关于php - 使用 PHPdoc 记录 PHP 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1096994/