Commits

Jon Waltman committed 9d4d80f

[texinfo] Do not capitalize words in deffn categories containing capital letters.

Comments (0)

Files changed (1)

sphinx/writers/texinfo.py

     return result
 
 
+def smart_capwords(s, sep=None):
+    """Like string.capwords() but does not capitalize words that already
+    contain a capital letter."""
+    words = s.split(sep)
+    for i, word in enumerate(words):
+        if all(x.islower() for x in word):
+            words[i] = word.capitalize()
+    return (sep or ' ').join(words)
+
+
 class TexinfoWriter(writers.Writer):
     """Texinfo writer for generating Texinfo documents."""
     supported = ('texinfo', 'texi')
                                         primary == domain.name)
         except KeyError:
             name = objtype
-        category = self.escape_arg(string.capwords(name))
+        # by convention, the deffn category should be capitalized like a title
+        category = self.escape_arg(smart_capwords(name))
         self.body.append('\n%s {%s} ' % (self.at_deffnx, category))
         self.at_deffnx = '@deffnx'
         self.desc_type_name = name