Skip to content

Commit 321de81

Browse files
committed
fix: github url generation
1 parent 726a7c0 commit 321de81

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

tools/github.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ def get_repo_url(force_github=False):
8181
return uri
8282

8383

84-
def get_file_url(object, hashmap):
84+
def get_file_url(object):
8585
"""Returns local or remote url for an object
8686
"""
8787
filename = inspect.getsourcefile(object)
8888
lines = inspect.getsourcelines(object)
8989
uri = 'file://%s#L%d' % (filename, lines[1])
9090
if is_git_repo():
91-
o, _ = Popen('git hash-object %s' % filename, shell=True, stdout=PIPE,
92-
cwd=os.path.dirname(nipype.__file__)).communicate()
93-
key = o.strip()
94-
if key in hashmap:
95-
uri = 'http://github.com/nipy/nipype/blob/master/' + \
96-
hashmap[key] + '#L%d' % lines[1]
91+
info = nipype.get_info()
92+
shortfile = os.path.join('nipype', filename.split('nipype/')[-1])
93+
print shortfile
94+
uri = 'http://github.com/nipy/nipype/tree/%s/%s#L%d' % \
95+
(info['commit_hash'],
96+
shortfile, lines[1])
9797
return uri

tools/interfacedocgen.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from nipype.pipeline.engine import Workflow
3232
from nipype.utils.misc import trim
3333

34-
from github import create_hash_map, get_file_url
34+
from github import get_file_url
3535

3636
# Functions and classes
3737
class InterfaceHelpWriter(object):
@@ -284,7 +284,6 @@ def generate_api_doc(self, uri):
284284

285285
#ad += '\n' + 'Classes' + '\n' + \
286286
# self.rst_section_levels[2] * 7 + '\n'
287-
hashmap = create_hash_map()
288287
for c in classes:
289288
__import__(uri)
290289
print c
@@ -303,7 +302,7 @@ def generate_api_doc(self, uri):
303302
ad += '\n.. _%s\n\n' % label
304303
ad += '\n.. index:: %s\n\n' % c
305304
ad += c + '\n' + self.rst_section_levels[2] * len(c) + '\n\n'
306-
ad += "Code: %s\n\n" % get_file_url(classinst, hashmap)
305+
ad += "Code: %s\n\n" % get_file_url(classinst)
307306
ad += trim(classinst.help(returnhelp=True),
308307
self.rst_section_levels[3]) + '\n'
309308

@@ -314,7 +313,7 @@ def generate_api_doc(self, uri):
314313
label = ':func:`' + name + '`'
315314
ad += '\n.. _%s:\n\n' % (uri + '.' + name)
316315
ad += '\n'.join((label, self.rst_section_levels[2] * len(label)))
317-
ad += "\n\nCode: %s\n\n" % get_file_url(finst, hashmap)
316+
ad += "\n\nCode: %s\n\n" % get_file_url(finst)
318317
helpstr = trim(finst.__doc__, self.rst_section_levels[3])
319318
ad += '\n\n' + helpstr + '\n\n'
320319

@@ -333,7 +332,7 @@ def generate_api_doc(self, uri):
333332
label = ':func:`' + name + '`'
334333
ad += '\n.. _%s:\n\n' % (uri + '.' + name)
335334
ad += '\n'.join((label, self.rst_section_levels[2] * len(label)))
336-
ad += "\n\nCode: %s\n\n" % get_file_url(finst, hashmap)
335+
ad += "\n\nCode: %s\n\n" % get_file_url(finst)
337336
helpstr = trim(finst.__doc__, self.rst_section_levels[3])
338337
ad += '\n\n' + helpstr + '\n\n'
339338

0 commit comments

Comments
 (0)