forked from ApiGen/ApiGen
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathapigen.php
76 lines (52 loc) · 1.74 KB
/
apigen.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
<?php
/**
* API Generator.
*
* Copyright (c) 2010 David Grudl (http://davidgrudl.com)
*
* This source file is subject to the "Nette license", and/or
* GPL license. For more information please see http://nette.org
*/
require __DIR__ . '/libs/NetteX/loader.php';
require __DIR__ . '/libs/fshl/fshl.php';
require __DIR__ . '/libs/texy/texy.min.php';
require __DIR__ . '/libs/Apigen/CustomClassReflection.php';
require __DIR__ . '/libs/Apigen/Model.php';
require __DIR__ . '/libs/Apigen/Generator.php';
echo '
APIGen version 0.1
------------------
';
$options = getopt('s:d:c:t:');
if (!isset($options['s'], $options['d'])) { ?>
Usage:
php apigen.php [options]
Options:
-s <path> Name of a source directory to parse. Required.
-d <path> Folder where to save the generated documentation. Required.
-c <path> Output config file.
-t ... Title of generated documentation.
<?php
die();
}
date_default_timezone_set('Europe/Prague');
NetteX\Debug::enable();
NetteX\Debug::timer();
echo "Scanning folder $options[s]\n";
$model = new Apigen\Model;
$model->parse($options['s']);
$count = count($model->getClasses());
$model->expand();
$countD = count($model->getClasses()) - $count;
echo "Found $count classes and $countD system classes\n";
$neon = new NetteX\NeonParser;
$config = str_replace('%dir%', __DIR__, file_get_contents(isset($options['c']) ? $options['c'] : __DIR__ . '/config.neon'));
$config = $neon->parse($config);
if (isset($options['t'])) {
$config['variables']['title'] = $options['t'];
}
echo "Generating documentation to folder $options[d]\n";
@mkdir($options['d']);
$generator = new Apigen\Generator($model);
$generator->generate($options['d'], $config);
echo 'Done. Total time: ' . (int) NetteX\Debug::timer() . " seconds\n";