Commit 6f8e8da4 authored by William Stein's avatar William Stein

Apply Nick Alexander's patch so that Sagex that embeds positions in module,...

Apply Nick Alexander's patch so that Sagex that embeds positions in module, cdef class, and def class docstrings.
parent f4961542
...@@ -123,6 +123,11 @@ class ModuleNode(Node, BlockNode): ...@@ -123,6 +123,11 @@ class ModuleNode(Node, BlockNode):
# body StatListNode # body StatListNode
def analyse_declarations(self, env): def analyse_declarations(self, env):
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 env.doc = self.doc
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
...@@ -2352,7 +2357,10 @@ class PyClassDefNode(StatNode, BlockNode): ...@@ -2352,7 +2357,10 @@ class PyClassDefNode(StatNode, BlockNode):
import ExprNodes import ExprNodes
self.dict = ExprNodes.DictNode(pos, key_value_pairs = []) self.dict = ExprNodes.DictNode(pos, key_value_pairs = [])
if self.doc: 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: else:
doc_node = None doc_node = None
self.classobj = ExprNodes.ClassNode(pos, self.classobj = ExprNodes.ClassNode(pos,
...@@ -2447,8 +2455,14 @@ class CClassDefNode(StatNode): ...@@ -2447,8 +2455,14 @@ class CClassDefNode(StatNode):
visibility = self.visibility, visibility = self.visibility,
typedef_flag = self.typedef_flag) typedef_flag = self.typedef_flag)
scope = self.entry.type.scope scope = self.entry.type.scope
if self.doc: if 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 scope.doc = self.doc
if has_body: if has_body:
self.body.analyse_declarations(scope) self.body.analyse_declarations(scope)
if self.in_pxd: if self.in_pxd:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment