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).
There is also an associated string tangler which generates native strings.
1: #line 399 "tanglers.ipk" 2: #--------------------------------------------------------- 3: # ocaml tangler: write to a file, insert source line numbers 4: # using '#' pre-processor directives 5: from interscript.tanglers.base import tangler_base 6: import re 7: import string 8: class ocaml_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 = 'ocaml' 13: 14: def write_comment(self,line,file,count): 15: self.writeline('(* '+line+'*)') 16: 17: def start_section(self, file, count): 18: data = '# '+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 ocaml_comment_tangler(self.sink) 25: 26: def get_string_tangler(self,eol='\\n',width=0): 27: return ocaml_string_tangler(self.sink,self.weaver,eol,width) 28:
6.16.8.1. ocaml comment tangler
6.16.8.2. ocaml string tangler