call site 1 for code.Source.__init__
apigen/testing/test_apigen_example.py - line 167
166
167
168
169
170
171
   def test_build_function_pages(self):
->     self.apb.build_function_pages(['main.sub.func'])
       funcfile = self.base.join('api/main.sub.func.html')
       assert funcfile.check()
       html = funcfile.read()
       _checkhtml(html)
apigen/htmlgen.py - line 527
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
   def build_function_pages(self, method_dotted_names):
       passed = []
       for dotted_name in sorted(method_dotted_names):
           if self.capture:
               self.capture.err.writeorg('.')
           # XXX should we create a build_function_view instead?
           parent_dotted_name, _ = split_of_last_part(dotted_name)
           sibling_dotted_names = self.namespace_tree[parent_dotted_name]
->         tag = H.Content(self.build_callable_view(dotted_name))
           nav = self.build_navigation(dotted_name, False)
           reltargetpath = "api/%s.html" % (dotted_name,)
           self.linker.set_link(dotted_name, reltargetpath)
           title = '%s API' % (dotted_name,)
           rev = self.get_revision(dotted_name)
           if rev:
               title += ' [rev. %s]' % (rev,)
           self.write_page(title, reltargetpath, tag, nav)
       return passed
apigen/htmlgen.py - line 376
364
365
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
   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/tracer/docstorage.py - line 265
262
263
264
265
266
267
   def get_function_source(self, name):
       desc = self.ds.descs[name]
       try:
->         return str(py.code.Source(desc.pyobj))
       except IOError:
           return "Cannot get source"
code/source.py - line 30
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
   def __init__(self, *parts, **kwargs):
       self.lines = lines = []
       de = kwargs.get('deindent', True)
       rstrip = kwargs.get('rstrip', True) 
       for part in parts:
           if not part: 
               partlines = []
           if isinstance(part, Source):
               partlines = part.lines
           elif isinstance(part, (unicode, str)):
               partlines = part.split('\n')
               if rstrip:
                   while partlines: 
                       if partlines[-1].strip(): 
                           break
                       partlines.pop()
           else:
->             partlines = getsource(part, deindent=de).lines
           if de:
               partlines = deindent(partlines)
           lines.extend(partlines)
code/source.py - line 236
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
   def getsource(obj, **kwargs):
       if hasattr(obj, 'func_code'):
           obj = obj.func_code
       elif hasattr(obj, 'f_code'):
           obj = obj.f_code
       try:
           fullsource = obj.co_filename.__source__
       except AttributeError:
           try:
               strsrc = inspect.getsource(obj)
           except IndentationError:
               strsrc = "\"Buggy python version consider upgrading, cannot get source\""
           assert isinstance(strsrc, str)
->         return Source(strsrc, **kwargs)
       else:
           lineno = obj.co_firstlineno - 1
           end = fullsource.getblockend(lineno)
           return fullsource[lineno:end+1]