From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by dpdk.org (Postfix) with ESMTP id 9721E5A32 for ; Wed, 13 May 2015 21:08:14 +0200 (CEST) Received: by widdi4 with SMTP id di4so67747233wid.0 for ; Wed, 13 May 2015 12:08:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=6BBbtWG0N9CozcFjXMVCREPlSuVJqAreThB7NpjZYVs=; b=eym5/zq/4u8rAfOcmnv3OcZ7dHRUd339JSgzd+7/BlTliNasmPSsSJ4cUeaTlaZkEA VjplWrU/Gr86cOzzsDOjPI8ZTwAtIxcGPBqj97ukbEHHeFEUwcTaN7Rty29sXAk5Ziou ToZy3lR2tshraTsYfDtJg3IBe/WfyhP/EINIMHa9S13ozDvfa+gLs8TLx5aktNB2BxxV OEI2qeUugB57mKiYRevvQqqwN45AAyiwKVQZz71exGDNQ7TVkwzDGFToKepBqHjwDSD4 uUBAVsTglLWAhX5zGMfqjCIaibL9ifUQ/wWjDwFkp2dwZqOrgl5MCSWq66Nn816zXyUk x8KQ== X-Gm-Message-State: ALoCoQkTywz5dT3DcgiSSGLXGlp6Mk3u6pC2SzjrHpwa8LME638CQZJcfb5UKg0p8dmN2D4jH4al X-Received: by 10.194.60.4 with SMTP id d4mr787731wjr.72.1431544094403; Wed, 13 May 2015 12:08:14 -0700 (PDT) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id y7sm34347316wjw.16.2015.05.13.12.08.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2015 12:08:13 -0700 (PDT) From: Thomas Monjalon To: "Mcnamara, John" Date: Wed, 13 May 2015 21:07:30 +0200 Message-ID: <2042378.YRHo6U96YW@xps13> Organization: 6WIND User-Agent: KMail/4.14.7 (Linux/4.0.1-1-ARCH; KDE/4.14.7; x86_64; ; ) In-Reply-To: References: <1429881109-16684-1-git-send-email-john.mcnamara@intel.com> <4018323.hxXVqqSkHq@xps13> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2015 19:08:14 -0000 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 : 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