Skip to content

Commit

Permalink
Modern doclet added
Browse files Browse the repository at this point in the history
  • Loading branch information
peej committed Apr 16, 2013
1 parent 198142c commit a22458b
Show file tree
Hide file tree
Showing 10 changed files with 1,604 additions and 3 deletions.
358 changes: 358 additions & 0 deletions doclets/modern/classWriter.php

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions doclets/modern/frameIndexWriter.php
@@ -0,0 +1,135 @@
<?php
/*
PHPDoctor: The PHP Documentation Creator
Copyright (C) 2004 Paul James <paul@peej.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/** This generates the package-summary.html files that list the interfaces and
* classes for a given package.
*
* @package PHPDoctor\Doclets\Modern
*/
class FrameIndexWriter extends HTMLWriter
{

/** Build the package summaries.
*
* @param Doclet doclet
*/
public function __construct(&$doclet)
{

parent::__construct($doclet);

$this->_id = 'frame';

$rootDoc = $this->_doclet->rootDoc();
$phpdoctor = $this->_doclet->phpdoctor();

$packages = $rootDoc->packages();
ksort($packages);

ob_start();

#echo '<h1>'.$this->_doclet->_docTitle.'</h1>';

$namespaces = array();
foreach ($packages as $package) {
$name = explode('\\', $package->name());
$namespaces = $this->placeIntoNamespace($namespaces, $package, $name);
}

$this->outputNamespace($namespaces, $packages);

echo <<<SCRIPT
<script>
window.onload = function () {
var lis = document.getElementsByTagName("li");
for (var foo = 0; foo < lis.length; foo++) {
lis[foo].onclick = function (e) {
e.stopPropagation();
if (this.className == "parent open") {
this.className = "parent";
} else if (this.className == "parent") {
this.className = "parent open";
}
};
}
};
</script>
SCRIPT;

$this->_output = ob_get_contents();
ob_end_clean();

$this->_write('frame.html', 'Frame', true, false);

}

function placeIntoNamespace($namespaces, $package, $name)
{
$thisNamespace = array_shift($name);
if (!isset($namespaces[$thisNamespace])) {
$namespaces[$thisNamespace] = array();
}
if ($name) {
$namespaces[$thisNamespace] = $this->placeIntoNamespace($namespaces[$thisNamespace], $package, $name);
}
return $namespaces;
}

function outputNamespace($namespaces, $packages, $fullPackageName = '', $depth = 0)
{
if (is_array($namespaces)) {
echo '<ul>';
foreach ($namespaces as $packageName => $children) {
if ($fullPackageName) {
$thisFullPackageName = $fullPackageName.'\\'.$packageName;
} else {
$thisFullPackageName = $packageName;
}

$hasChildren = isset($packages[$thisFullPackageName]) && $packages[$thisFullPackageName]->allClasses();
$indent = (20 + (14 * $depth));

if ($children || $hasChildren) {
echo '<li class="parent">';
} else {
echo '<li>';
}
if (isset($packages[$thisFullPackageName])) {
echo '<a href="', $packages[$thisFullPackageName]->asPath(), '.html" target="main" style="padding-left: '.$indent.'px">', $packageName, '</a>';
} else {
echo '<span style="padding-left: '.$indent.'px">'.$packageName.'</span>';
}
if ($children) {
echo $this->outputNamespace($children, $packages, $thisFullPackageName, $depth + 1);
}
if ($hasChildren) {
echo '<ul>';
foreach ($packages[$thisFullPackageName]->allClasses() as $class) {
echo '<li><a href="'.$class->asPath().'" target="main" style="padding-left: '.($indent + 14).'px">'.$class->name().'</a></li>';
}
echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
}
}

}
73 changes: 73 additions & 0 deletions doclets/modern/frameOutputWriter.php
@@ -0,0 +1,73 @@
<?php
/*
PHPDoctor: The PHP Documentation Creator
Copyright (C) 2004 Paul James <paul@peej.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/** This generates the index.html file used for presenting the frame-formated
* "cover page" of the API documentation.
*
* @package PHPDoctor\Doclets\Modern
*/
class FrameOutputWriter extends HTMLWriter
{

/** Build the HTML frameset.
*
* @param Doclet doclet
*/
public function frameOutputWriter(&$doclet)
{

parent::HTMLWriter($doclet);

ob_start();
echo <<<END
<frameset cols="20%,80%" frameborder="1" border="1" bordercolor="#bbb" framespacing="1">
<frame src="frame.html" name="index">
<frame src="namespaces.html" name="main">
<noframes>
<body>
<h2>Frame Alert</h2>
<p>This document is designed to be viewed using frames. If you see this message, you are using a non-frame-capable browser.<br>
Link to <a href="namespaces.html">Non-frame version</a>.</p>
</body>
</noframes>
</frameset>
END;

$this->_output = ob_get_contents();
ob_end_clean();

$this->_write('index.html', false, false, false);

}

/** Get the HTML DOCTYPE for this output
*
* @return str
*/
public function _doctype()
{
return '<!DOCTYPE html>'."\n\n";
}

}
100 changes: 100 additions & 0 deletions doclets/modern/functionWriter.php
@@ -0,0 +1,100 @@
<?php
/*
PHPDoctor: The PHP Documentation Creator
Copyright (C) 2004 Paul James <paul@peej.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/** This generates the HTML API documentation for each global function.
*
* @package PHPDoctor\Doclets\Modern
*/
class FunctionWriter extends HTMLWriter
{

/** Build the function definitons.
*
* @param Doclet doclet
*/
public function functionWriter(&$doclet)
{

parent::HTMLWriter($doclet);

$this->_id = 'definition';

$rootDoc =& $this->_doclet->rootDoc();

$packages =& $rootDoc->packages();
ksort($packages);

foreach ($packages as $packageName => $package) {

$this->_depth = $package->depth() + 1;

ob_start();

echo '<header>';
echo '<h1>'.$this->_doclet->_docTitle.'</h1>';
echo "<span>Global</span>\n\n";
echo "<h2>Functions</h2>\n\n";
echo '</header>';

$functions =& $package->functions();

if ($functions) {
ksort($functions);
echo '<table>', "\n";
foreach ($functions as $function) {
$textTag =& $function->tags('@text');
echo "<tr>\n";
echo '<td class="type">', $function->modifiers(FALSE), ' ', $function->returnTypeAsString(), "</td>\n";
echo '<td class="description">';
echo '<p class="name"><a href="#', $function->name(), '()">', $function->name(), '</a>', $function->flatSignature(), '</p>';
if ($textTag) {
echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
}
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n\n";

echo '<h2>Details</h2>', "\n";
foreach ($functions as $function) {
$textTag =& $function->tags('@text');
$this->_sourceLocation($function);
echo '<h3 id="', $function->name(),'()">', $function->name(), "</h3>\n";
echo '<code class="signature">', $function->modifiers(), ' ', $function->returnTypeAsString(), ' <strong>';
echo $function->name(), '</strong>', $function->flatSignature();
echo "</code>\n";
echo '<div class="details">', "\n";
if ($textTag) {
echo $this->_processInlineTags($textTag), "\n";
}
$this->_processTags($function->tags());
echo "</div>\n\n";
}
}

$this->_output = ob_get_contents();
ob_end_clean();

$this->_write($package->asPath().'/package-functions.html', 'Functions', TRUE);
}

}

}

0 comments on commit a22458b

Please sign in to comment.