Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * $Id: PHPDocumentorTask.php 144 2007-02-05 15:19:00Z hans $
4
 *
5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
 *
17
 * This software consists of voluntary contributions made by many individuals
18
 * and is licensed under the LGPL. For more information please see
19
 * <http://phing.info>.
20
 */
21
 
22
/**
23
 * Phing subclass of the phpDocumentor_setup class provided with PhpDocumentor to work around limitations in PhpDocumentor API.
24
 *
25
 * This class is necessary because phpDocumentor_setup does not expose a complete API for setting configuration options.  Because
26
 * this class must directly modify some "private" GLOBAL(!) configuration variables, it is liable to break if the PhpDocumentor
27
 * internal implementation changes.  Obviously this is far from ideal, but there's also no solution given the inflexibility of the
28
 * PhpDocumentor design.
29
 *
30
 * @author Hans Lellelid <hans@xmpl.org>@author hans
31
 * @version $Id$
32
 * @package phing.tasks.ext.phpdoc
33
 */
34
class PhingPhpDocumentorSetup extends phpDocumentor_setup {
35
 
36
	/**
37
	 * Constructs a new PhingPhpDocumentorSetup.
38
	 *
39
	 * @param string $configDir Directory in which to look for configuration files.
40
	 */
41
	public function __construct($configdir = null) {
42
		global $_phpDocumentor_cvsphpfile_exts, $_phpDocumentor_setting, $_phpDocumentor_phpfile_exts;
43
 
44
		$this->setup = new Io();
45
		$this->render = new phpDocumentor_IntermediateParser("Default Title");
46
 
47
		$GLOBALS['_phpDocumentor_install_dir'] = $configdir;
48
        $this->parseIni();
49
 
50
        // These redundant-looking lines seem to actually make a difference.
51
        // See: http://phing.info/trac/ticket/150
52
        $_phpDocumentor_phpfile_exts = $GLOBALS['_phpDocumentor_phpfile_exts'];
53
		$_phpDocumentor_cvsphpfile_exts = $GLOBALS['_phpDocumentor_cvsphpfile_exts'];
54
 
55
		if (tokenizer_ext) {
56
            $this->parse = new phpDocumentorTParser();
57
        } else {
58
            $this->parse = new Parser();
59
        }
60
 
61
        $this->setMemoryLimit();
62
	}
63
 
64
	/**
65
	 * Set whether to generate sourcecode for each file parsed.
66
	 *
67
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
68
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
69
	 * is subject to break if PhpDocumentor internals changes.
70
	 *
71
	 * @param bool $b
72
	 */
73
	public function setGenerateSourcecode($b) {
74
		global $_phpDocumentor_setting;
75
		$_phpDocumentor_setting['sourcecode'] = (boolean) $b;
76
	}
77
 
78
	/**
79
	 * Set an array of README/INSTALL/CHANGELOG file paths.
80
	 *
81
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
82
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
83
	 * is subject to break if PhpDocumentor internals changes.
84
	 *
85
	 * @param array $files Absolute paths to files.
86
	 */
87
	public function setRicFiles($files) {
88
		global $_phpDocumentor_RIC_files;
89
		$_phpDocumentor_RIC_files = $files;
90
	}
91
 
92
	/**
93
	 * Set comma-separated list of tags to ignore.
94
	 *
95
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
96
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
97
	 * is subject to break if PhpDocumentor internals changes.
98
	 *
99
	 * @param string $tags
100
	 */
101
	public function setIgnoreTags($tags) {
102
		global $_phpDocumentor_setting;
103
		$ignoretags = explode(',', $tags);
104
		$ignoretags = array_map('trim', $ignoretags);
105
		$tags = array();
106
		foreach($ignoretags as $tag) {
107
		    if (!in_array($tag,array('@global', '@access', '@package', '@ignore', '@name', '@param', '@return', '@staticvar', '@var')))
108
		        $tags[] = $tag;
109
		}
110
		$_phpDocumentor_setting['ignoretags'] = $tags;
111
	}
112
 
113
	/**
114
	 * Set whether to parse dirs as PEAR repos.
115
	 *
116
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
117
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
118
	 * is subject to break if PhpDocumentor internals changes.
119
	 *
120
	 * @param bool $b
121
	 */
122
	public function setPear($b) {
123
		global $_phpDocumentor_setting;
124
		$_phpDocumentor_setting['pear'] = (boolean) $b;
125
	}
126
 
127
	/**
128
	 * Set fullpath to directory to look in for examples.
129
	 *
130
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
131
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
132
	 * is subject to break if PhpDocumentor internals changes.
133
	 *
134
	 * @param string $dir
135
	 */
136
	public function setExamplesDir($dir) {
137
		global $_phpDocumentor_setting;
138
		$_phpDocumentor_setting['examplesdir'] = $dir;
139
	}
140
 
141
	/**
142
	 * Sets the default package name.
143
	 *
144
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
145
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
146
	 * is subject to break if PhpDocumentor internals changes.
147
	 *
148
	 * @param string $name
149
	 */
150
	public function setDefaultPackageName($name) {
151
		$GLOBALS['phpDocumentor_DefaultPackageName'] = trim($name);
152
	}
153
 
154
	/**
155
	 * Sets the default category name.
156
	 *
157
	 * This method exists as a hack because there is no API exposed for this in PhpDocumentor.
158
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
159
	 * is subject to break if PhpDocumentor internals changes.
160
	 *
161
	 * @param string $name
162
	 */
163
	public function setDefaultCategoryName($name) {
164
		$GLOBALS['phpDocumentor_DefaultCategoryName'] = trim($name);
165
	}
166
 
167
	/**
168
	 * Enables quiet mode.
169
	 *
170
	 * This method exists as a hack because the API exposed for this method in PhpDocumentor
171
	 * doesn't work correctly.
172
	 *
173
	 * Note that because we are setting a "private" GLOBAL(!!) config var with this value, this
174
	 * is subject to break if PhpDocumentor internals changes.
175
	 *
176
	 */
177
	public function setQuietMode() {
178
		global $_phpDocumentor_setting;
179
		$_phpDocumentor_setting['quiet'] = true;
180
		parent::setQuietMode();
181
	}
182
 
183
    /**
184
     * Control whether or not warnings will be shown for undocumented elements.
185
     * Useful for identifying classes and methods that haven't yet been
186
     * documented.
187
     *
188
     * @param  bool  $bEnable
189
     */
190
    public function setUndocumentedelements($bEnable) {
191
        $this->render->setUndocumentedElementWarningsMode($bEnable);
192
    }
193
 
194
    /**
195
     * custom tags, will be recognized and put in tags[] instead of
196
     * unknowntags[]
197
     *
198
     * This method exists as a hack because the API exposed for this method in
199
     * PhpDocumentor doesn't work correctly.
200
	 *
201
     * Note that because we are setting a "private" GLOBAL(!!) config var with
202
     * this value, this is subject to break if PhpDocumentor internals changes.
203
     *
204
     * @param  string  $sCustomtags
205
     */
206
    public function setCustomtags($sCustomtags) {
207
        global $_phpDocumentor_setting;
208
        $_phpDocumentor_setting['customtags'] = $sCustomtags;
209
    }
210
}