aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-10-07 12:21:59 +0200
committerMs2ger <Ms2ger@gmail.com>2015-10-07 12:21:59 +0200
commit03b04e5363c864432db139b0beb25c8804c2ee70 (patch)
tree2eae5a76b9f8bf9ead9cadef3cbd2ad836639e6a /components/script/dom/bindings/codegen/CodegenRust.py
parent409fbafe9cdd16a2b5a25f64eae0bc11d6fc9aa1 (diff)
downloadservo-03b04e5363c864432db139b0beb25c8804c2ee70.tar.gz
servo-03b04e5363c864432db139b0beb25c8804c2ee70.zip
Add support for documenting CGAbstractMethods.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 49c0cf52cbc..910f1431897 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2064,10 +2064,12 @@ class CGAbstractMethod(CGThing):
If templateArgs is not None it should be a list of strings containing
template arguments, and the function will be templatized using those
arguments.
+
+ docs is None or documentation for the method in a string.
"""
def __init__(self, descriptor, name, returnType, args, inline=False,
alwaysInline=False, extern=False, pub=False, templateArgs=None,
- unsafe=False):
+ unsafe=False, docs=None):
CGThing.__init__(self)
self.descriptor = descriptor
self.name = name
@@ -2078,6 +2080,7 @@ class CGAbstractMethod(CGThing):
self.templateArgs = templateArgs
self.pub = pub
self.unsafe = unsafe
+ self.docs = docs
def _argstring(self):
return ', '.join([a.declare() for a in self.args])
@@ -2087,6 +2090,13 @@ class CGAbstractMethod(CGThing):
return ''
return '<%s>\n' % ', '.join(self.templateArgs)
+ def _docs(self):
+ if self.docs is None:
+ return ''
+
+ lines = self.docs.splitlines()
+ return ''.join('/// %s\n' % line for line in lines)
+
def _decorators(self):
decorators = []
if self.alwaysInline:
@@ -2118,8 +2128,9 @@ class CGAbstractMethod(CGThing):
post=self.definition_epilogue()).define()
def definition_prologue(self):
- return "%sfn %s%s(%s)%s {\n" % (self._decorators(), self.name, self._template(),
- self._argstring(), self._returnType())
+ return "%s%sfn %s%s(%s)%s {\n" % (self._docs(), self._decorators(),
+ self.name, self._template(),
+ self._argstring(), self._returnType())
def definition_epilogue(self):
return "\n}\n"