1.1 --- a/micropython/report.py Sun Jul 08 19:21:56 2012 +0200
1.2 +++ b/micropython/report.py Sun Jul 08 21:01:52 2012 +0200
1.3 @@ -129,7 +129,8 @@
1.4 }
1.5
1.6 .attrnames a,
1.7 - .opnames a {
1.8 + .opnames a,
1.9 + .scope a {
1.10 color: white;
1.11 }
1.12
1.13 @@ -287,8 +288,14 @@
1.14 classes or "specific-ref", module_name, os.path.extsep,
1.15 self._attr(full_name), self._text(name)))
1.16
1.17 - def _scope(self, scope):
1.18 - self.stream.write("<div class='scope'><span class='label'>scope</span><br />%s</div>\n" % scope)
1.19 + def _scope(self, scope, attr):
1.20 + self.stream.write("<div class='scope'>"
1.21 + "<span class='label'>scope</span><br />%s<br/>" % scope)
1.22 + values = self._values_to_attribute_names(attr)
1.23 + if values:
1.24 + self.stream.write("<span class='label'>values</span><br />")
1.25 + self._attribute_list(values)
1.26 + self.stream.write("</div>\n")
1.27
1.28 def _assname(self, name, node):
1.29 self._span_start("assname")
1.30 @@ -368,42 +375,61 @@
1.31 if target_names:
1.32 self._span_end()
1.33
1.34 + def _values_to_attribute_names(self, attr):
1.35 +
1.36 + "Get the output form of the values referenced by 'attr'."
1.37 +
1.38 + if isinstance(attr, Instance):
1.39 + return [(str(attr), attr)]
1.40 +
1.41 + values = []
1.42 + for v in attr.get_values():
1.43 + if not isinstance(v, Instance):
1.44 + values.append((v.full_name(), v))
1.45 +
1.46 + values.sort()
1.47 + return values
1.48 +
1.49 + def _attributes_to_attribute_names(self, attributes, attrname):
1.50 +
1.51 + "Get the output form of the 'attributes'."
1.52 +
1.53 + output = []
1.54 + for value, target, target_name in attributes:
1.55 + if value and not isinstance(value, Instance):
1.56 + fullname = value.full_name()
1.57 + else:
1.58 + fullname = target_name + "." + attrname
1.59 + output.append((fullname, value))
1.60 +
1.61 + output.sort()
1.62 + return output
1.63 +
1.64 def _attribute_start(self, attrname, attributes):
1.65 if attributes:
1.66 -
1.67 - # Get the output form of the attributes.
1.68 -
1.69 - output = []
1.70 - for value, target, target_name in attributes:
1.71 - if value and not isinstance(value, Instance):
1.72 - fullname = value.full_name()
1.73 - else:
1.74 - fullname = target_name + "." + attrname
1.75 - output.append((fullname, value))
1.76 -
1.77 - output.sort()
1.78 -
1.79 self._span_start("attr")
1.80 self._popup_start("attributes-popup")
1.81 self._names_list_start("attributes", "attrnames")
1.82 -
1.83 - # Mix links to attributes with labels indicating undetermined
1.84 - # attributes.
1.85 -
1.86 - last = None
1.87 - for fullname, value in output:
1.88 - if fullname != last:
1.89 - if last is not None:
1.90 - self.stream.write("<br />")
1.91 - if value is not None and not isinstance(value, Instance):
1.92 - self._object_name_ref(value.module, value, fullname, classes="attribute-name")
1.93 - else:
1.94 - self.stream.write(fullname)
1.95 - last = fullname
1.96 -
1.97 + self._attribute_list(attributes)
1.98 self._names_list_end()
1.99 self._popup_end()
1.100
1.101 + def _attribute_list(self, attributes):
1.102 +
1.103 + # Mix links to attributes with labels indicating undetermined
1.104 + # attributes.
1.105 +
1.106 + last = None
1.107 + for fullname, value in attributes:
1.108 + if fullname != last:
1.109 + if last is not None:
1.110 + self.stream.write("<br />")
1.111 + if value is not None and not isinstance(value, Instance):
1.112 + self._object_name_ref(value.module, value, fullname, classes="attribute-name")
1.113 + else:
1.114 + self.stream.write(fullname)
1.115 + last = fullname
1.116 +
1.117 def _attribute_end(self, attributes):
1.118 if attributes:
1.119 self._span_end()
1.120 @@ -1001,7 +1027,7 @@
1.121 if not wraps_getattr:
1.122 self._accessor_end(target_names)
1.123 self.stream.write(".")
1.124 - self._attribute_start(node.attrname, attributes)
1.125 + self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
1.126 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
1.127 self._attribute_end(attributes)
1.128 if not wraps_getattr:
1.129 @@ -1101,7 +1127,7 @@
1.130 if not wraps_getattr:
1.131 self._accessor_end(target_names)
1.132 self.stream.write(".")
1.133 - self._attribute_start(node.attrname, attributes)
1.134 + self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
1.135 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
1.136 self._attribute_end(attributes)
1.137 if not wraps_getattr:
1.138 @@ -1226,7 +1252,7 @@
1.139 self._name_start()
1.140 self.stream.write(node.name)
1.141 self._popup_start()
1.142 - self._scope(scope)
1.143 + self._scope(node._scope, node._attr)
1.144 self._popup_end()
1.145 self._name_end()
1.146 else: