diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-07-11 13:39:58 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-07-11 13:39:58 +0000 |
commit | c3a0fb9711a119ac303d18719cea702efeff408f (patch) | |
tree | d92854c76945246b07566d8420f0c633bab34a1d /doc/sphinxext | |
parent | 8ea0648357ae54483f9eed69b55b418b80acdb1f (diff) | |
download | numpy-c3a0fb9711a119ac303d18719cea702efeff408f.tar.gz |
numpydoc: fix some unicode issues
Diffstat (limited to 'doc/sphinxext')
-rw-r--r-- | doc/sphinxext/numpydoc.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/doc/sphinxext/numpydoc.py b/doc/sphinxext/numpydoc.py index 846dd7b85..df5a914a3 100644 --- a/doc/sphinxext/numpydoc.py +++ b/doc/sphinxext/numpydoc.py @@ -25,29 +25,29 @@ def mangle_docstrings(app, what, name, obj, options, lines, if what == 'module': # Strip top title - title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*', + title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*', re.I|re.S) - lines[:] = title_re.sub('', "\n".join(lines)).split("\n") + lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n") else: - doc = get_doc_object(obj, what, "\n".join(lines)) + doc = get_doc_object(obj, what, u"\n".join(lines)) doc.use_plots = app.config.numpydoc_use_plots - lines[:] = str(doc).split("\n") + lines[:] = unicode(doc).split(u"\n") if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \ obj.__name__: if hasattr(obj, '__module__'): - v = dict(full_name="%s.%s" % (obj.__module__, obj.__name__)) + v = dict(full_name=u"%s.%s" % (obj.__module__, obj.__name__)) else: v = dict(full_name=obj.__name__) - lines += ['', '.. htmlonly::', ''] - lines += [' %s' % x for x in + lines += [u'', u'.. htmlonly::', ''] + lines += [u' %s' % x for x in (app.config.numpydoc_edit_link % v).split("\n")] # replace reference numbers so that there are no duplicates references = [] for line in lines: line = line.strip() - m = re.match(r'^.. \[([a-z0-9_.-])\]', line, re.I) + m = re.match(ur'^.. \[([a-z0-9_.-])\]', line, re.I) if m: references.append(m.group(1)) @@ -56,14 +56,14 @@ def mangle_docstrings(app, what, name, obj, options, lines, if references: for i, line in enumerate(lines): for r in references: - if re.match(r'^\d+$', r): - new_r = "R%d" % (reference_offset[0] + int(r)) + if re.match(ur'^\d+$', r): + new_r = u"R%d" % (reference_offset[0] + int(r)) else: - new_r = "%s%d" % (r, reference_offset[0]) - lines[i] = lines[i].replace('[%s]_' % r, - '[%s]_' % new_r) - lines[i] = lines[i].replace('.. [%s]' % r, - '.. [%s]' % new_r) + new_r = u"%s%d" % (r, reference_offset[0]) + lines[i] = lines[i].replace(u'[%s]_' % r, + u'[%s]_' % new_r) + lines[i] = lines[i].replace(u'.. [%s]' % r, + u'.. [%s]' % new_r) reference_offset[0] += len(references) @@ -78,8 +78,8 @@ def mangle_signature(app, what, name, obj, options, sig, retann): doc = SphinxDocString(pydoc.getdoc(obj)) if doc['Signature']: - sig = re.sub("^[^(]*", "", doc['Signature']) - return sig, '' + sig = re.sub(u"^[^(]*", u"", doc['Signature']) + return sig, u'' def initialize(app): try: |