Permalink
Browse files

supports 3.x attribute change event syntax

  • Loading branch information...
1 parent d4ed2ee commit 7d5a799eda5fa367a43192f0c51140bbe4356f9c Adam Moore committed Aug 1, 2008
Showing with 70 additions and 78 deletions.
  1. +1 −0 bin/const.py
  2. BIN bin/const.pyc
  3. +65 −26 bin/yuidoc_parse.py
  4. +1 −1 template/assets/ac-js
  5. +3 −51 template/main.tmpl
View
1 bin/const.py
@@ -37,6 +37,7 @@
LOGCONFIG='yuidoclog.conf'
METHOD='method'
METHODS='methods'
+MAJOR_VERSION='majorversion'
MODULE='module'
MODULE_PREFIX='module_'
MODULES='modules'
View
BIN bin/const.pyc
Binary file not shown.
View
91 bin/yuidoc_parse.py
@@ -64,9 +64,18 @@ def parseDir(path):
# the remainder of the file with the comment blocks removed
# self.stripped = ""
+ majorVersion = version[:1]
+ try:
+ majorVersion = int(majorVersion)
+ except:
+ majorVersion = 3
# Dictionary of parsed data
- self.data = { const.VERSION: version, const.CLASS_MAP: {}, const.MODULES: {} }
+ self.data = {
+ const.VERSION: version,
+ const.MAJOR_VERSION: majorVersion,
+ const.CLASS_MAP: {},
+ const.MODULES: {} }
self.inputdirs = inputdirs
self.outputdir = os.path.abspath(outputdir)
@@ -653,33 +662,63 @@ def parseModule(tokenMap):
if not const.EVENTS in c: c[const.EVENTS] = {}
+ def getAttEvt(eventname, desc):
+
+ return {
+ const.NAME: eventname,
+ const.DESCRIPTION: desc,
+ const.PARAMS: [{
+ const.NAME: const.EVENT,
+ const.TYPE: "{oldValue: any, newValue: any}",
+ const.DESCRIPTION: "An object containing the previous attribute value and the new value."
+ }]
+ }
+
+ def get3xAttEvt(eventname, config):
+
+ return {
+ const.NAME: eventname,
+ const.DESCRIPTION: 'Fires when the value for the configuration attribute \'%s\' is \
+changed. You can listen for the event using the <a href="Attribute.html#method_on>on</a> \
+method if you wish to be notified before the attribute\'s value has changed, or using the \
+<a href="Event.Target.html#method_after>after</a> method if you wish to be notified after \
+the attribute\'s value has changed.' %(config),
+ const.PARAMS: [{
+ const.NAME: const.EVENT,
+ const.TYPE: "Event.Facade",
+ const.DESCRIPTION: 'An Event Facade object with \
+ the following attribute specific properties added:\
+ <dl>\
+ <dt>prevVal</dt>\
+ <dd>The value of the attribute, prior to it being set</dd>\
+ <dt>newVal</dt>\
+ <dd>The value the attribute is to be set to</dd>\
+ <dt>attrName</dt>\
+ <dd>The name of the attribute being set</dd>\
+ <dt>subAttrName</dt>\
+ <dd>If setting a property within the attribute\'s value,\
+ the name of the sub-attribute property being set</dd>\
+ </dl>'
+ }]
+ }
+
# auto-document '[configname]ChangeEvent' and 'before[Configname]ChangeEvent'
- eventname = config + const.CHANGEEVENT
+ if self.data[const.MAJOR_VERSION] > 2:
+
+ eventname = config + const.CHANGEEVENT
+ c[const.EVENTS][eventname] = get3xAttEvt(eventname, config)
+
+ else:
+
+ eventname = config + const.CHANGEEVENT
+ desc = "Fires when the value for the configuration attribute '" + config + "' changes."
+ c[const.EVENTS][eventname] = getAttEvt(eventname, desc)
+
+ eventname = const.BEFORE + config[0].upper() + config[1:] + const.CHANGEEVENT
+ desc = "Fires before the value for the configuration attribute '" + config + "' changes." + " Return false to cancel the attribute change."
+ c[const.EVENTS][eventname] = getAttEvt(eventname, desc)
+
- c[const.EVENTS][eventname] = {
- const.NAME: eventname,
- const.DESCRIPTION: "Fires when the value for the configuration attribute '" + config + "' changes.",
- const.PARAMS: [{
- const.NAME: "eventInfo",
- const.TYPE: "{oldValue: any, newValue: any}",
- const.DESCRIPTION: "An object containing the previous attribute value and the new value."
- }]
- }
-
- # eventname = const.BEFORE + config.capitalize() + const.CHANGEEVENT
- eventname = const.BEFORE + config[0].upper() + config[1:] + const.CHANGEEVENT
-
- c[const.EVENTS][eventname] = {
- const.NAME: eventname,
- const.DESCRIPTION: "Fires before the value for the configuration attribute '" + config + "' changes." +
- " Return false to cancel the attribute change.",
- const.PARAMS: [{
- const.NAME: "eventInfo",
- const.TYPE: "{oldValue: any, newValue: any}",
- const.DESCRIPTION: "An object containing the current attribute value and the new value.",
- # const.RETURN: "Return false to cancel the attribute change"
- }]
- }
else:
tokenMap.pop(const.CONFIG)
View
2 template/assets/ac-js
@@ -88,7 +88,7 @@
var className=(show) ? "": "none";
var els=Dom.getElementsByClassName(type);
- // console.log('showhide ' + type + ', ' + els.length);
+ console.log('showhide ' + type + ', ' + els.length);
for (var i=0,l=els.length;i<l;i=i+1) {
//try {
View
54 template/main.tmpl
@@ -21,7 +21,6 @@
#if $classname# &gt; $classname #end if#
#if $filename# &gt; $filename (source view) #end if#
</p>
-
#end if
</div>
@@ -30,9 +29,9 @@
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
- <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
- <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
- <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
+ <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
+ <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
+ <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
</form>
#if $index
@@ -277,20 +276,12 @@
<dd>$method.return.description</dd>
</dl>
#end if
-
- #if $method.chainable
- <div class="chainable">
- <strong>Chainable:</strong> This method is chainable.
- </div>
- #end if
-
#if $method.deprecated
<div class="deprecated">
<strong>Deprecated</strong> $method.deprecated
</div>
#end if
-
</div>
</div>
@@ -368,16 +359,6 @@
</dl>
#end if
- #if $event.bubbles
- <div class="bubbles">
- <strong>Bubbles:</strong> This event bubbles to <a href="${event.bubbles}.html">$event.bubbles</a>.
- </div>
- #end if
- #if $event.preventable
- <div class="preventable">
- <strong>Preventable:</strong> This event is preventable by method: $event.preventable.
- </div>
- #end if
#if $event.deprecated
<div class="deprecated">
@@ -480,8 +461,6 @@
<div class="description summary">
$moduledesc
</div>
-
-
#if $requires
<div class="content">
Requires: $requires
@@ -493,8 +472,6 @@
</div>
#end if
-<div class="yui-gc">
- <div class="yui-u first">
<form onsubmit="return false">
<p>Search ${modulename}:
<div id="propertysearch">
@@ -507,32 +484,7 @@
<script type="text/javascript">
ALL_YUI_PROPS = $allprops;
</script>
- </div>
- <div class="yui-u">
- #set count = 0;
- #for $info in $submodules
- #set count = count + 1
- #end for
- #if count != 0
- <style>
- .submodules dd {
- font-size: 93%;
- font-weight: italic;
- }
- </style>
- <div class="submodules">
- <h4>Submodules:</h4>
- <dl>
- #for $info in $submodules
- <dt><code><a href="${$subdata[$info].name}.html">$info</a></code></dt>
- <dd>$subdata[$info].description</dd>
- #end for
- </dl>
- </div>
- #end if
- </div>
-</div>
#end if
</div>

0 comments on commit 7d5a799

Please sign in to comment.