|
145 | 145 | # Additional templates that should be rendered to pages, maps page names to |
146 | 146 | # template names. |
147 | 147 | #html_additional_pages = {} |
148 | | -# ----------------------------------------------------------------------------- |
149 | | -# Source code links |
150 | | -# ----------------------------------------------------------------------------- |
151 | | - |
152 | | -import inspect |
153 | | -from os.path import relpath, dirname |
154 | | - |
155 | | -for name in ['sphinx.ext.linkcode', 'linkcode', 'numpydoc.linkcode']: |
156 | | - try: |
157 | | - __import__(name) |
158 | | - extensions.append(name) |
159 | | - break |
160 | | - except ImportError: |
161 | | - pass |
162 | | -else: |
163 | | - print "NOTE: linkcode extension not found -- no links to source generated" |
164 | | - |
165 | | -def linkcode_resolve(domain, info): |
166 | | - """ |
167 | | -Determine the URL corresponding to Python object |
168 | | -""" |
169 | | - if domain != 'py': |
170 | | - return None |
171 | | - |
172 | | - modname = info['module'] |
173 | | - fullname = info['fullname'] |
174 | | - |
175 | | - submod = sys.modules.get(modname) |
176 | | - if submod is None: |
177 | | - return None |
178 | | - |
179 | | - obj = submod |
180 | | - for part in fullname.split('.'): |
181 | | - try: |
182 | | - obj = getattr(obj, part) |
183 | | - except: |
184 | | - return None |
185 | 148 |
|
186 | | - try: |
187 | | - fn = inspect.getsourcefile(obj) |
188 | | - except: |
189 | | - fn = None |
190 | | - if not fn: |
191 | | - return None |
192 | | - |
193 | | - try: |
194 | | - source, lineno = inspect.findsource(obj) |
195 | | - except: |
196 | | - lineno = None |
197 | | - |
198 | | - if lineno: |
199 | | - linespec = "#L%d" % (lineno + 1) |
200 | | - else: |
201 | | - linespec = "" |
202 | | - |
203 | | - fn = relpath(fn, start=dirname(numpy.__file__)) |
204 | | - |
205 | | - if 'dev' in numpy.__version__: |
206 | | - return "http://github.com/numpy/numpy/blob/master/numpy/%s%s" % ( |
207 | | - fn, linespec) |
208 | | - else: |
209 | | - return "http://github.com/numpy/numpy/blob/v%s/numpy/%s%s" % ( |
210 | | - numpy.__version__, fn, linespec) |
211 | 149 | # If false, no module index is generated. |
212 | 150 | #html_domain_indices = True |
213 | 151 |
|
@@ -352,5 +290,5 @@ def linkcode_resolve(domain, info): |
352 | 290 |
|
353 | 291 | fn = relpath(fn, start=dirname(nmrglue.__file__)) |
354 | 292 |
|
355 | | - return "http://github.com/jjhelmus/nmrglue/blob/master/nmrglue/%s%s" % ( |
| 293 | + return "http://github.com/jjhelmus/nmrglue/blob/v0.4/nmrglue/%s%s" % ( |
356 | 294 | fn, linespec) |
0 commit comments