diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-04-19 16:18:45 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-04-19 16:18:45 +0000 |
commit | 0d18cd71f1be611a3a5c5cf0fe4ce2a7aa076188 (patch) | |
tree | 0cca2794e9e5dfb81ba594c2e7b8764f8ac87dfe /doc/sphinxext/docscrape_sphinx.py | |
parent | e427f7a166b83e6523248eaddabd0742f9d329e9 (diff) | |
download | numpy-0d18cd71f1be611a3a5c5cf0fe4ce2a7aa076188.tar.gz |
sphinxext: use real RST references for bibliographies, and add suitable links for Latex
Diffstat (limited to 'doc/sphinxext/docscrape_sphinx.py')
-rw-r--r-- | doc/sphinxext/docscrape_sphinx.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/sphinxext/docscrape_sphinx.py b/doc/sphinxext/docscrape_sphinx.py index 77ed271b0..7293fc795 100644 --- a/doc/sphinxext/docscrape_sphinx.py +++ b/doc/sphinxext/docscrape_sphinx.py @@ -1,4 +1,5 @@ import re, inspect, textwrap, pydoc +import sphinx from docscrape import NumpyDocString, FunctionDoc, ClassDoc class SphinxDocString(NumpyDocString): @@ -90,6 +91,18 @@ class SphinxDocString(NumpyDocString): self['References'] = [self['References']] out.extend(self['References']) out += [''] + # Latex collects all references to a separate bibliography, + # so we need to insert links to it + if sphinx.__version__ >= 0.6: + out += ['.. only:: latex',''] + else: + out += ['.. latexonly::',''] + items = [] + for line in self['References']: + m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I) + if m: + items.append(m.group(1)) + out += [' ' + ", ".join(["[%s]_" % item for item in items]), ''] return out def __str__(self, indent=0, func_role="obj"): |