forked from pronamic/wp-documentor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphpdocumentor-rst.php
90 lines (70 loc) · 2.56 KB
/
phpdocumentor-rst.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* RestructuredText Template for phpDocumentor
*
* @link https://docs.phpdoc.org/3.0/guide/internals/guides.html
* @link https://docutils.sourceforge.io/docs/user/rst/quickref.html
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package DigitalJoeCo\Leantime\Documentor
*/
namespace DigitalJoeCo\Leantime\Documentor;
if ( ! isset( $documentor ) ) {
return;
}
$eol = "\n";
$tab = "\t";
$hooks = $documentor->get_hooks();
switch ( $documentor->type ) {
case 'actions':
$hooks = $documentor->get_actions();
break;
case 'filters':
$hooks = $documentor->get_filters();
break;
}
if ( 'actions' === $documentor->type ) {
echo 'Actions', $eol;
echo '=======' , $eol;
echo $eol;
echo $tab, 'Actions allow you to add data or change how WordPress operates. Callback functions for Actions will run at a specific point in the execution of WordPress, and can perform some kind of a task, like echoing output to the user or inserting something into the database. Actions do not return anything back to the calling hook.', $eol;
echo $eol;
echo 'https://developer.wordpress.org/plugins/hooks/actions/', $eol;
}
if ( 'filters' === $documentor->type ) {
echo 'Filters', $eol;
echo '=======' , $eol;
echo $eol;
echo $tab, 'Filters give you the ability to change data during the execution of WordPress. Callback functions for Filters will accept a variable, modify it, and return it. They are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. Filters expect to have something returned back to them.', $eol;
echo $eol;
echo 'https://developer.wordpress.org/plugins/hooks/filters/', $eol;
}
echo $eol;
foreach ( $hooks as $hook ) {
$tag_name = $hook->get_tag()->get_name();
echo $tag_name, $eol;
echo str_repeat( '-', \strlen( $tag_name ) ), $eol;
echo $eol;
$summary = $hook->get_summary();
if ( null !== $summary ) {
echo '*', $summary, '*', $eol;
echo $eol;
}
$description = $hook->get_description();
if ( null !== $description ) {
echo $description, $eol;
echo $eol;
}
$arguments = $hook->get_arguments();
if ( \count( $arguments ) > 0 ) {
echo '+----------+------+-------------+', $eol;
echo '| Argument | Type | Description |', $eol;
echo '+==========+======+=============+', $eol;
foreach ( $arguments as $argument ) {
echo '| ', $argument->get_name(), ' | ', $argument->get_type(), ' | ', $argument->get_description(), ' |', $eol;
}
echo '+----------+------+-------------+', $eol;
echo $eol;
}
}