#!/usr/bin/perl

use strict;
use warnings;
use Syntax::Kamelon;
use Syntax::Kamelon::Indexer;

my $tab = 40;
my $kam_version = Syntax::Kamelon->VERSION;

my $indexer = Syntax::Kamelon::Indexer->new(
);

my @syntaxes = $indexer->AvailableSyntaxes;

my %sections = ();

for (@syntaxes) {
	my $name = $_;
	my $xml = $indexer->GetXMLObject($name);
	my $lang_hash = $xml->Language;
	my $section = $lang_hash->{section};
	unless (defined $section) {
		$section = 'None',
	}
	unless (exists $sections{$section}) {
		$sections{$section} = {};
	}
	my $xmlversion = $lang_hash->{version};
	unless (defined $xmlversion) {
		$xmlversion = 'Unknown',
	}
	$sections{$section}->{$name} = $xmlversion;
}

print <<__EOF;
=head1 NAME

Syntax::Kamelon::Syntaxes - List of available syntaxes

=head1 LIST

This is a list of all included syntax definition files in this release $kam_version of B<Syntax::Kamelon>.
Please note that the names may contain spaces.

=over 4

__EOF

for (sort keys %sections) {
	my $sct = $_;
	print "=item B<$sct>\n\n";
	print " --NAME--";
	for (9 .. $tab) { print " " }
	print "--VERSION--\n";
	my $synt_hash = $sections{$sct};
	for (sort keys %$synt_hash) {
		my $nme = $_;
		my $out = " $nme";
		for (length($out) .. $tab) {
			$out = $out . " ";
		}
		$out = $out . $synt_hash->{$nme};
		print "$out\n";
	}
	print "\n";
}

print <<__EOF;

=back

=head1 AUTHOR AND COPYRIGHT

This document is written and maintained by:

Hans Jeuken < hanje at cpan dot org >

Copyright (c) 2017 -2023 by Hans Jeuken, all rights reserved.

Published under the same license as Perl.

=head1 SEE ALSO

L<Syntax::Kamelon>, L<Syntax::Kamelon::Builder>, L<Syntax::Kamelon::Debugger>, L<Syntax::Kamelon::Diagnostics>,
L<Syntax::Kamelon::XMLData>, L<Syntax::Kamelon::Format::Base>, L<Syntax::Kamelon::Format::ANSI>, 
L<Syntax::Kamelon::Format:HTML4>

=cut

__EOF
