The write_comment method can be used to insert comments into a code file without them appearing in the documentation file.
There is an associated comment tangler which writes text as block of comments to the same sink: the whole block is enclosed in a single /* */ pair and nicely formatted. (The c comment tangler cannot interleave comments).
Design note: The idea of comment tanglers was to get rid of a 'mode' for tanglers. But the idea seems to have problems.
There is also an associated string tangler which generates native strings.
1: #line 232 "tanglers.ipk" 2: #--------------------------------------------------------- 3: # c tangler: write to a file, insert source line numbers 4: # using '#line' pre-processor directives 5: from interscript.tanglers.base import tangler_base 6: import re 7: import string 8: class c_tangler(tangler_base): 9: def __init__(self,sink,weaver): 10: tangler_base.__init__(self,sink,weaver) 11: self.matchid = re.compile('^[^A-Za-z_]*([A-Za-z_][A-Za-z_0-9]*)(.*)$') 12: self.language = 'C' 13: 14: def write_comment(self,line,file,count): 15: self.writeline('/* '+line+'*/') 16: 17: def start_section(self, file, count): 18: data = '#line '+str(count)+' '+'"'+file+'"' 19: self._writeline(data) 20: if self.weaver: 21: self.weaver.echotangle(self.sink.lines_written,data) 22: 23: def get_comment_tangler(self): 24: return c_comment_tangler(self.sink) 25: 26: def get_string_tangler(self,eol='\\n',width=0): 27: return c_string_tangler(self.sink,self.weaver,eol,width) 28: