Index: tools/dom/scripts/generator.py |
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py |
index cced66fc41d5eec48181b9d043361ffcee40f57c..0ebccc0855c39741029a7d9504be8f972cc8eb59 100644 |
--- a/tools/dom/scripts/generator.py |
+++ b/tools/dom/scripts/generator.py |
@@ -7,6 +7,8 @@ |
Dart APIs from the IDL database.""" |
import copy |
+import json |
+import os |
import re |
from htmlrenamer import html_interface_renames |
@@ -795,7 +797,32 @@ dart_annotations = { |
'XMLHttpRequestProgressEvent': _webkit_experimental_annotations, |
} |
-def FindCommonAnnotations(interface_name, member_name=None): |
+def GetComments(interface_name, member_name=None, library_name=None): |
+ """ Finds all comments for the interface or member and returns a list. """ |
+ |
+ # Add documentation from JSON. |
+ current_dir = os.path.dirname(__file__) |
+ json_path = os.path.join(current_dir, '..', 'docs', 'docs.json') |
+ html_json = json.load(open(json_path)) |
blois
2013/01/25 18:49:13
dom_json, unless it's only for dart:html.
blois
2013/01/25 18:49:13
Is this really opening & parsing this file for eve
Andrei Mouravski
2013/01/25 19:11:52
Done.
Andrei Mouravski
2013/01/25 19:11:52
Done.
|
+ |
+ comments = [] |
+ |
+ if library_name in html_json and interface_name in html_json[library_name]: |
+ if member_name and member_name in html_json[library_name][interface_name]['members']: |
blois
2013/01/25 18:49:13
line length
Andrei Mouravski
2013/01/25 19:11:52
Done.
|
+ comments = html_json[library_name][interface_name]['members'][member_name] |
+ elif 'comments' in html_json[library_name][interface_name]: |
+ comments = html_json[library_name][interface_name]['comment'] |
+ |
+ return comments |
+ |
+def GetAnnotationsAndComments(interface_name, member_name=None, |
+ library_name=None): |
+ annotations = GetComments(interface_name, member_name, library_name) |
+ annotations.extend(FindCommonAnnotations(interface_name, member_name, |
+ library_name)) |
+ return annotations |
+ |
+def FindCommonAnnotations(interface_name, member_name=None, library_name=None): |
""" Finds annotations common between dart2js and dartium. |
""" |
if member_name: |
@@ -803,7 +830,8 @@ def FindCommonAnnotations(interface_name, member_name=None): |
else: |
key = interface_name |
- annotations = ["@DomName('" + key + "')",] |
+ annotations = ["@DomName('" + key + "')"] |
+ |
# Only add this for members, so we don't add DocsEditable to templated classes |
# (they get it from the default class template) |
if member_name: |
@@ -814,11 +842,13 @@ def FindCommonAnnotations(interface_name, member_name=None): |
return annotations |
-def FindDart2JSAnnotations(idl_type, interface_name, member_name): |
+def FindDart2JSAnnotations(idl_type, interface_name, member_name, |
blois
2013/01/25 18:49:13
Should rename to include comments.
Andrei Mouravski
2013/01/25 19:11:52
Done.
|
+ library_name=None): |
""" Finds all annotations for Dart2JS members- including annotations for |
both dart2js and dartium. |
""" |
- annotations = FindCommonAnnotations(interface_name, member_name) |
+ annotations = GetAnnotationsAndComments(interface_name, member_name, |
+ library_name) |
ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name) |
if ann2: |
@@ -835,7 +865,7 @@ def AnyConversionAnnotations(idl_type, interface_name, member_name): |
else: |
return False |
-def FormatAnnotations(annotations, indentation): |
+def FormatAnnotationsAndComments(annotations, indentation): |
if annotations: |
newline = '\n%s' % indentation |
result = newline.join(annotations) + newline |