changeset 708:c82ff69f0935

Add markers to flag included snippets of code.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 31 Mar 2009 12:18:22 -0700
parents c17f8bffc9e5
children 4432ad34b8e5
files en/examples/run-example
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/en/examples/run-example	Tue Mar 31 09:04:23 2009 -0700
+++ b/en/examples/run-example	Tue Mar 31 12:18:22 2009 -0700
@@ -127,9 +127,11 @@
         s = open(self.name).read().rstrip()
         s = s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
         ofp = wopen(result_name(self.name + '.tmp'))
+        ofp.write('<!-- BEGIN %s -->\n' % self.name)
         ofp.write('<programlisting>')
         ofp.write(s)
         ofp.write('</programlisting>\n')
+        ofp.write('<!-- END %s -->\n' % self.name)
         ofp.close()
         self.rename_output(self.name)
         norm = self.name.replace(os.sep, '-')
@@ -309,6 +311,7 @@
                             assert os.sep not in out
                             if ofp is not None:
                                 ofp.write('</screen>\n')
+                                ofp.write('<!-- END %s -->\n' % ofp_basename)
                                 ofp.close()
                                 err |= self.rename_output(ofp_basename, ignore)
                             if out:
@@ -320,6 +323,7 @@
                                     % (norm, norm)] = 1
                                 read_hint = ofp_basename + ' '
                                 ofp = wopen(result_name(ofp_basename + '.tmp'))
+                                ofp.write('<!-- BEGIN %s -->\n' % ofp_basename)
                                 ofp.write('<screen>')
                             else:
                                 ofp = None
@@ -333,7 +337,8 @@
                         # first, print the command we ran
                         if not hunk.startswith('#'):
                             nl = hunk.endswith('\n')
-                            hunk = ('<prompt>%s</prompt> <userinput>%s</userinput>' %
+                            hunk = ('<prompt>%s</prompt> '
+                                    '<userinput>%s</userinput>' %
                                     (prompts[ps],
                                      xml_escape(hunk.rstrip('\n'))))
                             if nl: hunk += '\n'
@@ -353,6 +358,7 @@
                     if ofp is not None:
                         ofp.write(output)
                         ofp.write('</screen>\n')
+                        ofp.write('<!-- END %s -->\n' % ofp_basename)
                         ofp.close()
                         err |= self.rename_output(ofp_basename, ignore)
                     os.close(self.cfd)
@@ -379,7 +385,7 @@
     print >> sys.stderr, 'Options:'
     print >> sys.stderr, '  -a --all       run all examples in this directory'
     print >> sys.stderr, '  -h --help      print this help message'
-    print >> sys.stderr, '     --help      keep new output as desired output'
+    print >> sys.stderr, '     --keep      keep new output as desired output'
     print >> sys.stderr, '  -v --verbose   display extra debug output'
     sys.exit(exit)