From 6f8e8da482193fda210d6675304898679aa5b41d Mon Sep 17 00:00:00 2001 From: William Stein Date: Sun, 17 Dec 2006 18:05:12 -0800 Subject: [PATCH] Apply Nick Alexander's patch so that Sagex that embeds positions in module, cdef class, and def class docstrings. --- Cython/Compiler/Nodes.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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: -- 2.26.2