summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-07 11:16:55 +0100
committerGeorg Brandl <georg@python.org>2011-01-07 11:16:55 +0100
commit33ed935df287f958097f018246e4bb7f17582d78 (patch)
treef5fbf460d248e8402823d03cbd36fb4d3e815a2c
parentc50054c8dab65814c18c38b3f6ef60fc2e2d007f (diff)
downloadsphinx-git-33ed935df287f958097f018246e4bb7f17582d78.tar.gz
Add line numbers to newly generated nodes.
-rw-r--r--sphinx/directives/code.py2
-rw-r--r--sphinx/directives/other.py1
-rw-r--r--sphinx/ext/mathbase.py2
3 files changed, 5 insertions, 0 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index f72af912d..bfde48e58 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -64,6 +64,7 @@ class CodeBlock(Directive):
literal = nodes.literal_block(code, code)
literal['language'] = self.arguments[0]
literal['linenos'] = 'linenos' in self.options
+ literal.line = self.lineno
return [literal]
@@ -180,6 +181,7 @@ class LiteralInclude(Directive):
text = text.expandtabs(self.options['tab-width'])
retnode = nodes.literal_block(text, text, source=fn)
retnode.line = 1
+ retnode.attributes['line_number'] = self.lineno
if self.options.get('language', ''):
retnode['language'] = self.options['language']
if 'linenos' in self.options:
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py
index 873fef046..d39a338d5 100644
--- a/sphinx/directives/other.py
+++ b/sphinx/directives/other.py
@@ -260,6 +260,7 @@ class TabularColumns(Directive):
def run(self):
node = addnodes.tabular_col_spec()
node['spec'] = self.arguments[0]
+ node.line = self.lineno
return [node]
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py
index 27c211ef7..e7258300a 100644
--- a/sphinx/ext/mathbase.py
+++ b/sphinx/ext/mathbase.py
@@ -69,6 +69,8 @@ class MathDirective(Directive):
node['nowrap'] = 'nowrap' in self.options
node['docname'] = self.state.document.settings.env.docname
ret = [node]
+ node.line = self.lineno
+ node.source = self.src
if node['label']:
tnode = nodes.target('', '', ids=['equation-' + node['label']])
self.state.document.note_explicit_target(tnode)