original_file_name + ':' + str(original_lineno)is generated. Tanglers which call this function supply the original source file name and line number (not the file and line being written to).
Tanglers generate an entry for the identifier occurence which contains both the original source file and line number, and the output code file and line number.
The cross reference table the html weaver generates displays the output code file and line number (not the orginal file and line number), but it generates a reference of the form
'#' + original_file_name + ':' + str(original_lineno)using the original file name and line number.
The stacking weaver must trap calls to 'identifier_reference' because the hyperlinks the child weaver charged with generating this table would fail to refer to the specific html file containing the anchor. Instead, the stacking weaver must build the table.
To do that, the stacking weaver must know in which html child document the reference was generated so it can generate a hyperlink of the form:
childname + '#' + original_file_name + ':' + str(original_lineno)Unfortunately, the ids dictionary in the global frame currently being used to hold identifier cross references on a document wide basis, does not have this information available. It wouldn't make sense either, the information in that table is generated by tanglers, and has nothing to do with the weaver.
Therefore, the stacking weaver must _also_ intercept calls to 'set_fc_anchor', and create an entry in a dictionary keyed by the original filename and original line number, which tells in which html file the anchor was set: the stacking weaver knows that!
639: #line 794 "web_weaver.ipk" 640: def mk_identref(self,filename,target): 641: ids = self.master.ids 642: if len(ids) == 0: 643: ids = self.pass_frame.ids 644: if len(ids) == 0: return 0 645: sink = named_file_sink( 646: self.pass_frame, 647: self.basedir+filename, 648: self.master.weaver_prefix, 649: eol=self.eol) 650: self.mk_head(sink) 651: w = sink.writeline 652: w ('<BODY LANG="'+self.language+'">') 653: 654: w('<H1>Index of Identifiers</H1>') 655: self.print_table(ids,sink) 656: 657: w('</BODY>') 658: w('</HTML>') 659: return 1 660: 661: def mk_sectionref(self,filename,target): 662: dict = self.pass_frame.section_index 663: if len(dict) == 0: return 0 664: sink = named_file_sink( 665: self.pass_frame, 666: self.basedir+filename, 667: self.master.weaver_prefix, 668: eol=self.eol) 669: self.mk_head(sink) 670: w = sink.writeline 671: w ('<BODY LANG="'+self.language+'">') 672: 673: w('<H1>Index of Sections</H1>') 674: keys = dict.keys() 675: keys.sort() 676: w = sink.writeline 677: w('<TABLE COLS="1" BORDER="1" CELLPADDING="2">') 678: for k in keys: 679: w('<TR><TD VALIGN="Top"><CODE> '+k+' </CODE>: ') 680: nsections = len(dict[k]) 681: for i in range(nsections): 682: name = k + '['+str(i+1)+']' 683: anchor = '<A HREF="'+self.get_anchor(name)+\ 684: '" TARGET="'+target+'">'+str(i+1)+'</A>' 685: w(anchor+' ') 686: w('</TD></TR>') 687: w('</TABLE>') 688: w('</BODY>') 689: w('</HTML>') 690: return 1 691: 692: def mk_classref(self,filename,target): 693: ids = self.master.classes 694: if len(ids) == 0: 695: ids = self.pass_frame.classes 696: if len(ids)==0: return 0 697: sink = named_file_sink( 698: self.pass_frame, 699: self.basedir+filename, 700: self.master.weaver_prefix, 701: eol=self.eol) 702: w = sink.writeline 703: self.mk_head(sink) 704: w ('<BODY LANG="'+self.language+'">') 705: 706: w('<H1>Index of Classes</H1>') 707: self.print_table(ids,sink) 708: w('</BODY>') 709: w('</HTML>') 710: return 1 711: 712: def mk_funcref(self,filename,target): 713: ids = self.master.functions 714: if len(ids) == 0: 715: ids = self.pass_frame.functions 716: if len(ids) ==0: return 0 717: sink = named_file_sink( 718: self.pass_frame, 719: self.basedir+filename, 720: self.master.weaver_prefix, 721: eol=self.eol) 722: w = sink.writeline 723: self.mk_head(sink) 724: w ('<BODY LANG="'+self.language+'">') 725: 726: w('<H1>Index of Functions</H1>') 727: self.print_table(ids,sink) 728: 729: w('</BODY>') 730: w('</HTML>') 731: return 1 732: 733: def mk_sourceref(self,filename,target): 734: data = self.master.include_files 735: if not data: 736: data = self.pass_frame.include_files 737: if len(data) == 0: return 0 738: sink = named_file_sink( 739: self.pass_frame, 740: self.basedir+filename, 741: self.master.weaver_prefix, 742: eol=self.eol) 743: w = sink.writeline 744: self.mk_head(sink) 745: w ('<BODY LANG="'+self.language+'">') 746: 747: w('<H1>Source tree</H1>') 748: 749: for level, type, name in data: 750: w(' '*(level*3)+' '+type+': '+name+ '<BR>') 751: 752: w('<H1>External Sources</H1>') 753: w('<H2>FTP Sources</H2>') 754: data = self.master.ftp_list 755: if not data: 756: data = self.pass_frame.ftp_list 757: 758: w('<TABLE COLS="4">') 759: w('<TR><TH>host</TH><TH>directory</TH><TH>filename</TH><TH>local</TH></TR>') 760: for remote_host,remote_directory,remote_filename, local_filename in data: 761: w('<TR><TD>'+remote_host+\ 762: '</TD><TD>'+remote_directory+\ 763: '</TD><TD>'+remote_filename+\ 764: '</TD><TD>'+local_filename+'</TD></TR>') 765: w('</TABLE>') 766: w('</BODY>') 767: w('</HTML>') 768: return 1 769: 770: def mk_metricsref(self,filename,target): 771: data = self.master.iflist 772: if not data: 773: data = self.pass_frame.iflist 774: if len(data) ==0: return 0 775: sink = named_file_sink( 776: self.pass_frame, 777: self.basedir+filename, 778: self.master.weaver_prefix, 779: eol=self.eol) 780: w = sink.writeline 781: self.mk_head(sink) 782: w ('<BODY LANG="'+self.language+'">') 783: 784: w('<H1>Software Metrics</H1>') 785: 786: for name, count in data: 787: w(name+ ': '+str(count)+' LOC<BR>') 788: 789: w('</BODY>') 790: w('</HTML>') 791: return 1 792: 793: def mk_noticesref(self,filename,target): 794: data = self.master.noticedict 795: if len(data)==0: return 0 796: sink = named_file_sink( 797: self.pass_frame, 798: self.basedir+filename, 799: self.master.weaver_prefix, 800: eol=self.eol) 801: w = sink.writeline 802: self.mk_head(sink) 803: w ('<BODY LANG="'+self.language+'">') 804: 805: w('<H1>Notices</H1>') 806: keys = data.keys() 807: keys.sort() 808: for key in keys: 809: value = data[key] 810: w('<A HREF="'+key+'.html" TARGET="notices">'+key+'</A>') 811: sink2 = named_file_sink( 812: self.pass_frame, 813: self.basedir+key+'.html', 814: self.master.weaver_prefix, 815: eol=self.eol) 816: w2 = sink2.writeline 817: self.mk_head(sink) 818: w2( '<BODY>') 819: w2('<PRE>') 820: sink2.write(cvt_text(value)) 821: w2('</PRE>') 822: w2('</BODY>') 823: w2('</HTML>') 824: del w2 825: del sink2 826: w('</BODY>') 827: w('</HTML>') 828: return 1 829: 830: def mk_testref(self,filename,target): 831: ids = self.master.tests 832: if len(ids) == 0: 833: ids = self.pass_frame.tests 834: if len(ids)==0: return 0 835: sink = named_file_sink( 836: self.pass_frame, 837: self.basedir+filename, 838: self.master.weaver_prefix, 839: eol=self.eol) 840: w = sink.writeline 841: self.mk_head(sink) 842: w ('<BODY LANG="'+self.language+'">') 843: 844: w('<H1>Index of Tests</H1>') 845: w('<TABLE CLASS="TEST_SUMMARY_TABLE" COLS="4" BORDER="1">') 846: w('<TR><TH>No</TH><TH>Description</TH><TH>Kind</TH><TH>Result</TH><TR>') 847: keys = ids.keys() 848: keys.sort() 849: for key in keys: 850: descr, label, kind, result = ids[key] 851: href = self.get_anchor(label) 852: w('<TR><TD>'+str(key)+'</TD><TD><A TARGET="'+target+'" HREF="'+href+'">'+descr+'</A></TD><TD>'+kind+'</TD><TD>'+result+'</TD></TR>') 853: w('</TABLE>') 854: w('</BODY>') 855: w('</HTML>') 856: return 1 857: 858: def mk_filestatus(self,filename,target): 859: if 'weavers' in self.process.trace: 860: print 'Creating file status file:',filename 861: filestatus_output = simple_named_file_sink( 862: self.pass_frame,self.basedir+filename, self.master.weaver_prefix,eol='\r\n') 863: filestatus_weaver = html_weaver( 864: self.pass_frame, 865: filestatus_output,title='File Status', language=self.language) 866: filestatus_weaver.print_file_status(hlevel=1) 867: return 1 868: 869: def set_fc_anchor(self,file,count): 870: filename = self.base[0].sink.basename 871: self.anchor_file[(file,count)]=filename 872: for weaver in self.base: 873: weaver.set_fc_anchor(file,count) 874: 875: def heading_reference(self, *args, **kwds): pass # always generated 876: def identifier_reference(self, *args, **kwds): pass # always generated 877: def class_reference(self, *args, **kwds): pass # always generated 878: def function_reference(self, *args, **kwds): pass # always generated 879: def test_reference(self, *args, **kwds): pass # always generated 880: 881: