27 from omniidl_be.python
import comment, output_inline
28 from omniidl_be.python
import run
as run_parent
29 from omniidl
import idlvisitor, idlast, idltype
33 li = s.rsplit(old, occurrence)
41 self.commentStart = re.compile(
r"^//+ ?")
43 def _commentToConst(self, node, comments):
50 for c
in reversed(comments):
51 if line - c.line() != 1:
56 texts.append(re.sub(self.commentStart,
"", text))
58 if isinstance(node, idlast.Attribute):
59 for i
in node.identifiers():
60 print(i +
" documentation may be ill-formed.")
62 print(node.identifier() +
" documentation may be ill-formed.")
66 if isinstance(node, idlast.Operation):
67 with open(node.file())
as fp:
68 for _
in range(node.line() - 1):
71 texts.append(
"\nPrototype:\t" + line)
76 texts.append(
" \t" + line)
82 id = node.identifier() +
"__doc__" 90 node.scopedName()[:-1]
94 _rreplace(node.repoId(), node.identifier(), id, 1),
100 def _addDoc(self, parent, node):
104 const = self._commentToConst(node, node.comments())
107 if isinstance(parent, idlast.Module):
108 parent._Module__definitions.append(const)
109 elif isinstance(parent, idlast.Interface):
110 parent._Interface__declarations.append(const)
111 parent._Interface__contents.append(const)
112 elif isinstance(parent, idlast.AST):
113 parent._AST__declarations.append(const)
115 print(
"Doc ignored: " + comment.text())
117 def visitAST(self, node):
118 for n
in node.declarations():
119 if not output_inline
and not n.mainFile():
122 if isinstance(n, idlast.Module)
or isinstance(n, idlast.Interface):
123 self._addDoc(node, n)
126 def visitModule(self, node):
127 for n
in node.definitions():
128 if not output_inline
and not n.mainFile():
131 if isinstance(n, idlast.Module)
or isinstance(n, idlast.Interface):
132 self._addDoc(node, n)
135 def visitInterface(self, node):
136 for c
in node.callables():
137 self._addDoc(node, c)
144 run_parent(tree, args)
def _rreplace(s, old, new, occurrence)