Skip to content

Commit eba50de

Browse files
committed
Improve doxygen documentation
Change-Id: Ie46e222207ab4b19fc4f72d272e40d181cfee693
1 parent a882468 commit eba50de

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

Doxyfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Doxyfile for IDLeDOM
22
#
3-
# See <http://www.stack.nl/~dimitri/doxygen/manual/config.html>
3+
# See <https://www.doxygen.nl/manual/config.html>
44
# for help on how to use this file to configure Doxygen.
55

66
PROJECT_NAME = "IDLeDOM"
@@ -13,7 +13,7 @@ INPUT = README.md src/
1313
FILE_PATTERNS = *.php
1414
RECURSIVE = YES
1515
USE_MDFILE_AS_MAINPAGE = README.md
16-
FILTER_PATTERNS = *md=build/doxygen_escape.sh
16+
FILTER_PATTERNS = *md=build/doxygen_escape.sh *.php="php build/doxygen_php_filters.php"
1717
HTML_DYNAMIC_SECTIONS = YES
1818
GENERATE_TREEVIEW = YES
1919
TREEVIEW_WIDTH = 250
@@ -25,3 +25,4 @@ TEMPLATE_RELATIONS = YES
2525
CALL_GRAPH = NO
2626
CALLER_GRAPH = NO
2727
DOT_MULTI_TARGETS = YES
28+
GENERATE_TAGFILE = doc/idledom.tag

build/doxygen_php_filters.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
// phpcs:disable Generic.Files.LineLength.TooLong
3+
4+
// Originally from: https://github.com/AbcAeffchen/doxygen-php-filters
5+
// Commit: f13305bd4996bc1b6fcd153f32f7136187b9dd6d
6+
/**
7+
* Project: doxygen-php-filters
8+
* User: Alex Schickedanz (AbcAeffchen)
9+
* Date: 05.03.2015
10+
* License: GPL v2.0
11+
*/
12+
13+
// Input
14+
$source = file_get_contents( $argv[1] );
15+
16+
// support short array syntax
17+
$regexp = '#((var|public|protected|private)(\s+static)?)\s+(\$[^\s;=]+)\s+\=\s+\[([\s\S]*?)\]\;#';
18+
$replace = '$1 $4 = array( $5 );';
19+
$source = preg_replace( $regexp, $replace, $source );
20+
21+
// add class member type hints
22+
$regexp = '#\@(var|type)\s+([^\s]+)([^/]+)/\s+(var|public|protected|private)(\s+static)?\s+(\$[^\s;=]+)#';
23+
$replace = '$3 */ $4 $5 $2 $6';
24+
$source = preg_replace( $regexp, $replace, $source );
25+
26+
// add type hinting to methods
27+
$regexp = '#(\/\*\*[\s\S]*?@return\s+([^\s]*)[\s\S]*?\*\/[\s\S]*?)((?:final\s+)?(?:public|protected|private)(?:\s+static)?)\s+function\s+([\S]*?)\s*?\(#';
28+
$replace = '$1 $3 $2 function $4(';
29+
$source = preg_replace( $regexp, $replace, $source );
30+
31+
$regexp = '#(\*\/\s*?)((?:final\s+)?(?:public|protected|private)(?:\s+static)?)\s+(function\s+(?:[^\s\(]*?)\s*\([^\)]*\)\s*:\s*)((?!void)[^\s\{]*)#m';
32+
$replace = '$1$2 $4 $3$4';
33+
$source = preg_replace( $regexp, $replace, $source );
34+
35+
// Remove @inheritDoc
36+
$regexp = '#@inheritDoc#';
37+
$replace = '';
38+
$source = preg_replace( $regexp, $replace, $source );
39+
40+
// change "@return $this" to '@return [ClassName]'
41+
$tokens = token_get_all( $source );
42+
$classes = [];
43+
foreach ( $tokens as $key => $token ) {
44+
if ( $token[0] == T_CLASS ) {
45+
$classes[] = $tokens[$key + 2][1];
46+
}
47+
}
48+
49+
if ( !empty( $classes ) ) {
50+
list( $source, $tail ) = explode( 'class ' . $classes[0], $source, 2 );
51+
$class_code = '';
52+
for ( $i = 1; $i < count( $classes ); $i++ ) {
53+
list( $class_code, $tail ) = explode( 'class ' . $classes[$i], $tail, 2 );
54+
$class_code = str_replace( '@return $this', '@return ' . $classes[$i - 1], $class_code );
55+
$source .= 'class ' . $classes[$i - 1] . $class_code;
56+
}
57+
$class_code = str_replace( '@return $this', '@return ' . $classes[count( $classes ) - 1], $tail );
58+
$source .= 'class ' . $classes[count( $classes ) - 1] . $class_code;
59+
}
60+
61+
// make traits to classes
62+
$regexp = '#trait([\s]+[\S]+[\s]*){#';
63+
$replace = 'class$1{';
64+
$source = preg_replace( $regexp, $replace, $source );
65+
66+
// use traits by extending them (classes that not extending a class)
67+
$regexp = '#class([\s]+[\S]+[\s]*){[\s]+use([^;]+);#';
68+
$replace = 'class$1 extends $2 {';
69+
$source = preg_replace( $regexp, $replace, $source );
70+
71+
// use traits by extending them (classes that already extending a class)
72+
$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*){[\s]+use([^;]+);#';
73+
$replace = 'class$1, $2 {';
74+
$source = preg_replace( $regexp, $replace, $source );
75+
76+
// Output
77+
echo $source;

0 commit comments

Comments
 (0)