On Fri, Jan 7, 2011 at 05:17, Georg Brandl <ge...@python.org> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Am 24.08.2010 15:53, schrieb Kevin Dunn: >> 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. > > This is now committed to 1.0 and trunk. > > Thanks, > Georg
Hi Georg, Thanks for applying my patch. However I just noticed that when running on a system that has docutils version 0.5 that it will break mathematics functionality: any document that uses the ``.. math::`` directive will raise an error. I've pasted an example of the Sphinx error below this message. It seems that docutils 0.5 does not have a ``.src`` attribute in its class definition for ``Directive`` (docutils/parsers/rst/__init__.py). When I supplied that patch I was using docutils version 0.7, which does have a ``.src`` attribute. The obvious solution is to remove a line in my patch:: node.source = self.src from ``sphinx/ext/mathbase.py``; or to raise the docutils dependency to a higher version :) I apologize for this; I'll be sure to test any future patches on the minimal Sphinx requirements before submitting them. Thanks, Kevin ------ # Sphinx version: 1.1pre # Python version: 2.6.5 # Docutils version: 0.5 release # Jinja2 version: 2.5.2 Traceback (most recent call last): File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/cmdline.py", line 188, in main app.build(force_all, filenames) File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/application.py", line 204, in build self.builder.build_update() File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/builders/__init__.py", line 193, in build_update 'out of date' % len(to_build)) File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/builders/__init__.py", line 213, in build purple, length): File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/builders/__init__.py", line 117, in status_iterator for item in iterable: File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/environment.py", line 583, in update_generator self.read_doc(docname, app=app) File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/environment.py", line 730, in read_doc pub.publish() File "/usr/local/lib/python2.6/site-packages/docutils/core.py", line 204, in publish self.settings) File "/usr/local/lib/python2.6/site-packages/docutils/readers/__init__.py", line 69, in read self.parse() File "/usr/local/lib/python2.6/site-packages/docutils/readers/__init__.py", line 75, in parse self.parser.parse(self.input, document) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/__init__.py", line 157, in parse self.statemachine.run(inputlines, document, inliner=self.inliner) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/states.py", line 170, in run input_source=document['source']) File "/usr/local/lib/python2.6/site-packages/docutils/statemachine.py", line 232, in run context, state, transitions) File "/usr/local/lib/python2.6/site-packages/docutils/statemachine.py", line 420, in check_line return method(match, context, next_state) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/states.py", line 2239, in explicit_markup nodelist, blank_finish = self.explicit_construct(match) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/states.py", line 2251, in explicit_construct return method(self, expmatch) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/states.py", line 1994, in directive directive_class, match, type_name, option_presets) File "/usr/local/lib/python2.6/site-packages/docutils/parsers/rst/states.py", line 2043, in run_directive result = directive_instance.run() File "/home/kevindunn/lib/python2.6/Sphinx-1.1pre_f977def00a09dev_20110107-py2.6.egg/sphinx/ext/mathbase.py", line 74, in run node.source = self.src AttributeError: MathDirective instance has no attribute 'src' ------ -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-dev@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.