
net.xp_forge.doclet.doclet.xar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xp-maven-plugin Show documentation
Show all versions of xp-maven-plugin Show documentation
Maven 2/3 plugin to manage the lifecycle of an XP-Framework project
CCA net/xp_forge/apidoc/Doclet.class.php rE css/default.css > rE META-INF/manifest.ini ? ?J write('');
$stream->write(''.$title.($this->api ? ' ('.$this->api.')' : '').' ');
$this->css && $stream->write('');
$stream->write('');
}
/**
* Writes footer
*
* @param io.streams.OutputStream
*/
protected function writeFooter(OutputStream $stream) {
$this->gen && $stream->write(''.$this->gen.'');
$stream->write('');
}
/**
* Creates a link to a given type
*
* @param string t qualified type name
* @param string base
* @return string the link as HTML or the type itself if it cannot be found
*/
protected function typeLink($type, $base) {
sscanf($type, '%[^#]#%s', $t, $anchor);
if ('[]' === substr($t, -2)) {
$raw= substr($t, 0, -2);
$components= '[]';
} else if ($p= strpos($t, '<')) {
$raw= substr($t, 0, $p);
$components= htmlspecialchars(substr($t, $p));
} else {
$raw= $t;
$components= '';
}
foreach ($this->hierarchy as $level) {
foreach ($level['contents'] as $docs) {
foreach ($docs as $doc) {
if ($doc->qualifiedName() !== $raw) continue;
return sprintf(
'%s%s%s',
$doc->classType(),
$doc->containingPackage()->name(),
$base,
strtr($raw, '.', '/'),
$anchor ? '#'.$anchor : '',
$doc->name(),
$anchor ? '::'.$anchor.'()' : '',
$components
);
}
}
}
return $t;
}
/**
* Returns an array of classes implementing this class
*
* @param text.doclet.ClassDoc class
* @return text.doclet.ClassDoc[]
*/
protected function classesImplementing(ClassDoc $class) {
$r= array();
foreach ($this->hierarchy as $level) {
foreach ($level['contents'] as $docs) {
foreach ($docs as $doc) {
for ($doc->interfaces->rewind(); $doc->interfaces->hasNext(); ) {
if ($class->equals($doc->interfaces->next())) $r[]= $doc;
}
}
}
}
return $r;
}
/**
* Returns an array of all interfaces implemented by the given class
*
* @param text.doclet.ClassDoc class
* @return text.doclet.ClassDoc[]
*/
protected function interfacesImplementedBy(ClassDoc $class) {
$r= array();
for ($implemented= array(), $class->interfaces->rewind(); $class->interfaces->hasNext(); ) {
$n= $class->interfaces->next();
$n && $r[]= $n;
}
return $r;
}
/**
* Returns an array of all interfaces implemented by the given class
*
* @param text.doclet.ClassDoc class
* @return text.doclet.ClassDoc[]
*/
protected function allInterfacesImplementedBy(ClassDoc $class) {
$r= array();
do {
for ($implemented= array(), $class->interfaces->rewind(); $class->interfaces->hasNext(); ) {
$n= $class->interfaces->next();
$n && $r[]= $n;
}
} while ($class= $class->superclass);
return $r;
}
/**
* Returns an array of classes subclassing this class
*
* @param text.doclet.ClassDoc class
* @return text.doclet.ClassDoc[]
*/
protected function directSubclassesOf(ClassDoc $class) {
$r= array();
foreach ($this->hierarchy as $level) {
foreach ($level['contents'] as $docs) {
foreach ($docs as $doc) {
if ($class->equals($doc->superclass)) $r[]= $doc;
}
}
}
return $r;
}
/**
* Returns a tag's contents
*
* @param text.doclet.Tag tag
* @param string base
* @return string
*/
protected function tagContents(Tag $tag, $base) {
if ($tag instanceof ReturnTag) {
return $this->typeLink($tag->type, $base).($tag->text ? ' - '.$tag->text : '');
} else if ($tag instanceof ParamTag) {
return $this->typeLink($tag->type, $base).' '.$tag->parameter.($tag->text ? ' - '.$tag->text : '');
} else if ($tag instanceof SeeTag) {
switch ($tag->scheme) {
case 'xp': return $this->typeLink($tag->urn, $base);
case 'http': return 'http://'.$tag->urn.'';
default: return $tag->urn;
}
} else if ($tag instanceof TestTag) {
return $this->typeLink($tag->class, $base);
} else if ($tag instanceof ThrowsTag) {
return $this->typeLink($tag->exception->qualifiedName(), $base).($tag->text ? ' - '.$tag->text : '');
} else {
return $tag->text();
}
}
/**
* Writes method signaturw
*
* @param text.doclet.MethodDoc method
* @param string base
* @param io.streams.OutputStream
*/
protected function writeSignature(MethodDoc $method, $base, OutputStream $stream) {
$return= $method->tags('return');
$params= $method->tags('param');
$stream->write(($return ? $this->typeLink($return[0]->type, $base) : 'void').' ');
$stream->write(''.$method->name().'(');
for ($i= 0, $s= sizeof($params); $i < $s; $i++) {
$stream->write($this->typeLink($params[$i]->type, $base).' '.$params[$i]->parameter);
$i < $s- 1 && $stream->write(', ');
}
$stream->write(')');
}
/**
* Writes tags
*
* @param string title
* @param text.doclet.Tag[] tags
* @param string base
* @param io.streams.OutputStream
*/
protected function writeTags($title, array $tags, $base, OutputStream $stream) {
if (empty($tags)) return;
$stream->write(''.$title.': ');
foreach ($tags as $tag) {
$stream->write(''.$this->tagContents($tag, $base).' ');
}
}
/**
* Write markup
*
* @param io.streams.OutputStream
* @param string input
*/
protected function writeMarkup($input, OutputStream $stream) {
$stream->write('');
$stream->write(strtr($this->processor->markupFor($input), array(
'' => '',
'
' => '',
'
' => '',
'
' => '',
'' => '',
'
' => '',
'' => '',
'
' => '',
)));
$stream->write('');
}
/**
* Returns whether a given doc is static
*
* @param text.doclet.Doc d
* @return bool
*/
protected function isStatic(Doc $d) {
return array_key_exists('static', $d->getModifiers());
}
/**
* Generate class documentation for a given class and write it to the
* given output stream
*
* @param text.doclet.ClassDoc doc
* @param io.streams.OutputStream
* @return io.streams.OutputStream
*/
protected function writeDoc(ClassDoc $doc, OutputStream $stream) {
$this->writeHeader($doc->name(), $stream);
$base= str_repeat('../', substr_count($doc->qualifiedName(), '.'));
// Summary
$stream->write('Overview');
$stream->write(' » '.$doc->containingPackage()->name().'
');
$stream->write(''.ucfirst($doc->classType()).' '.$doc->name().'
');
$stream->write('');
if ($doc->isInterface()) {
$implementations= $this->classesImplementing($doc);
if (!empty($implementations)) {
$stream->write('- All known implementing classes:
- ');
for ($i= 0, $s= sizeof($implementations); $i < $s; $i++) {
$stream->write($this->typeLink($implementations[$i]->qualifiedName(), $base));
$i < $s- 1 && $stream->write(', ');
}
$stream->write('
');
}
} else {
$implemented= $this->allInterfacesImplementedBy($doc);
if (!empty($implemented)) {
$stream->write('- All implemented interfaces:
- ');
for ($i= 0, $s= sizeof($implemented); $i < $s; $i++) {
$stream->write($this->typeLink($implemented[$i]->qualifiedName(), $base));
$i < $s- 1 && $stream->write(', ');
}
$stream->write('
');
}
$subclasses= $this->directSubclassesOf($doc);
if (!empty($subclasses)) {
$stream->write('- Direct known subclasses:
- ');
for ($i= 0, $s= sizeof($subclasses); $i < $s; $i++) {
$stream->write($this->typeLink($subclasses[$i]->qualifiedName(), $base));
$i < $s- 1 && $stream->write(', ');
}
$stream->write('
');
}
}
$stream->write('
');
$stream->write('
');
// Signature
$stream->write('');
$stream->write(implode(' ', array_keys($doc->getModifiers())).' '.$doc->classType().' '.$doc->name());
if (!$doc->isInterface()) {
$doc->superclass && $stream->write(' extends '.$this->typeLink($doc->superclass->qualifiedName(), $base));
$implemented= $this->interfacesImplementedBy($doc);
if (!empty($implemented)) {
$stream->write(' implements ');
for ($i= 0, $s= sizeof($implemented); $i < $s; $i++) {
$stream->write($this->typeLink($implemented[$i]->qualifiedName(), $base));
$i < $s- 1 && $stream->write(', ');
}
}
}
$stream->write('
');
$this->writeMarkup($doc->commentText(), $stream);
// Class tags
$stream->write('');
$this->writeTags('See also', $doc->tags('see'), $base, $stream);
$this->writeTags('Verified by', $doc->tags('test'), $base, $stream);
$stream->write('
');
$stream->write('
');
// Field summary
$stream->write('');
// Method summary
$stream->write('');
// Method details
foreach ($doc->methods as $method) {
$stream->write(''.$method->name().'
');
$stream->write(''.implode(' ', array_keys($method->getModifiers())).' ');
$this->writeSignature($method, $base, $stream);
$stream->write('
');
$this->writeMarkup($method->commentText(), $stream);
$stream->write('');
$this->writeTags('Parameters', $method->tags('param'), $base, $stream);
$this->writeTags('Returns', $method->tags('return'), $base, $stream);
$this->writeTags('Throws', $method->tags('throws'), $base, $stream);
$this->writeTags('See also', $method->tags('see'), $base, $stream);
$stream->write('
');
$stream->write('');
$stream->write('
');
}
$this->writeFooter($stream);
return $stream;
}
/**
* Generate package documentation for a given package and write it to the
* given output stream
*
* @param array contents
* @param io.Folder target
* @return io.streams.OutputStream
*/
protected function writePackage(array $definitions, Folder $target) {
with ($stream= new FileOutputStream(new File($target, 'summary.html'))); {
$this->writeHeader($definitions['doc']->name(), $stream);
$stream->write('Overview
');
$stream->write('Package '.$definitions['doc']->name().'
');
$this->writeMarkup($definitions['doc']->commentText(), $stream);
foreach ($definitions['contents'] as $type => $docs) {
if (empty($docs)) continue;
// Contents
$stream->write('');
}
$this->writeFooter($stream);
}
return $stream;
}
/**
* Generate overview
*
* @param array packages
* @param io.Folder target
* @return io.streams.OutputStream
*/
protected function writeOverview(array $packages, Folder $target) {
with ($stream= new FileOutputStream(new File($target, 'index.html'))); {
$this->writeHeader('Overview', $stream);
$stream->write('Overview
');
$stream->write('Overview '.($this->api ? ' ('.$this->api.')' : '').'
');
// Summary
$stream->write('');
$this->writeFooter($stream);
return $stream;
}
}
/**
* Returns valid options
*
* @return array
*/
public function validOptions() {
return array('output' => HAS_VALUE, 'api' => HAS_VALUE, 'css' => HAS_VALUE, 'gen' => HAS_VALUE);
}
/**
* Entry point
*
* @param text.doclet.RootDoc root
* @return var
*/
public function start(RootDoc $root) {
$this->processor= new MarkupBuilder();
// Option: API (will be used in title, default: none)
$this->api= $this->option('api');
// Option: Gen (will be used in footer)
$this->gen= $this->option('gen');
// Option: CSS to embed (filename, default: none)
if ($css= $this->option('css')) {
$this->css= FileUtil::getContents(new File($css));
}
// Option: Output folder (default: Current directory, created if non-existant)
$target= new Folder($this->option('output', '.'));
$target->exists() || $target->create();
// Compute hierarchy
Console::write('[');
$this->hierarchy= array();
$seen= array();
while ($this->classes->hasNext()) {
$class= $this->classes->next();
if (isset($seen[$class->qualifiedName()])) {
continue;
}
$seen[$class->qualifiedName()]= TRUE;
$key= $class->containingPackage()->name();
if (!isset($this->hierarchy[$key])) {
$sub= new Folder($target, strtr($key, '.', DIRECTORY_SEPARATOR));
$sub->exists() || $sub->create();
$this->hierarchy[$key]= array(
'target' => $sub,
'doc' => $class->containingPackage(),
'contents' => array(
INTERFACE_CLASS => array(),
ORDINARY_CLASS => array(),
ENUM_CLASS => array(),
EXCEPTION_CLASS => array(),
ERROR_CLASS => array()
)
);
}
Console::write('.');
$this->hierarchy[$key]['contents'][$class->classType()][]= $class;
}
// Generate HTML files
Console::write('>');
$this->writeOverview($this->hierarchy, $target)->close();
Console::writeLine($target, ']');
}
}
?>
* {
font: 10pt "Trebuchet MS",Arial,Helvetica;
}
h1 {
font-size: 1.5em;
padding: 1pt;
background-color: #91d9ba;
border-bottom: 2px solid #3a775d;
}
h2 {
font-size: 1.4em;
}
h3 {
font-size: 1.3em;
}
hr {
height: 2px;
color: #b8c9c2;
border: 0;
}
a {
color: #155e3e;
}
a:visited {
color: #7f8c87;
}
dt {
font-weight: bold;
}
dd {
padding: 1px;
}
code, pre, tt, a.type {
font: 9pt "Lucida Console", "Monaco", courier, fixed, monospace;
}
fieldset {
padding-top: 1em;
}
fieldset legend {
font-size: 1.3em;
}
fieldset ul li {
border-bottom: 1px solid #cccccc;
padding: 1pt;
}
fieldset ul p {
margin: 0;
}
ul {
list-style-type: square;
}
div.dfn {
margin-left: 20px;
}
div.dfn h2, div.dfn h3 {
font-size: 10pt;
font-weight: bold;
}
pre.code {
border-left: 2px solid #cccccc;
padding-left: 8px;
}
pre.code span {
font: 9pt "Courier New", courier;
}
pre.code .keyword {
color: #990000;
font-weight: bold;
}
pre.code .modifier {
color: #666666;
font-weight: bold;
}
pre.code .variable {
color: #000099;
font-weight: bold;
}
pre.code .bracket {
color: #a90000;
}
pre.code .string {
color: #0000a9;
}
pre.code .number {
color: #00a000;
}
pre.code .comment {
color: #666666;
}
pre.code .annotation {
color: #3165c5;
}
div#foot {
font-style: italic;
text-align: center;
}
[project]
version=5.8.9
name=Apidoc
artifact-id=apidoc
group-id=net.xp-framework
[archive]
created-by=mrosoiu@dlbu-1gpst4j
generator=xp-maven-plugin
format=xar
created-on=2012-11-26 15:58:07 GMT
© 2015 - 2025 Weber Informatics LLC | Privacy Policy