Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: tools/dom/scripts/generator.py

Issue 12045076: Second half of HTML json docs. This reads the json file and inserts the docs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/docs/lib/docs.dart ('k') | tools/dom/scripts/htmleventgenerator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/generator.py
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py
index d6bfb7e96cb43bc4703620357213417da646bca9..8293dc20a8616b6636798b7773ae4a70846a8d98 100644
--- a/tools/dom/scripts/generator.py
+++ b/tools/dom/scripts/generator.py
@@ -7,9 +7,16 @@
Dart APIs from the IDL database."""
import copy
+import json
+import os
import re
from htmlrenamer import html_interface_renames
+# Set up json file for retrieving comments.
+current_dir = os.path.dirname(__file__)
blois 2013/01/25 19:16:32 should be private types (_current_dir, etc).
Andrei Mouravski 2013/01/25 19:23:31 Done.
+json_path = os.path.join(current_dir, '..', 'docs', 'docs.json')
+dom_json = json.load(open(json_path))
+
_pure_interfaces = set([
# TODO(sra): DOMStringMap should be a class implementing Map<String,String>.
'DOMStringMap',
@@ -795,7 +802,29 @@ 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.
+ comments = []
+
+ if library_name in dom_json and interface_name in dom_json[library_name]:
+ if member_name and (member_name in
+ dom_json[library_name][interface_name]['members']):
+ comments = dom_json[library_name][interface_name]['members'][member_name]
+ elif 'comment' in dom_json[library_name][interface_name]:
+ comments = dom_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 +832,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 +844,13 @@ def FindCommonAnnotations(interface_name, member_name=None):
return annotations
-def FindDart2JSAnnotations(idl_type, interface_name, member_name):
+def FindDart2JSAnnotationsAndComments(idl_type, interface_name, member_name,
+ 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 +867,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
« no previous file with comments | « tools/dom/docs/lib/docs.dart ('k') | tools/dom/scripts/htmleventgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698