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

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: Line too long. 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 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
« 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