From: William Stein Date: Mon, 18 Dec 2006 02:05:12 +0000 (-0800) Subject: Apply Nick Alexander's patch so that Sagex that embeds positions in module, cdef... X-Git-Tag: 0.9.6.14~29^2~205 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6f8e8da482193fda210d6675304898679aa5b41d;p=cython.git Apply Nick Alexander's patch so that Sagex that embeds positions in module, cdef class, and def class docstrings. --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 95f27e86..12d45ff7 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -123,7 +123,12 @@ class ModuleNode(Node, BlockNode): # body StatListNode def analyse_declarations(self, env): - env.doc = self.doc + if Options.embed_pos_in_docstring: + env.doc = 'File: %s (starting at line %s)'%relative_position(self.pos) + if not self.doc is None: + env.doc = env.doc + '\\n' + self.doc + else: + env.doc = self.doc self.body.analyse_declarations(env) def process_implementation(self, env, result): @@ -2352,7 +2357,10 @@ class PyClassDefNode(StatNode, BlockNode): import ExprNodes self.dict = ExprNodes.DictNode(pos, key_value_pairs = []) if self.doc: - doc_node = ExprNodes.StringNode(pos, value = self.doc) + if Options.embed_pos_in_docstring: + doc = 'File: %s (starting at line %s)'%relative_position(self.pos) + doc = doc + '\\n' + self.doc + doc_node = ExprNodes.StringNode(pos, value = doc) else: doc_node = None self.classobj = ExprNodes.ClassNode(pos, @@ -2447,8 +2455,14 @@ class CClassDefNode(StatNode): visibility = self.visibility, typedef_flag = self.typedef_flag) scope = self.entry.type.scope + if self.doc: - scope.doc = self.doc + if Options.embed_pos_in_docstring: + scope.doc = 'File: %s (starting at line %s)'%relative_position(self.pos) + scope.doc = scope.doc + '\\n' + self.doc + else: + scope.doc = self.doc + if has_body: self.body.analyse_declarations(scope) if self.in_pxd: