call site 0 for path.local.relto
apigen/testing/test_apigen_example.py - line 174
173
174
175
176
   def test_build_class_view(self):
->     snippet = self.apb.build_class_view('main.SomeClass')
       html = snippet.unicode()
       _checkhtmlsnippet(html)
apigen/htmlgen.py - line 420
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
   def build_class_view(self, dotted_name):
       """ build the html for a class """
       cls = get_obj(self.dsa, self.pkg, dotted_name)
       # XXX is this a safe check?
       try:
           sourcefile = inspect.getsourcefile(cls)
       except TypeError:
           sourcefile = None
   
       docstring = cls.__doc__
       if docstring:
           docstring = deindent(docstring)
       if not hasattr(cls, '__name__'):
           clsname = 'instance of %s' % (cls.__class__.__name__,)
       else:
           clsname = cls.__name__
       bases = self.build_bases(dotted_name)
       properties = self.build_properties(cls)
->     methods = self.build_methods(dotted_name)
   
       if sourcefile is None:
           sourcelink = H.div('no source available')
       else:
           if sourcefile[-1] in ['o', 'c']:
               sourcefile = sourcefile[:-1]
           sourcelink = H.div(H.a('view source',
               href=self.linker.get_lazyhref(sourcefile)))
   
       snippet = H.ClassDescription(
           # XXX bases HTML
           H.ClassDef(clsname, bases, docstring, sourcelink,
                      properties, methods),
       )
   
       return snippet
apigen/htmlgen.py - line 474
462
463
464
465
466
467
468
469
470
471
472
473
474
475
   def build_methods(self, dotted_name):
       ret = []
       methods = self.dsa.get_class_methods(dotted_name)
       # move all __*__ methods to the back
       methods = ([m for m in methods if not m.startswith('_')] +
                  [m for m in methods if m.startswith('_')])
       # except for __init__, which should be first
       if '__init__' in methods:
           methods.remove('__init__')
           methods.insert(0, '__init__')
       for method in methods:
           ret += self.build_callable_view('%s.%s' % (dotted_name,
->                                                    method))
       return ret
apigen/htmlgen.py - line 391
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
   def build_callable_view(self, dotted_name):
       """ build the html for a class method """
       # XXX we may want to have seperate
       func = get_obj(self.dsa, self.pkg, dotted_name)
       docstring = func.__doc__ 
       if docstring:
           docstring = deindent(docstring)
       localname = func.__name__
       argdesc = get_param_htmldesc(self.linker, func)
       valuedesc = self.build_callable_signature_description(dotted_name)
   
       sourcefile = inspect.getsourcefile(func)
       callable_source = self.dsa.get_function_source(dotted_name)
       # i assume they're both either available or unavailable(XXX ?)
       is_in_pkg = self.is_in_pkg(sourcefile)
       href = None
       text = 'could not get to source file'
       colored = []
       if sourcefile and callable_source:
           enc = source_html.get_module_encoding(sourcefile)
           tokenizer = source_color.Tokenizer(source_color.PythonSchema)
           firstlineno = func.func_code.co_firstlineno
           sep = get_linesep(callable_source)
           org = callable_source.split(sep)
           colored = [enumerate_and_color(org, firstlineno, enc)]
->         relpath = get_rel_sourcepath(self.projroot, sourcefile, sourcefile)
           text = 'source: %s' % (relpath,)
           if is_in_pkg:
               href = self.linker.get_lazyhref(sourcefile)
   
       csource = H.SourceSnippet(text, href, colored)
       cslinks = self.build_callsites(dotted_name)
       snippet = H.FunctionDescription(localname, argdesc, docstring,
                                       valuedesc, csource, cslinks)
       return snippet
apigen/htmlgen.py - line 168
167
168
169
170
171
   def get_rel_sourcepath(projpath, filename, default=None):
->     relpath = py.path.local(filename).relto(projpath)
       if not relpath:
           return default
       return relpath