diff options
| author | Jonathan Waltman <jonathan.waltman@gmail.com> | 2013-02-19 19:36:19 -0600 |
|---|---|---|
| committer | Jonathan Waltman <jonathan.waltman@gmail.com> | 2013-02-19 19:36:19 -0600 |
| commit | becac843172c99a6e3250784c059c2e4f56b0195 (patch) | |
| tree | 97224695b15b01fe4c0a36dd157d88d8e7da3b09 /sphinx | |
| parent | 428099dcb1260535312de32f855318d891a0b62f (diff) | |
| download | sphinx-becac843172c99a6e3250784c059c2e4f56b0195.tar.gz | |
[texinfo] Do not capitalize words in deffn categories containing capital letters.
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/writers/texinfo.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 2b462994..71db9015 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -88,6 +88,16 @@ def find_subsections(section): 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') @@ -1284,7 +1294,8 @@ class TexinfoTranslator(nodes.NodeVisitor): 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 |
