Hi,
I'm developing a Sphinx extension and Django application that I hope
to publicly release soon. The extension allows for commenting on each
node in the documentation.
Docutils makes the starting line number available for each node in the
RST file. However, the node's line number is not always propagated for
some of the custom Sphinx nodes.
It would helpful if the following small patches can be made to:
* sphinx/directives/code.py
* sphinx/directives/other.py
* sphinx/ext/mathbase.py
as given by the attached Mercurial diff output against the latest tip.
These changes simply ensure that the line number, provided by Docutils
via ``self.lineno``, are available in the node object when the various
``visit_ ....`` methods are called later on. The line numbers for
most nodes are already available, but these few were not.
These patches do not break any tests.
Thanks,
Kevin
--
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en.
diff -r f86cc904f833 sphinx/directives/code.py
--- a/sphinx/directives/code.py Mon Aug 23 17:16:45 2010 +0000
+++ b/sphinx/directives/code.py Tue Aug 24 08:23:50 2010 -0400
@@ -62,6 +62,7 @@
literal = nodes.literal_block(code, code)
literal['language'] = self.arguments[0]
literal['linenos'] = 'linenos' in self.options
+ literal.line = self.lineno
return [literal]
@@ -166,6 +167,7 @@
text = text.expandtabs(self.options['tab-width'])
retnode = nodes.literal_block(text, text, source=filename)
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 -r f86cc904f833 sphinx/directives/other.py
--- a/sphinx/directives/other.py Mon Aug 23 17:16:45 2010 +0000
+++ b/sphinx/directives/other.py Tue Aug 24 08:23:50 2010 -0400
@@ -259,6 +259,7 @@
def run(self):
node = addnodes.tabular_col_spec()
node['spec'] = self.arguments[0]
+ node.line = self.lineno
return [node]
diff -r f86cc904f833 sphinx/ext/mathbase.py
--- a/sphinx/ext/mathbase.py Mon Aug 23 17:16:45 2010 +0000
+++ b/sphinx/ext/mathbase.py Tue Aug 24 08:23:50 2010 -0400
@@ -69,6 +69,8 @@
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)