diff mbox

[1/3] doc-rst:c-domain: fix sphinx version incompatibility

Message ID 1472657372-21039-2-git-send-email-markus.heiser@darmarit.de (mailing list archive)
State New, archived
Headers show

Commit Message

Markus Heiser Aug. 31, 2016, 3:29 p.m. UTC
From: Markus Heiser <markus.heiser@darmarIT.de>

The self.indexnode's tuple has changed in sphinx version 1.4, from a
former 4 element tuple to a 5 element tuple.

https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
---
 Documentation/sphinx/cdomain.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Jonathan Corbet Sept. 6, 2016, 12:19 p.m. UTC | #1
On Wed, 31 Aug 2016 17:29:30 +0200
Markus Heiser <markus.heiser@darmarit.de> wrote:

> +            if major >= 1 and minor < 4:
> +                # indexnode's tuple changed in 1.4
> +                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
> +                self.indexnode['entries'].append(
> +                    ('single', indextext, targetname, ''))
> +            else:
> +                self.indexnode['entries'].append(
> +                    ('single', indextext, targetname, '', None))

So this doesn't seem right.  We'll get the four-entry tuple behavior with
1.3 and the five-entry behavior with 1.4...but what happens when 2.0
comes out?

Did you want maybe:

	if major == 1 and minor < 4:

?

(That will fail on 0.x, but we've already stated that we don't support
below 1.2).

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Heiser Sept. 6, 2016, 12:24 p.m. UTC | #2
Am 06.09.2016 um 14:19 schrieb Jonathan Corbet <corbet@lwn.net>:

> On Wed, 31 Aug 2016 17:29:30 +0200
> Markus Heiser <markus.heiser@darmarit.de> wrote:
> 
>> +            if major >= 1 and minor < 4:
>> +                # indexnode's tuple changed in 1.4
>> +                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
>> +                self.indexnode['entries'].append(
>> +                    ('single', indextext, targetname, ''))
>> +            else:
>> +                self.indexnode['entries'].append(
>> +                    ('single', indextext, targetname, '', None))
> 
> So this doesn't seem right.  We'll get the four-entry tuple behavior with
> 1.3 and the five-entry behavior with 1.4...but what happens when 2.0
> comes out?
> 
> Did you want maybe:
> 
> 	if major == 1 and minor < 4:
> 
> ?

Ups, yes you are right.

Should I send a new patch .. or could you fix it?

-- Markus --

> 
> (That will fail on 0.x, but we've already stated that we don't support
> below 1.2).
> 
> jon

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Corbet Sept. 6, 2016, 12:30 p.m. UTC | #3
On Tue, 6 Sep 2016 14:24:11 +0200
Markus Heiser <markus.heiser@darmarit.de> wrote:

> Should I send a new patch .. or could you fix it?

Please just regenerate the series and I'll apply it.

Thanks,

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jani Nikula Sept. 6, 2016, 1:34 p.m. UTC | #4
On Tue, 06 Sep 2016, Jonathan Corbet <corbet@lwn.net> wrote:
> On Wed, 31 Aug 2016 17:29:30 +0200
> Markus Heiser <markus.heiser@darmarit.de> wrote:
>
>> +            if major >= 1 and minor < 4:
>> +                # indexnode's tuple changed in 1.4
>> +                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
>> +                self.indexnode['entries'].append(
>> +                    ('single', indextext, targetname, ''))
>> +            else:
>> +                self.indexnode['entries'].append(
>> +                    ('single', indextext, targetname, '', None))
>
> So this doesn't seem right.  We'll get the four-entry tuple behavior with
> 1.3 and the five-entry behavior with 1.4...but what happens when 2.0
> comes out?
>
> Did you want maybe:
>
> 	if major == 1 and minor < 4:
>
> ?
>
> (That will fail on 0.x, but we've already stated that we don't support
> below 1.2).

Is there a way to check the number of entries expected in the tuples
instead of trying to match the version?

BR,
Jani.
Markus Heiser Sept. 6, 2016, 3:10 p.m. UTC | #5
Am 06.09.2016 um 15:34 schrieb Jani Nikula <jani.nikula@intel.com>:

> On Tue, 06 Sep 2016, Jonathan Corbet <corbet@lwn.net> wrote:
>> On Wed, 31 Aug 2016 17:29:30 +0200
>> Markus Heiser <markus.heiser@darmarit.de> wrote:
>> 
>>> +            if major >= 1 and minor < 4:
>>> +                # indexnode's tuple changed in 1.4
>>> +                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
>>> +                self.indexnode['entries'].append(
>>> +                    ('single', indextext, targetname, ''))
>>> +            else:
>>> +                self.indexnode['entries'].append(
>>> +                    ('single', indextext, targetname, '', None))
>> 
>> So this doesn't seem right.  We'll get the four-entry tuple behavior with
>> 1.3 and the five-entry behavior with 1.4...but what happens when 2.0
>> comes out?
>> 
>> Did you want maybe:
>> 
>> 	if major == 1 and minor < 4:
>> 
>> ?
>> 
>> (That will fail on 0.x, but we've already stated that we don't support
>> below 1.2).
> 
> Is there a way to check the number of entries expected in the tuples
> instead of trying to match the version?

Sadly not, the dissection of the tuple is spread around the source :(

Sphinx has some more of these tuples with fixed length (remember
conf.py, the latex_documents settings) where IMHO hash/value pairs
(dicts) are more suitable.

-- Markus --
> BR,
> Jani.
> -- 
> Jani Nikula, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mauro Carvalho Chehab Sept. 6, 2016, 3:55 p.m. UTC | #6
Em Tue, 6 Sep 2016 17:10:53 +0200
Markus Heiser <markus.heiser@darmarit.de> escreveu:

> Am 06.09.2016 um 15:34 schrieb Jani Nikula <jani.nikula@intel.com>:
> 
> > On Tue, 06 Sep 2016, Jonathan Corbet <corbet@lwn.net> wrote:  
> >> On Wed, 31 Aug 2016 17:29:30 +0200
> >> Markus Heiser <markus.heiser@darmarit.de> wrote:
> >>   
> >>> +            if major >= 1 and minor < 4:
> >>> +                # indexnode's tuple changed in 1.4
> >>> +                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
> >>> +                self.indexnode['entries'].append(
> >>> +                    ('single', indextext, targetname, ''))
> >>> +            else:
> >>> +                self.indexnode['entries'].append(
> >>> +                    ('single', indextext, targetname, '', None))  
> >> 
> >> So this doesn't seem right.  We'll get the four-entry tuple behavior with
> >> 1.3 and the five-entry behavior with 1.4...but what happens when 2.0
> >> comes out?
> >> 
> >> Did you want maybe:
> >> 
> >> 	if major == 1 and minor < 4:
> >> 
> >> ?
> >> 
> >> (That will fail on 0.x, but we've already stated that we don't support
> >> below 1.2).  
> > 
> > Is there a way to check the number of entries expected in the tuples
> > instead of trying to match the version?  
> 
> Sadly not, the dissection of the tuple is spread around the source :(
> 
> Sphinx has some more of these tuples with fixed length (remember
> conf.py, the latex_documents settings) where IMHO hash/value pairs
> (dicts) are more suitable.

Well, the LaTeX stuff at conf.py seems to have a new field on version
1.4.x. At least, our config has:

# (source start file, name, description, authors, manual section).

but 1.4.x docs mentions another tuple: toctree_only.

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Heiser Sept. 7, 2016, 8:01 a.m. UTC | #7
Am 06.09.2016 um 17:55 schrieb Mauro Carvalho Chehab <mchehab@infradead.org>:
...
>> Sphinx has some more of these tuples with fixed length (remember
>> conf.py, the latex_documents settings) where IMHO hash/value pairs
>> (dicts) are more suitable.
> 
> Well, the LaTeX stuff at conf.py seems to have a new field on version
> 1.4.x. At least, our config has:
> 
> # (source start file, name, description, authors, manual section).
> 
> but 1.4.x docs mentions another tuple: toctree_only.

Hmm, as far as I can see, toctree_only is supported since Release 0.3 
(May 6, 2008):

  https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.old#L1025

But is was implemented optional (from the beginning):

 https://github.com/sphinx-doc/sphinx/blame/master/sphinx/builders/latex.py#L104

-- Markus --

> 
> Regards,
> Mauro
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/sphinx/cdomain.py b/Documentation/sphinx/cdomain.py
index 9eb714a..66816ae 100644
--- a/Documentation/sphinx/cdomain.py
+++ b/Documentation/sphinx/cdomain.py
@@ -29,11 +29,15 @@  u"""
 
 from docutils.parsers.rst import directives
 
+import sphinx
 from sphinx.domains.c import CObject as Base_CObject
 from sphinx.domains.c import CDomain as Base_CDomain
 
 __version__  = '1.0'
 
+# Get Sphinx version
+major, minor, patch = map(int, sphinx.__version__.split("."))
+
 def setup(app):
 
     app.override_domain(CDomain)
@@ -85,8 +89,14 @@  class CObject(Base_CObject):
 
         indextext = self.get_index_text(name)
         if indextext:
-            self.indexnode['entries'].append(('single', indextext,
-                                              targetname, '', None))
+            if major >= 1 and minor < 4:
+                # indexnode's tuple changed in 1.4
+                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
+                self.indexnode['entries'].append(
+                    ('single', indextext, targetname, ''))
+            else:
+                self.indexnode['entries'].append(
+                    ('single', indextext, targetname, '', None))
 
 class CDomain(Base_CDomain):