Permalink
Browse files

Several inter-related fixes:

- Added class contents to API, finishes the fix for #2152
- Changed the format of the guide menu (translations must be updated!)
- Added Javascript toggling to the menu and API class contents
  • Loading branch information...
1 parent ad5e6bb commit 4002f7e75da4078d2e7258c530ed484d5087d097 @shadowhand shadowhand committed Oct 1, 2009
Showing with 126 additions and 26 deletions.
  1. +1 −1 classes/kohana/kodoc.php
  2. +21 −21 guide/menu.md
  3. +11 −3 media/css/kodoc.css
  4. +52 −0 media/js/kodoc.js
  5. +40 −0 views/userguide/api/class.php
  6. +1 −1 views/userguide/api/method.php
View
@@ -65,7 +65,7 @@ public static function menu()
$package = HTML::anchor($route->uri(array('class' => $package)), $package);
$output[] =
- "<li>$package\n\t<ul><li>".
+ "<li><strong>$package</strong>\n\t<ul><li>".
implode("</li><li>", $list).
"</li></ul>\n</li>";
}
View
@@ -1,21 +1,21 @@
-1. [Getting Started](start)
- * [Conventions and Style](start.conventions)
- * [Installation](start.installation)
- * [Configuration](start.configuration)
- * [Model View Controller](start.mvc)
- * [Filesystem](start.filesystem)
- * [Autoloading](start.autoloading)
- * [Request Flow](start.flow)
-2. [Tutorials](tutorials)
- * [Hello, World](tutorials.helloworld)
- * [Routes, URLs, and Links](tutorials.urls)
- * [Databases](tutorials.databases)
-3. [Security](security)
- * [XSS](security.xss)
- * [Validation](security.validation)
- * [Cookies](security.cookies)
- * [Database](security.database)
-4. [Debugging](debugging)
- * [Error Handling](debugging.errors)
- * [Profiling](debugging.profiling)
-5. [API Browser](api)
+1. **[Getting Started](start)**
+ - [Conventions and Style](start.conventions)
+ - [Installation](start.installation)
+ - [Configuration](start.configuration)
+ - [Model View Controller](start.mvc)
+ - [Filesystem](start.filesystem)
+ - [Autoloading](start.autoloading)
+ - [Request Flow](start.flow)
+2. **[Tutorials](tutorials)**
+ - [Hello, World](tutorials.helloworld)
+ - [Routes, URLs, and Links](tutorials.urls)
+ - [Databases](tutorials.databases)
+3. **[Security](security)**
+ - [XSS](security.xss)
+ - [Validation](security.validation)
+ - [Cookies](security.cookies)
+ - [Database](security.database)
+4. **[Debugging](debugging)**
+ - [Error Handling](debugging.errors)
+ - [Profiling](debugging.profiling)
+5. **[API Browser](api)**
View
@@ -5,6 +5,8 @@ table th { color: #444; background: #eee; }
table td { background: #f4f4f4; }
table tr.alt td { background: #fff; }
+.container .toggle { font-size: 0.7em; float: right; padding: 0 1em; cursor: pointer; color: #777; text-decoration: none; }
+
#topbar { padding: 1em 0; margin-bottom: 2em; background: #111; border-bottom: solid 0.2 #eee; color: #aaa; }
#topbar ul.breadcrumb { display: block; margin: 0; padding: 0; overflow: auto; }
#topbar ul.breadcrumb li { display: block; float: left; margin: 0; padding: 0; padding-left: 0.6em; }
@@ -17,11 +19,13 @@ table td { background: #f4f4f4; }
#menu ol,
#menu ul { margin: 0; padding: 0; list-style: none; }
#menu li { margin: 0; padding: 0; }
+ #menu li { display: block; }
#menu li a { display: block; padding: 0.2em 0.4em; }
+ #menu li strong { display: block; margin-bottom: 0.4em; font-weight: normal; color: #eee; background: #111; }
+ #menu li strong a { color: #eee; background: #111; text-decoration: none; }
#menu ol ul { margin-left: 1em; }
#menu > ol { padding: 1em; }
- #menu > ol ul { padding-top: 0.4em; padding-bottom: 0.6em; }
- #menu ol > li > a { color: #eee; background: #111; text-decoration: none; }
+ #menu > ol ul { padding-bottom: 0.6em; }
#footer { margin-top: 1em; padding: 1em 0; color: #666; }
#footer p { font-size: 0.8em; text-transform: uppercase; }
@@ -38,12 +42,16 @@ table td { background: #f4f4f4; }
#content h6 small { font-size: 0.9em; font-weight: normal; color: #444; }
#content pre { font-size: 1em; line-height: 1.4em; }
+#content div.toc { margin-bottom: 1em; padding-bottom: 1em; background: #eee; }
+ #content div.toc ul { margin: 0.6em 1em; padding: 0; list-style: none; }
+ #content div.toc li { margin: 0; padding: 0; }
+ #content div.toc h3 { margin: 0; padding: 0.2em 1em; font-size: 1em; color: #eee; background: #111; }
#content div.method,
#content div.properties,
#content div.constants { margin-bottom: 1em; }
#content div.method h3 .param { font-weight: normal; cursor: help; }
#content div.method h3 abbr.param { text-transform: none; font-size: 1em; }
#content p.note { display: block; padding: 0.4em 0.6em; background: #efefef; color: #444; font-size: 0.9em; border: solid 1px #eee; }
#content dl.tags { overflow: auto; background: #eee; padding: 1em; border: solid 6px #ddd; }
- #content dl.tags dt { margin: 0 0 0.4em; clear: left; float: left; width: 25%; }
+ #content dl.tags dt { margin: 0 0 0.4em; clear: both; float: left; width: 25%; }
#content dl.tags dd { margin: 0; padding: 0; clear: right; float: right; }
View
@@ -8,4 +8,56 @@ $(document).ready(function()
// Striped tables
$('#content tbody tr:even').addClass('alt');
+
+ // Toggle menus
+ $('#menu ol > li').each(function()
+ {
+ var link = $(this).find('strong a');
+ var menu = $(this).find('ul');
+ var togg = $('<span class="toggle">[ + ]</span>');
+
+ var open = function()
+ {
+ $(this).html('[ &ndash; ]');
+ menu.stop().slideDown();
+ };
+
+ var close = function()
+ {
+ $(this).html('[ + ]');
+ menu.stop().slideUp();
+ };
+
+ if ($(this).find('a[href="'+ window.location.pathname +'"]').length)
+ {
+ togg.html('[ &ndash; ]')
+ .toggle(close, open);
+ }
+ else
+ {
+ menu.hide();
+ togg.toggle(open, close);
+ }
+
+ togg.appendTo(link);
+ });
+
+ // Collapsable class contents
+ $('#content #toc').each(function()
+ {
+ var header = $(this);
+ var content = $('#content div.toc').hide();
+
+ $('<span class="toggle">[ + ]</span>').toggle(function()
+ {
+ $(this).html('[ &ndash; ]');
+ content.stop().slideDown();
+ },
+ function()
+ {
+ $(this).html('[ + ]');
+ content.stop().slideUp();
+ })
+ .appendTo(header);
+ });
});
@@ -6,6 +6,46 @@
<?php endwhile ?>
</h1>
+<h2 id="toc">Class Contents</h2>
+<div class="toc span-17 last">
+ <div class="constants span-5">
+ <h3>Constants</h3>
+ <ul>
+ <?php if ($doc->constants): ?>
+ <?php foreach ($doc->constants as $name => $value): ?>
+ <li><a href="#constant:<?php echo $name ?>"><?php echo $name ?></a></li>
+ <?php endforeach ?>
+ <?php else: ?>
+ <li><em>None</em></li>
+ <?php endif ?>
+ </ul>
+ </div>
+ <div class="properties span-6">
+ <h3>Properties</h3>
+ <ul>
+ <?php if ($properties = $doc->properties()): ?>
+ <?php foreach ($properties as $prop): ?>
+ <li><a href="#property:<?php echo $prop->property->name ?>">$<?php echo $prop->property->name ?></a></li>
+ <?php endforeach ?>
+ <?php else: ?>
+ <li><em>none</em></li>
+ <?php endif ?>
+ </ul>
+ </div>
+ <div class="methods span-6 last">
+ <h3>Methods</h3>
+ <ul>
+ <?php if ($methods = $doc->methods()): ?>
+ <?php foreach ($methods as $method): ?>
+ <li><a href="#<?php echo $method->method->name ?>"><?php echo $method->method->name ?>()</a></li>
+ <?php endforeach ?>
+ <?php else: ?>
+ <li><em>none</em></li>
+ <?php endif ?>
+ </ul>
+ </div>
+</div>
+
<?php echo $doc->description ?>
<?php if ($doc->tags) echo View::factory('userguide/api/tags')->set('tags', $doc->tags) ?>
@@ -1,5 +1,5 @@
<div class="method">
-<h3 id="<?php echo strtolower($doc->method->name) ?>"><?php echo $doc->modifiers, $doc->method->name, ' ( ', $doc->params, ' )' ?></h3>
+<h3 id="<?php echo strtolower($doc->method->name) ?>"><?php echo $doc->modifiers, $doc->method->name, ' ( ', $doc->params, ' )' ?> <a class="toggle" href="#toc">(top)</a></h3>
<div class="description">
<?php echo $doc->description ?>

0 comments on commit 4002f7e

Please sign in to comment.