## ---------------------------------------------------------------------
##
## Copyright (C) 2006 - 2015 by the deal.II authors
##
## This file is part of the deal.II library.
##
## The deal.II library is free software; you can use it, redistribute
## it, and/or modify it under the terms of the GNU Lesser General
## Public License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
## The full text of the license can be found in the file LICENSE at
## the top level of the deal.II distribution.
##
## ---------------------------------------------------------------------


print "\n";


while (<>) {
    # simply print non-comment lines and let doxygen do all the work.
    # the only thing we have to make sure is that if we copy /*...*/
    # comments that doxygen doesn't get confused; do so by simply
    # adding a space
    #
    # also remove all $ signs to avoid confusing doxygen with what
    # may or may not be a formula
    if ( ! m!^\s*//! ) {
        s!/\*!/ \*!g;
        s!\*/!\* /!g;

        s!\$!!g;

	print " * $_";
    } else {
	# for comments, all we do is replace section headers, and
	# generate addressable anchors
	if ( /\@sect/ ) {
	   m!\@sect(\d)\{(.*)\}\s*$!;
	   $sect_name = $2;

	   # for the anchor, use the name of the section but discard
	   # everything except for letters, numbers, and underscores
	   $sect_name =~ s/[^a-zA-Z0-9_]//g;

	   print "\@endcode\n";
	   print " <a name=\"plain-$sect_name\"></a>\n";
	   print "\@code\n";
	}
    }	
}
