hgbook

changeset 610:c82ff69f0935

Add markers to flag included snippets of code.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Mar 31 12:18:22 2009 -0700 (2009-03-31)
parents c17f8bffc9e5
children 4432ad34b8e5
files en/examples/run-example
line diff
     1.1 --- a/en/examples/run-example	Tue Mar 31 09:04:23 2009 -0700
     1.2 +++ b/en/examples/run-example	Tue Mar 31 12:18:22 2009 -0700
     1.3 @@ -127,9 +127,11 @@
     1.4          s = open(self.name).read().rstrip()
     1.5          s = s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
     1.6          ofp = wopen(result_name(self.name + '.tmp'))
     1.7 +        ofp.write('<!-- BEGIN %s -->\n' % self.name)
     1.8          ofp.write('<programlisting>')
     1.9          ofp.write(s)
    1.10          ofp.write('</programlisting>\n')
    1.11 +        ofp.write('<!-- END %s -->\n' % self.name)
    1.12          ofp.close()
    1.13          self.rename_output(self.name)
    1.14          norm = self.name.replace(os.sep, '-')
    1.15 @@ -309,6 +311,7 @@
    1.16                              assert os.sep not in out
    1.17                              if ofp is not None:
    1.18                                  ofp.write('</screen>\n')
    1.19 +                                ofp.write('<!-- END %s -->\n' % ofp_basename)
    1.20                                  ofp.close()
    1.21                                  err |= self.rename_output(ofp_basename, ignore)
    1.22                              if out:
    1.23 @@ -320,6 +323,7 @@
    1.24                                      % (norm, norm)] = 1
    1.25                                  read_hint = ofp_basename + ' '
    1.26                                  ofp = wopen(result_name(ofp_basename + '.tmp'))
    1.27 +                                ofp.write('<!-- BEGIN %s -->\n' % ofp_basename)
    1.28                                  ofp.write('<screen>')
    1.29                              else:
    1.30                                  ofp = None
    1.31 @@ -333,7 +337,8 @@
    1.32                          # first, print the command we ran
    1.33                          if not hunk.startswith('#'):
    1.34                              nl = hunk.endswith('\n')
    1.35 -                            hunk = ('<prompt>%s</prompt> <userinput>%s</userinput>' %
    1.36 +                            hunk = ('<prompt>%s</prompt> '
    1.37 +                                    '<userinput>%s</userinput>' %
    1.38                                      (prompts[ps],
    1.39                                       xml_escape(hunk.rstrip('\n'))))
    1.40                              if nl: hunk += '\n'
    1.41 @@ -353,6 +358,7 @@
    1.42                      if ofp is not None:
    1.43                          ofp.write(output)
    1.44                          ofp.write('</screen>\n')
    1.45 +                        ofp.write('<!-- END %s -->\n' % ofp_basename)
    1.46                          ofp.close()
    1.47                          err |= self.rename_output(ofp_basename, ignore)
    1.48                      os.close(self.cfd)
    1.49 @@ -379,7 +385,7 @@
    1.50      print >> sys.stderr, 'Options:'
    1.51      print >> sys.stderr, '  -a --all       run all examples in this directory'
    1.52      print >> sys.stderr, '  -h --help      print this help message'
    1.53 -    print >> sys.stderr, '     --help      keep new output as desired output'
    1.54 +    print >> sys.stderr, '     --keep      keep new output as desired output'
    1.55      print >> sys.stderr, '  -v --verbose   display extra debug output'
    1.56      sys.exit(exit)
    1.57