我正在将 PHP 文档与我的产品集成,因为我计划允许用户更改插件内的各种内容。
到目前为止一切顺利,我的目录中有 phpdoc .phar,我可以解析 html 文件。但我有两个问题:
这是我的代码:
/**
* Creates a custom cron schedule.
* @param array $schedules list of schedules
* @example class-wcdpue-admin.php add_filter( 'wcdpue_custom_cron_schedule', 300 ); Creates a custom cron
* @since 2.0.0
*/
public function wcdpue_custom_cron_schedule( $schedules ){
$schedules['wcdpue_cron'] = array(
'interval' => apply_filters( 'wcdpue_custom_cron_schedule', 900 ),
'display' => __( 'Every 15 Minutes' )
);
return $schedules;
}
当我检查 phpdoc 时,它显示如下:
我不确定为什么它说找不到文件,但我无法在网上找到使用此标签的示例,我希望它能显示一个带有我的使用示例的小代码框。
类文件路径是
oop/admin/class-wcdpue-admin.php
,我尝试将文档块更改为:
/**
* Creates a custom cron schedule.
* @param array $schedules list of schedules
* @example /admin/class-wcdpue-admin.php add_filter( 'wcdpue_custom_cron_schedule', 300 ); Creates a custom cron
* @since 2.0.0
*/
public function wcdpue_custom_cron_schedule( $schedules ){
$schedules['wcdpue_cron'] = array(
'interval' => apply_filters( 'wcdpue_custom_cron_schedule', 900 ),
'display' => __( 'Every 15 Minutes' )
);
return $schedules;
}
我正在运行的 phpdoc 命令是:
php phpDocumentor.phar -d oop/ -t docs/api --sourcecode
如果它有任何帮助,由于某种原因我也无法从渲染的 phpdoc 中看到我定义的任何块的源代码:
如有任何帮助,我们将不胜感激
@example 指定包含示例代码用法的文件的路径。 phpDocumentor 将发布带有语法突出显示和行号的示例。
例如: @example /path/example.php 描述
使用 phpDocumentor 3.4.2,我有同样的问题。 我试过:
@example "/fullpath/file.php" Description
生成的文档是:
Tags
example
"/fullpath/file.php" Description
但是根据官方文档:
该标签的效果在 phpDocumentor 3 中尚未完全实现。