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

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

Issue 12087112: Can now correctly add documentation to constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 5d18f07d233e31746db7316654a9c53ddf39ecc7..e2d5fb3a572a579692349e4292115adc43d76c27 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -9,7 +9,8 @@ dart:html APIs from the IDL database."""
import emitter
from generator import AnalyzeOperation, ConstantOutputOrder, \
DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \
- IsPureInterface, TypeOrNothing
+ IsPureInterface, TypeOrNothing, GetAnnotationsAndComments, \
+ FormatAnnotationsAndComments
# Types that are accessible cross-frame in a limited fashion.
# In these cases, the base type (e.g., WindowBase) provides restricted access
@@ -297,7 +298,7 @@ class HtmlDartGenerator(object):
return implements
def AddConstructors(self,
- constructors, factory_name, factory_constructor_name):
+ constructors, factory_name, factory_constructor_name, library_name):
blois 2013/01/31 20:45:28 I'd just put libary_name in the constructor of thi
Andrei Mouravski 2013/01/31 23:03:40 Done.
""" Adds all of the constructors.
Arguments:
constructors - List of the constructors to be added.
@@ -308,7 +309,8 @@ class HtmlDartGenerator(object):
"""
for constructor_info in constructors:
self._AddConstructor(
- constructor_info, factory_name, factory_constructor_name)
+ constructor_info, factory_name, factory_constructor_name,
+ library_name)
typed_array_type = None
for interface in self._database.Hierarchy(self._interface):
@@ -316,28 +318,43 @@ class HtmlDartGenerator(object):
if type_info.is_typed_array():
typed_array_type = type_info.list_item_type()
break
+
+ annotations = FormatAnnotationsAndComments(
+ GetAnnotationsAndComments(self._interface.id, self._interface.id,
+ library_name=library_name), ' ')
blois 2013/01/31 20:45:28 Library name isn't really optional, it should be a
Andrei Mouravski 2013/01/31 23:03:40 Done.
+
+ fromListAnnotations = FormatAnnotationsAndComments(
+ GetAnnotationsAndComments(self._interface.id, 'fromList',
+ library_name=library_name), ' ')
+
+ fromBufferAnnotations = FormatAnnotationsAndComments(
+ GetAnnotationsAndComments(self._interface.id, 'fromBuffer',
+ library_name=library_name), ' ')
+
if typed_array_type:
self._members_emitter.Emit(
- '\n'
- ' factory $CTOR(int length) =>\n'
+ '\n $(ANNOTATIONS)factory $CTOR(int length) =>\n'
' $FACTORY.create$(CTOR)(length);\n'
- '\n'
- ' factory $CTOR.fromList(List<$TYPE> list) =>\n'
+ '\n $(LIST_ANNOTATIONS)factory $CTOR.fromList(List<$TYPE> list) =>\n'
' $FACTORY.create$(CTOR)_fromList(list);\n'
- '\n'
- ' factory $CTOR.fromBuffer(ArrayBuffer buffer, '
+ '\n $(BUFFER_ANNOTATIONS)factory $CTOR.fromBuffer(ArrayBuffer buffer, '
'[int byteOffset, int length]) => \n'
' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n',
CTOR=self._interface.id,
+ ANNOTATIONS=annotations,
+ LIST_ANNOTATIONS=fromListAnnotations,
+ BUFFER_ANNOTATIONS=fromBufferAnnotations,
TYPE=self._DartType(typed_array_type),
FACTORY=factory_name)
def _AddConstructor(self,
- constructor_info, factory_name, factory_constructor_name):
+ constructor_info, factory_name, factory_constructor_name, library_name):
if self.GenerateCustomFactory(constructor_info):
return
- self._members_emitter.Emit('\n @DocsEditable');
+ annotations = FormatAnnotationsAndComments(
+ GetAnnotationsAndComments(self._interface.id, self._interface.id,
+ library_name=library_name), ' ')
if not factory_constructor_name:
factory_constructor_name = '_create'
@@ -354,25 +371,27 @@ class HtmlDartGenerator(object):
if not has_optional:
self._members_emitter.Emit(
- '\n'
- ' factory $CTOR($PARAMS) => '
+ '\n $(ANNOTATIONS)'
+ 'factory $CTOR($PARAMS) => '
'$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n',
CTOR=constructor_info._ConstructorFullName(self._DartType),
PARAMS=constructor_info.ParametersDeclaration(self._DartType),
FACTORY=factory_name,
+ ANNOTATIONS=annotations,
CTOR_FACTORY_NAME=factory_constructor_name,
FACTORY_PARAMS=factory_parameters)
else:
if has_factory_provider:
dispatcher_emitter = self._members_emitter.Emit(
- '\n'
- ' factory $CTOR($PARAMS) {\n'
+ '\n $(ANNOTATIONS)'
+ 'factory $CTOR($PARAMS) {\n'
'$!DISPATCHER'
' return $FACTORY._create($FACTORY_PARAMS);\n'
' }\n',
CTOR=constructor_info._ConstructorFullName(self._DartType),
PARAMS=constructor_info.ParametersDeclaration(self._DartType),
FACTORY=factory_name,
+ ANNOTATIONS=annotations,
FACTORY_PARAMS=constructor_info.ParametersAsArgumentList())
for index, param_info in enumerate(constructor_info.param_infos):
@@ -386,13 +405,14 @@ class HtmlDartGenerator(object):
FACTORY_PARAMS=constructor_info.ParametersAsArgumentList(index))
else:
inits = self._members_emitter.Emit(
- '\n'
- ' factory $CONSTRUCTOR($PARAMS) {\n'
+ '\n $(ANNOTATIONS)'
+ 'factory $CONSTRUCTOR($PARAMS) {\n'
' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n'
'$!INITS'
' return e;\n'
' }\n',
CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType),
+ ANNOTATIONS=annotations,
FACTORY=factory_name,
CTOR_FACTORY_NAME=factory_constructor_name,
PARAMS=constructor_info.ParametersDeclaration(self._DartType),
@@ -422,8 +442,9 @@ class HtmlDartGenerator(object):
constructor_info.idl_args,
False,
[info.name for info in constructor_info.param_infos],
- emitter.Format('factory $CTOR($PARAMS)',
+ emitter.Format('$(ANNOTATIONS)factory $CTOR($PARAMS)',
CTOR=constructor_info._ConstructorFullName(self._DartType),
+ ANNOTATIONS=annotations,
PARAMS=constructor_info.ParametersDeclaration(self._DartType)),
GenerateCall,
IsOptional)

Powered by Google App Engine
This is Rietveld 408576698