Sphinx output from openstackdoctools adds extra numbered line to code samples

Bug #1416570 reported by Anne Gentle
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openstack-manuals
Fix Released
High
Anne Gentle

Bug Description

With this RST:

Here's an example configuration::

  [DEFAULT]
  ...
  my_ip = 10.0.0.31
  vnc_enabled = True
  vncserver_listen = 0.0.0.0
  vncserver_proxyclient_address = 10.0.0.31
  novncproxy_base_url = http://controller:6080/vnc_auto.html

HTML comes out like this:

<p>Here&#8217;s an example configuration:</p>
<div class="highlight-python"><div class="highlight"><pre>[DEFAULT]
...
my_ip = 10.0.0.31
vnc_enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = 10.0.0.31
novncproxy_base_url = http://controller:6080/vnc_auto.html
</pre></div>
</div>

The original HTML mockup at http://openstack-homepage.bitballoon.com/docs/book has this:

<p>
<pre><code>[DEFAULT]
...
my_ip = 10.0.0.31
vnc_enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = 10.0.0.31
novncproxy_base_url = http://controller:6080/vnc_auto.html</code></pre>
      </p>

Anne Gentle (annegentle)
Changed in openstack-manuals:
status: New → Confirmed
tags: added: openstackdocstheme
Anne Gentle (annegentle)
Changed in openstack-manuals:
importance: Undecided → High
Revision history for this message
Anne Gentle (annegentle) wrote :

When I look at the Inspect Element in Google Chrome, I definitely see that the <pre> text has double quote marks around it, which can explain the extra line count. What I don't know is why that quote mark is added.

Revision history for this message
Anne Gentle (annegentle) wrote :

Debugging further, I can change docs.js to stop an off by one error:

// Needed for code and pre
$(function() {
    var pre = document.getElementsByTagName('pre'),
        pl = pre.length;
    for (var i = 0; i < pl; i++) {
        pre[i].innerHTML = '<span class="line-number"></span>' + pre[i].innerHTML + '<span class="cl"></span>';
        var num = pre[i].innerHTML.split(/\n/).length;
        for (var j = 0; j < (num-1); j++) {
            var line_num = pre[i].getElementsByTagName('span')[0];
            line_num.innerHTML += '<span aria-hidden="true">' + (j + 1) + '</span>';
        }
    }
});

However I think we need to get :lineos: working with Sphinx as a more durable fix for this:
http://sphinx-doc.org/markup/code.html#line-numbers

Anne Gentle (annegentle)
Changed in openstack-manuals:
assignee: nobody → Anne Gentle (annegentle)
Changed in openstack-manuals:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstackdocstheme (master)

Reviewed: https://review.openstack.org/154699
Committed: https://git.openstack.org/cgit/openstack/openstackdocstheme/commit/?id=070cf1331ae71f6fce4347410935c727154094d1
Submitter: Jenkins
Branch: master

commit 070cf1331ae71f6fce4347410935c727154094d1
Author: Anne Gentle <email address hidden>
Date: Tue Feb 10 16:39:56 2015 -0600

    Updates sample to include linenos for Sphinx line numbering

    - Removes function for line numbering for code and pre from docs.js.

    Closes-bug: 1416570

    Change-Id: I7eb2c560d70a5bf04e143b1f35bb773f7e3734c0

Changed in openstack-manuals:
status: In Progress → Fix Released
Anne Gentle (annegentle)
Changed in openstack-manuals:
status: Fix Released → Confirmed
Changed in openstack-manuals:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on openstackdocstheme (master)

Change abandoned by Anne Gentle (<email address hidden>) on branch: master
Review: https://review.openstack.org/158014

Revision history for this message
Anne Gentle (annegentle) wrote :

Fixed with new release 1.0.3

Changed in openstack-manuals:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.