#!/usr/bin/perl
#
# Converts the input source code into a format ready to insert as an example
# into gtk-doc comments.
#

print " * <informalexample><programlisting>\n";

while (<>) {
  # Convert '<', '>' and '&' to entities.
  s%&%&amp;%g;
  s%<%&lt;%g;
  s%>%&gt;%g;

  # Convert '#' to the "&num;" entity to stop gtk-doc assuming its a type.
  s%#%&num;%g;

  # Convert asterisks in comments to "&ast;" entities.
  s%/\*%/&ast;%g;
  s%\*/%&ast;/%g;

  s%(\w+) \(\)%$1&nbsp;()%g;

  # Convert tabs to spaces, otherwise they won't line up properly.
  s%\t%        %g;

  print " *  $_";
}

print " * </programlisting></informalexample>\n";
