3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
7 from caffe2.python.docs.formatter
import Markdown
8 from caffe2.python.docs.generator
import OpDocGenerator, DocUploader
9 from caffe2.python.docs.generator
import OperatorDoc, OperatorEngine
17 def upload(self, content_body):
22 def addHeader(self, text, h=1):
25 self.addLine(
"{header} {text}".format(header=h *
'#', text=text),
True)
27 def addTable(self, table, noTitle=False):
28 self.addRaw(
"<table>")
33 self.addLine(
"{cell}".format(cell=cell))
36 self.addRaw(
"</table>")
39 def getCodeLink(formatter, schema):
40 formatter = formatter.clone()
41 path = os.path.relpath(schema.file,
"caffe2")
42 schemaLink = (
'https://github.com/caffe2/caffe2/blob/master/{path}' 44 formatter.addLink(
'{path}'.format(path=path), schemaLink)
45 return formatter.dump()
49 def generateDoc(self, formatter, schema):
50 for device, _
in self.getDeviceImpl():
51 formatter.addCode(
'{engine}'.format(engine=self.engine),
True)
53 formatter.addRaw(
' on ')
54 formatter.addEmphasis(
"{device}".format(device=device), 1)
58 def generateCodeLink(self, formatter):
59 formatter.addHeader(
"Code", 3)
60 formatter.addRaw(getCodeLink(formatter, self.schema))
62 def getInfo(self, formatter, name, impl):
63 formatter = formatter.clone()
65 formatter.addEmphasis(
'{name}'.format(name=name), 1)
67 formatter.addCode(
'{impl}'.format(impl=impl),
True)
68 return formatter.dump()
72 def getOperatorDoc(self, name, schema, priority):
75 def getOperatorEngine(self, name):
79 if __name__ ==
"__main__":
82 print(ops.content_body)