321: #line 423 "web_weaver.ipk"
322:
323:
324: def _foot(self):
325: if self._trig(0) == self._current_level():
326: self._popw()
327:
328: def _head(self,text, atext, anchor,nospawn):
329: level = self._current_level()
330: if level == self._trig(1) and not nospawn:
331: self._pushw(level,text,atext,anchor)
332: else:
333: self._ins_head(level,text,atext,anchor)
334:
335: def __del__(self):
336: if 'weavers' in self.process.trace:
337: print "WEB WEAVER DESTRUCTOR COMMENCES"
338: del self.base
339: while self.stack: del self.stack[-1]
340: oldsubdoc = self.subdoc_stack.top
341: while 0 < oldsubdoc[0]:
342: self.pattern = oldsubdoc[1]
343: self.childcount = oldsubdoc[2]
344: print 'Resetting pattern to',self.pattern,'count to',self.childcount
345: self.subdoc_stack.pop()
346: oldsubdoc = self.subdoc_stack.top
347:
348: tables = [
349: ['contents','Contents','docview',0],
350: ['funcref','Functions','docview',0],
351: ['classref','Classes','docview',0],
352: ['identref','Identifiers','docview',0],
353: ['testref','Tests','docview',0],
354: ['sectionref','Sections','docview',0],
355: ['sourceref','Source','docview',0],
356: ['metricsref','Metrics','docview',0],
357: ['noticesref','Notices','docview',0],
358: ['filestatus','Status','docview',0]
359: ]
360: for i in range(len(tables)):
361: name, descr, target, count = tables[i]
362: s = 'tables['+str(i)+'][3]=self.mk_'+name+'(self.pattern % '+repr(name)+','+repr(target)+')'
363: try:
364: exec s
365: except:
366: print 'Error generating table',name,descr
367: traceback.print_exc()
368: self.persistent_frame['contents'] = self.toc
369: self.mk_frames(self.home_file, tables)
370: if 'weavers' in self.process.trace:
371: print 'Web Weaver finished'
372: if 'weavers' in self.process.trace:
373: self.process.release_object(self)
374:
375: def format_heading_number(self, hlist, sep):
376: hnumber = ''
377: for i in range(1,len(hlist)-1):
378: hnumber = hnumber + str(hlist[i])+'.'
379: hnumber = hnumber + str(hlist[-1])
380: return hnumber
381:
382: def get_formatted_heading_number(self, sep):
383: return self.format_heading_number(self.hcount,sep)
384:
385:
386: def anchor_text(self,anchor,label,tooltip):
387: return '<A HREF="'+anchor+'" TITLE="'+tooltip+'">'+\
388: self.tr_phrase(label)+'</A>'
389:
390: def anchor_of(self, toc, ix, label):
391: if ix == None: return None
392: if 0<=ix<len(toc):
393: level, hnum, anchor, text,hcount = toc[ix]
394: return self.anchor_text(anchor, label, text)
395: else: return None
396:
397: def cal_nav(self,level):
398: toc = self.persistent_frame.get('contents',None)
399: first, last, next, prev, along, back, up, this = (None,)*8
400: n = toc and len(toc)
401: if n:
402: first = 0
403: last = n-1
404:
405: this = 0
406: for entry in toc:
407: if entry[4] == self.hcount: break
408: this = this + 1
409:
410: if this+1 < n: next = this + 1
411: if this>0: prev = this - 1
412:
413: along = this + 1
414: while along < n:
415: nlev = toc[along][0]
416: if nlev < level: along = None
417: if nlev <= level: break
418: along = along + 1
419:
420: back = this - 1
421: while back >= 0:
422: nlev = toc[back][0]
423: if nlev < level: back = None
424: if nlev <= level: break
425: back = back - 1
426:
427: up = this -1
428: while up >= 0:
429: nlev = toc[up][0]
430: if nlev < level: break
431: up = up - 1
432:
433: return toc, this, first, last, next, prev, along, back, up
434:
435: def mk_nav(self, lasttoc, this, first, last, next, prev, along, back, up):
436: home = self.home_anchor
437: up = self.anchor_of(lasttoc,up,'Up')
438: prev = self.anchor_of(lasttoc,prev,'Prev')
439: next = self.anchor_of(lasttoc,next,'Next')
440: along = self.anchor_of(lasttoc,along,'Along')
441: back = self.anchor_of(lasttoc,back,'Back')
442: this = self.anchor_of(lasttoc,this,'This')
443:
444: nav = ''
445: if next : nav = nav + next+' '
446: if prev : nav = nav + prev+' '
447: if along : nav = nav + along+' '
448: if back : nav = nav + back+' '
449: if up : nav = nav + up+' '
450: if home: nav = nav + home+' '
451: if this: nav = nav + this+' '
452: nav = nav + '<SMALL>['+self.original_filename+']</SMALL>'
453:
454: hnav = '<DIV CLASS="NAVIGATION">'+nav+'<BR><HR></DIV>'
455: fnav = '<DIV CLASS="NAVIGATION"><BR><HR>'+nav+'</DIV>'
456: return hnav, fnav
457:
458: def _popw(self):
459: if 'weavers' in self.process.trace:
460: print 'Terminating weaver',self.stack[-1].name
461: del self.stack[-1]
462: self.base = [self.stack[-1]]
463:
464: def _new_child(self):
465: self.childcount = self.childcount + 1
466: return self.pattern % ('%04d' % self.childcount)
467:
468: def _pushw(self,level,text,atext,label):
469: filename = self._new_child()
470: if label:
471: anchor = self.pattern%('%04d'%(self.childcount))
472: self.register_anchor(label, anchor)
473:
474:
475:
476:
477:
478:
479:
480: self.base = [self.stack[-1]]
481: hn = self.get_formatted_heading_number('.')+'.'
482: hnum = self.get_formatted_heading_number('_')
483: h = hn + ' '+text
484: self.toc.append([level,hnum,filename,h,self.hcount[:]])
485: self._ensuremode('P')
486: self._writeline( '<BR><A HREF="'+filename+'">'+h+'</A>')
487:
488: lasttoc, this, first, last, next, prev, along, back, up = self.cal_nav(level)
489: hnav, fnav = self.mk_nav(lasttoc, this, first, last, next, prev, along, back, up)
490:
491: extra = ''
492:
493:
494:
495:
496:
497:
498:
499:
500:
501: sink = named_file_sink(self.pass_frame, self.basedir + filename, self.master.weaver_prefix, self.eol)
502: child = html_weaver(
503: self.pass_frame, sink,
504: title = h,
505: pagehead = hnav,
506: pagefoot=fnav,
507: heading_prefix=hn,
508: head_extra=extra,
509: anchor=label,
510: language=self.language)
511: self.base = [child]
512: self.stack.append(child)
513:
514: def _trig(self,offset=0):
515: doc_level = len(self.stack)-1
516: return self.break_list[doc_level+offset]
517:
518: def _ins_head(self,level,text,atext,anchor):
519: adjusted_level = level - self._trig()
520: if anchor == '':
521: anchor = 'a'+str(self.acount)
522: self.acount = self.acount + 1
523: hn = self.get_formatted_heading_number('.')+'.'
524: hnum = self.get_formatted_heading_number('_')
525: h = hn + ' '+text
526: filename = self.pattern%('%04d'%self.childcount)
527: self.register_anchor(anchor,filename+'#'+anchor)
528: self.toc.append([level,hnum,filename+'#'+anchor,h,self.hcount[:]])
529: if atext:
530: for weaver in self.base:
531: weaver.head(adjusted_level,text,short_text=atext,key=anchor)
532: else:
533: for weaver in self.base:
534: weaver.head(adjusted_level,text,key=anchor)
535:
536: