diff options
author | Michi Henning <michi@zeroc.com> | 2007-01-12 06:01:39 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-01-12 06:01:39 +0000 |
commit | e55d4d843c56a946507fcda5e9dbc7c3f305c109 (patch) | |
tree | a69375648eb15c15cef7796d8368e82dad5d70e1 /cpp | |
parent | Replace .ice.h by .ice.cpp; fixed Oracle .mak files (diff) | |
download | ice-e55d4d843c56a946507fcda5e9dbc7c3f305c109.tar.bz2 ice-e55d4d843c56a946507fcda5e9dbc7c3f305c109.tar.xz ice-e55d4d843c56a946507fcda5e9dbc7c3f305c109.zip |
*** empty log message ***
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/doc/indexHeader | 40 | ||||
-rw-r--r-- | cpp/doc/symboltree.js | 270 | ||||
-rw-r--r-- | cpp/src/slice2html/Gen.cpp | 64 |
3 files changed, 354 insertions, 20 deletions
diff --git a/cpp/doc/indexHeader b/cpp/doc/indexHeader new file mode 100644 index 00000000000..752e0e4da4d --- /dev/null +++ b/cpp/doc/indexHeader @@ -0,0 +1,40 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <title> +TITLE + </title> + <style> + .Symbol { + font-family: "Courier New", Courier, mono; + } + .CollapsibleList { + margin: 0; + padding: 0; + list-style-type: none; + } + .ListEntry { + padding-left: 20px; + } + .CollapsedList { + list-style-type: none; + padding-left: 20px; + width: 20px; + background: url(../images/opened.gif) no-repeat; + cursor: pointer; + } + .ExpandedList { + list-style-type: none; + padding-left: 20px; + width: 20px; + background: url(../images/closed.gif) no-repeat; + cursor: pointer; + } + .ExpandCollapseButtons { + } + .ECButton { + cursor: pointer; + } + </style> + </head> + <body> diff --git a/cpp/doc/symboltree.js b/cpp/doc/symboltree.js new file mode 100644 index 00000000000..0659456d4b8 --- /dev/null +++ b/cpp/doc/symboltree.js @@ -0,0 +1,270 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +var symboltree = new Object(); + +symboltree.id = 'SymbolTree'; +symboltree.cookie = 'SliceSymbolTree'; + +symboltree.main = function() +{ + // + // Look for a collapsible list. + // + symboltree.tree = document.getElementById(symboltree.id); + if(!symboltree.tree) + { + alert('There is no symbol tree on this page.'); + return; + } + + if(symboltree.tree.style) + { + // + // Assign class 'CollapsibleList' to all the unordered lists. + // That way, if the browser does not support DOM, the CCS style + // that removes the bullets and indent does not apply. + // + symboltree.tree.className = 'CollapsibleList'; + var ul = symboltree.tree.getElementsByTagName('ul'); + for(var i = 0; i < ul.length; ++i) + { + ul[i].className = 'CollapsibleList'; + } + } + else + { + return; // Browser doesn't support DOM, don't do anything. + } + + // + // Find all <li> list items. + // + var list = symboltree.tree.getElementsByTagName('li'); + for(var i = 0; i < list.length; ++i) + { + // + // If this list contains sub-lists, it needs a collapse/expand widget. + // + if(list[i].getElementsByTagName('ul').length != 0) + { + // + // Attach an event listener to the widget. + // + list[i].addEventListener('click', symboltree.handleEvent, false); + + // + // The list starts out collapsed by default. Set state and class name, and + // hide all the entries in this list. + // + list[i].setAttribute('state', 'collapsed'); + list[i].className = 'CollapsedList'; + var children = list[i].childNodes; + for(var j = 0; j < children.length; ++j) + { + if(children[j].tagName == 'UL' || children[j].tagName == 'LI') + { + children[j].style.display = 'none'; + } + } + } + else + { + // + // We have a plain <li> list item without <ul> sub-lists. We attach a class name + // to these items so we can refer to them separately in the style sheet. + // + list[i].className = 'ListEntry'; + } + } + + // + // Save expanded list indexes in cookie on page unload. + // + window.addEventListener('unload', symboltree.save, false); + + // + // Load state of list. + // + symboltree.restore(); + + // + // Set image and handler for the "expand all" and "collapse" all buttons. + // + var expandAll = document.getElementById('ExpandAllButton'); + expandAll.addEventListener('click', symboltree.expandAll, false); + + var collapseAll = document.getElementById('CollapseAllButton'); + collapseAll.addEventListener('click', symboltree.collapseAll, false); +} + +// +// Mouse click event handler for collapse/expand widget. +// +symboltree.handleEvent = function(e) +{ + var target; + if(e.target) + { + target = e.target; + } + else if(e.srcObject) + { + target = e.srcObject; + } + if(!target.className || (target.className != 'CollapsedList' && target.className != 'ExpandedList')) + { + return; // Ignore event because it bubbled up from child element (namely, from a link in the list). + } + + // + // Toggle the list. + // + if(target.getAttribute('state') == 'expanded') + { + symboltree.collapse(e.currentTarget); + } + else + { + symboltree.expand(e.currentTarget); + } + + // + // Stop event from bubbling up. + // + if(e.stopPropagation) + { + e.stopPropagation(); // For standards-compliant browsers. + } + else + { + e.cancelBubble = true; // For IE + } +} + +// +// Expand sub-list. The state of the list is remembered in the 'state' attribute. +// Expanded lists have a class name of 'ExpandedList', so the style sheet can select +// the correct icon. To expand a list, we change the display of all immediate +// child <ul> and <li> nodes to 'block'. +// +symboltree.expand = function(list) +{ + var state = list.getAttribute('state'); + if(state && state != 'expanded') + { + list.setAttribute('state', 'expanded'); + list.className = 'ExpandedList'; + var children = list.childNodes; + for(var i = 0; i < children.length; ++i) + { + if(children[i].tagName == 'UL' || children[i].tagName == 'LI') + { + children[i].style.display = 'block'; + } + } + } +} + +symboltree.expandAll = function() +{ + var list = symboltree.tree.getElementsByTagName('li'); + for(var i = 0; i < list.length; ++i) + { + if(list[i].getElementsByTagName('ul').length != 0) + { + symboltree.expand(list[i]); + } + } +} + +// +// Collapse a sub-list. The state of the list is remembered in the 'state' attribute. +// Collapsed lists have a class name of 'CollapsedList', so the style sheet can select +// the correct icon. To collapse a list, we change the display of all immediate +// child <ul> and <li> nodes to 'none'. +// +symboltree.collapse = function(list) +{ + var state = list.getAttribute('state'); + if(state && state != 'collapsed') + { + list.setAttribute('state', 'collapsed'); + list.className = 'CollapsedList'; + var children = list.childNodes; + for(var i = 0; i < children.length; ++i) + { + if(children[i].tagName == 'UL' || children[i].tagName == 'LI') + { + children[i].style.display = 'none'; + } + } + } +} + +symboltree.collapseAll = function() +{ + var list = symboltree.tree.getElementsByTagName('li'); + for(var i = 0; i < list.length; ++i) + { + if(list[i].getElementsByTagName('ul').length != 0) + { + symboltree.collapse(list[i]); + } + } +} + +// +// Save state of the list in a cookie. We save the index of each +// expanded <li> element. +// +symboltree.save = function() +{ + var list = symboltree.tree.getElementsByTagName('li'); + var saved = new Array(); + for(var i = 0; i < list.length; ++i) + { + if(list[i].getElementsByTagName('ul').length != 0) + { + var state = list[i].getAttribute('state'); + if(state && state == 'expanded') + { + saved[saved.length] = i; + } + } + } + if(saved.length == 0) + { + saved[0] = 'none'; + } + document.cookie = symboltree.cookie + '=' + saved; +} + +// +// Restore the state of the list from a cookie. +// +symboltree.restore = function() +{ + var regex = new RegExp(symboltree.cookie + '=[^;]+', 'i'); + if (document.cookie.match(regex)) + { + var value = document.cookie.match(regex)[0].split('=')[1]; + if(value != 'none') + { + var indexes = value.split(','); + var list = symboltree.tree.getElementsByTagName('li'); + for(var i = 0; i < indexes.length; ++i) + { + symboltree.expand(list[indexes[i]]); + } + } + } +} + +symboltree.main(); // Start running. diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp index ada9f56a473..716ff89de6a 100644 --- a/cpp/src/slice2html/Gen.cpp +++ b/cpp/src/slice2html/Gen.cpp @@ -108,7 +108,7 @@ Slice::GeneratorBase::setOutputDir(const string& dir) // // Get the headers. If "header" is empty, use a default header. -// If a header file is specified, it is expected to end in <body> +// If a header file is specified, it is expected to include <body> // and to contain a "TITLE" placeholder line (in column 1, no leading // or trailing white space). The actual document title is later substituted // where that TITLE placeholder appears. @@ -121,7 +121,7 @@ Slice::GeneratorBase::setHeader(const string& header) // // Get the footer. If "footer" is empty, use a default footer. -// The footer is expected to start with </body>. +// The footer is expected to include </body>. // void Slice::GeneratorBase::setFooter(const string& footer) @@ -189,6 +189,7 @@ Slice::GeneratorBase::openDoc(const string& file, const string& title, const str { _out << h2; } + _indexFooter = getFooter(footer); _out.inc(); _out.inc(); } @@ -233,7 +234,7 @@ Slice::GeneratorBase::closeDoc() { _out.dec(); _out.dec(); - _out << nl << _footer; + _out << nl << (!_indexFooter.empty() ? _indexFooter : _footer); _out << nl; } @@ -543,7 +544,7 @@ Slice::GeneratorBase::printSummary(const ContainedPtr& p, const ContainerPtr& mo string Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, bool asTarget, bool inIndex, - unsigned* summarySize) + unsigned* summarySize, bool shortName) { string anchor; string linkpath; @@ -579,7 +580,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(proxy->_class()->definition()); linkpath = getLinkPath(proxy->_class()->definition(), container, inIndex); } - s = getScopedMinimized(proxy->_class(), container); + s = getScopedMinimized(proxy->_class(), container, shortName); } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p); @@ -595,7 +596,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(definition); linkpath = getLinkPath(definition, container, inIndex); } - s = getScopedMinimized(cl, container); + s = getScopedMinimized(cl, container, shortName); } ExceptionPtr ex = ExceptionPtr::dynamicCast(p); @@ -606,7 +607,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(ex); linkpath = getLinkPath(ex, container, inIndex); } - s = getScopedMinimized(ex, container); + s = getScopedMinimized(ex, container, shortName); } StructPtr st = StructPtr::dynamicCast(p); @@ -617,7 +618,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(st); linkpath = getLinkPath(st, container, inIndex); } - s = getScopedMinimized(st, container); + s = getScopedMinimized(st, container, shortName); } EnumeratorPtr en = EnumeratorPtr::dynamicCast(p); @@ -628,7 +629,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(en); linkpath = getLinkPath(en, container, inIndex); } - s = getScopedMinimized(en, container); + s = getScopedMinimized(en, container, shortName); } OperationPtr op = OperationPtr::dynamicCast(p); @@ -639,7 +640,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(op); linkpath = getLinkPath(op, container, inIndex); } - s = getScopedMinimized(op, container); + s = getScopedMinimized(op, container, shortName); } ParamDeclPtr pd = ParamDeclPtr::dynamicCast(p); @@ -652,7 +653,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c anchor = getAnchor(op); linkpath = getLinkPath(op, container, inIndex); } - s = getScopedMinimized(op, container); + s = getScopedMinimized(op, container, shortName); } if(s.empty()) @@ -675,7 +676,7 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c linkpath = getLinkPath(contained, container, inIndex); } } - s = getScopedMinimized(contained, container); + s = getScopedMinimized(contained, container, shortName); } if(summarySize) @@ -891,7 +892,7 @@ Slice::GeneratorBase::getLinkPath(const SyntaxTreeBasePtr& p, const ContainerPtr { path += "/"; } - path += target.front(); + path += target.front() == "index" ? "_index" : target.front(); target.pop_front(); } return path; @@ -982,8 +983,13 @@ Slice::GeneratorBase::getTagged(const string& tag, string& comment) } string -Slice::GeneratorBase::getScopedMinimized(const ContainedPtr& contained, const ContainerPtr& container) +Slice::GeneratorBase::getScopedMinimized(const ContainedPtr& contained, const ContainerPtr& container, bool shortName) { + if(shortName) + { + return contained->name(); + } + string s = contained->scoped(); ContainerPtr p = container; ContainedPtr q = ContainedPtr::dynamicCast(p); @@ -1347,10 +1353,26 @@ Slice::StartPageVisitor::visitModuleStart(const ModulePtr& m) TOCGenerator::TOCGenerator(const Files& files, const string& header, const string& footer) : GeneratorBase(_out, files) { - openDoc("toc.html", "Index", header, footer); - start("H1"); + openDoc("_sindex.html", "Index", header, footer); + start("h1"); _out << "Index"; end(); + + start("table", "ExpandCollapseButton"); + start("tbody"); + + start("td"); + _out << "<button type=\"button\" id=\"ExpandAllButton\">Expand All" + << "<img class=\"ExpandAllButtonImage\"/></button>"; + end(); + + start("td"); + _out << "<button type=\"button\" id=\"CollapseAllButton\">Collapse All" + << "<img class=\"ExpandAllButtonImage\"/></button>"; + end(); + + end(); + end(); } TOCGenerator::~TOCGenerator() @@ -1369,12 +1391,14 @@ TOCGenerator::generate(const ModulePtr& m) void TOCGenerator::writeTOC() { - start("ul"); + _out << nl << "<ul id=\"SymbolTree\""; + _out.inc(); for(ModuleList::const_iterator i = _modules.begin(); i != _modules.end(); ++i) { writeEntry(*i); } - end(); + _out.dec(); + _out << nl << "</ul>"; } void @@ -1448,7 +1472,7 @@ TOCGenerator::writeEntry(const ContainedPtr& c) cl.sort(); cl.unique(); - _out << toString(c, 0, false, true); + _out << toString(c, 0, false, true, 0, true); start("ul"); for(ContainedList::const_iterator i = cl.begin(); i != cl.end(); ++i) { @@ -1458,7 +1482,7 @@ TOCGenerator::writeEntry(const ContainedPtr& c) } else { - _out << toString(c, 0, false, true); + _out << toString(c, 0, false, true, 0, true); } end(); } |