Message ID | B27915DBBA3421428155699D51E4CFE2F183E8@IRSMSX103.ger.corp.intel.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2DAA2CB40; Thu, 30 Apr 2015 15:34:39 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C1262CB3A for <dev@dpdk.org>; Thu, 30 Apr 2015 15:34:36 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 30 Apr 2015 06:34:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,677,1422950400"; d="scan'208";a="721622257" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga002.jf.intel.com with ESMTP; 30 Apr 2015 06:34:16 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.76]) by IRSMSX152.ger.corp.intel.com ([169.254.6.7]) with mapi id 14.03.0224.002; Thu, 30 Apr 2015 14:34:15 +0100 From: "Mcnamara, John" <john.mcnamara@intel.com> To: Thomas Monjalon <thomas.monjalon@6wind.com> Thread-Topic: [dpdk-dev] [PATCH 0/2] doc: refactored fig and table nums into references Thread-Index: AQHQfpA8J0zr7EQ+/ESRicUEUY/zUJ1kIMIAgAFk/JA= Date: Thu, 30 Apr 2015 13:34:15 +0000 Message-ID: <B27915DBBA3421428155699D51E4CFE2F183E8@IRSMSX103.ger.corp.intel.com> References: <1429881109-16684-1-git-send-email-john.mcnamara@intel.com> <4018323.hxXVqqSkHq@xps13> In-Reply-To: <4018323.hxXVqqSkHq@xps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" <dev@dpdk.org> Subject: Re: [dpdk-dev] [PATCH 0/2] doc: refactored fig and table nums into references X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Mcnamara, John
April 30, 2015, 1:34 p.m. UTC
> -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Wednesday, April 29, 2015 5:13 PM > To: Mcnamara, John > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 0/2] doc: refactored fig and table nums > into references > > is really a great work but I think it's not reasonnable to require > sphinx 1.3. As almost nobody is using this version, it would be equivalent > to prevent users and developers to generate the doc by themselves. Hi Thomas, Yes. That is probably right. > It produces this error: > ERROR: Unknown interpreted text role "numref". > > Do you think it's possible to implement a fallback in our conf.py in order > to ignore this new role if not supported? It would be possible but a full implementation probably wouldn't be worth it. We could add a workaround like the following to conf.py that would just render the figure/table ref numbers as the target name as a fallback. That would allow people to generate the docs with older versions of sphinx: $ git diff doc/guides/conf.py That is just a workaround though, and maybe not worth it either. P.S. Also note, Sphinx 1.3.1 has a nice but very different default Html style. John
Comments
2015-04-30 13:34, Mcnamara, John: > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > > It produces this error: > > ERROR: Unknown interpreted text role "numref". > > > > Do you think it's possible to implement a fallback in our conf.py in order > > to ignore this new role if not supported? > > It would be possible but a full implementation probably wouldn't be worth it. > We could add a workaround like the following to conf.py that would just > render the figure/table ref numbers as the target name as a fallback. > That would allow people to generate the docs with older versions of sphinx: > > +from docutils import nodes > +from distutils.version import LooseVersion > +from sphinx import __version__ as sphinx_version > + > +# Workaround to ignore :numref: in older versions of Sphinx. > +def setup(app): > + > + if LooseVersion(sphinx_version) < LooseVersion('1.3.1'): > + print('[dpdk docs] Upgrade sphinx to version >= 1.3.1 for ' > + 'improved Figure/Table number handling.') > + app.add_generic_role('numref', nodes.emphasis) > > That is just a workaround though, and maybe not worth it either. The error is removed so it's better. With this patch, a figure reference looks like this: :numref:`figure_single_port_nic` Virtualization for a Single Port NIC in SR-IOV Mode The rst line is: :numref:`figure_single_port_nic` :ref:`figure_single_port_nic` I was trying to replace the numref output by a working link with "figure" as label. This is my trial to mimic :ref: as a first step: 8<------------------------ from docutils import nodes from distutils.version import LooseVersion from sphinx import __version__ as sphinx_version from sphinx import addnodes from sphinx.roles import XRefRole class XNumRefNode(addnodes.pending_xref): def __init__(self, rawsource='', *children, **attributes): attributes['reftype'] = 'ref' super(XNumRefNode, self).__init__(rawsource, *children, **attributes) class XNumRefRole(XRefRole): def __init__(self): super(XNumRefRole, self).__init__(nodeclass=XNumRefNode, innernodeclass=nodes.emphasis, warn_dangling=True) def setup(app): if LooseVersion(sphinx_version) < LooseVersion('1.3.1'): print('Upgrade sphinx to version >= 1.3.1 for ' 'improved Figure/Table number handling.') app.add_node(XNumRefNode) app.add_role('numref', XNumRefRole()) 8<------------------------ Unfortunately it gives this error: _pickle.PicklingError: Can't pickle <class 'XNumRefNode'>: attribute lookup XNumRefNode on builtins failed Help of python experts is welcome. References: http://sphinx-doc.org/markup/inline.html#role-numref https://bitbucket.org/arjones6/sphinx-numfig/src/b2345f7d9fabefbd103c31cc0c4c26c68b29ac6a/numfig.py http://code.nabla.net/doc/sphinx/api/sphinx/addnodes/sphinx.addnodes.pending_xref.html
> -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Wednesday, May 13, 2015 8:08 PM > To: Mcnamara, John > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 0/2] doc: refactored fig and table nums > into references > > > The error is removed so it's better. > With this patch, a figure reference looks like this: > :numref:`figure_single_port_nic` Virtualization for a Single Port NIC in > SR-IOV Mode The rst line is: > :numref:`figure_single_port_nic` :ref:`figure_single_port_nic` > > I was trying to replace the numref output by a working link with "figure" > as label. > This is my trial to mimic :ref: as a first step: Hi Thomas, I'll take a look at it and see if I can get something working. John. --
> -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Wednesday, May 13, 2015 8:08 PM > To: Mcnamara, John > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 0/2] doc: refactored fig and table nums > into references > > > Unfortunately it gives this error: > _pickle.PicklingError: Can't pickle <class 'XNumRefNode'>: attribute > lookup XNumRefNode on builtins failed > Hi Thomas, I ran into similar pickle.py issues trying to subclass the node.reference classes within sphinx. I was able to workaround it without a subclass. I'll submit a rebased V2 of the Figure/Table numbering patchset with updates to conf.py. You can review the workaround there. John. --
diff --git a/doc/guides/conf.py b/doc/guides/conf.py index 1bc031f..bbf40f1 100644 --- a/doc/guides/conf.py +++ b/doc/guides/conf.py @@ -82,3 +82,16 @@ class CustomLatexFormatter(LatexFormatter): # Replace the default latex formatter. PygmentsBridge.latex_formatter = CustomLatexFormatter + +from docutils import nodes +from distutils.version import LooseVersion +from sphinx import __version__ as sphinx_version + +# Workaround to ignore :numref: in older versions of Sphinx. +def setup(app): + + if LooseVersion(sphinx_version) < LooseVersion('1.3.1'): + print('[dpdk docs] Upgrade sphinx to version >= 1.3.1 for ' + 'improved Figure/Table number handling.') + app.add_generic_role('numref', nodes.emphasis) +