--- a/CMakeLists.txt Thu Jul 28 02:48:21 2011 +0300
+++ b/CMakeLists.txt Fri Aug 19 01:42:20 2011 +0300
@@ -41,7 +41,7 @@
set(CMAKE_REQUIRED_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS})
check_function_exists(lm_connection_get_keep_alive_rate HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE)
check_function_exists(lm_connection_unregister_reply_handler HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
-find_package(Perl)
+find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)")
# (this should be before targets definitions)
link_directories(${LUA_LIBRARY_DIRS} ${GLIB_LIBRARY_DIRS} ${LM_LIBRARY_DIRS})
@@ -62,8 +62,8 @@
COMPILE_FLAGS "-Wall ${DEBUG_COMPILE_FLAGS}")
## Extra targets
-if(PERL_FOUND)
- add_custom_command(OUTPUT ${lua-lm_BINARY_DIR}/loudmouth.html COMMAND ${PERL_EXECUTABLE} ${lua-lm_SOURCE_DIR}/docgen.pl -f html -t "Lua-loudmouth API reference" -o ${lua-lm_BINARY_DIR}/loudmouth.html -- ${loudmouth_SOURCES} DEPENDS ${lua-lm_SOURCE_DIR}/docgen.pl ${loudmouth_SOURCES} WORKING_DIRECTORY ${lua-lm_SOURCE_DIR})
+if(DOCGEN_EXECUTABLE)
+ add_custom_command(OUTPUT ${lua-lm_BINARY_DIR}/loudmouth.html COMMAND ${DOCGEN_EXECUTABLE} -f html -t "Lua-loudmouth API reference" -o ${lua-lm_BINARY_DIR}/loudmouth.html -- ${loudmouth_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${loudmouth_SOURCES} WORKING_DIRECTORY ${lua-lm_SOURCE_DIR})
add_custom_target(doc ALL DEPENDS ${lua-lm_BINARY_DIR}/loudmouth.html)
endif()
if(LUA_EXECUTABLE)
@@ -101,7 +101,7 @@
install(TARGETS loudmouth DESTINATION lib/lua/5.1)
install(FILES lm.lua DESTINATION share/lua/5.1)
install(FILES test.lua DESTINATION share/doc/${CPACK_PACKAGE_NAME}/examples)
-if(PERL_FOUND)
+if(DOCGEN_EXECUTABLE)
install(FILES ${lua-lm_BINARY_DIR}/loudmouth.html DESTINATION share/doc/${CPACK_PACKAGE_NAME})
endif()
install(FILES README TODO COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})
--- a/TODO Thu Jul 28 02:48:21 2011 +0300
+++ b/TODO Fri Aug 19 01:42:20 2011 +0300
@@ -5,9 +5,7 @@
Add versions to dependencies.
Finish parse function?
Do something about debug and logging.
-Document docgen or switch to some other documentation system.
-iterator over node childs (maybe with filtering by node name)
-get child value method
-xml console interception means?
+Get child value method
+Xml console interception means?
--- a/docgen.pl Thu Jul 28 02:48:21 2011 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-#! /usr/bin/perl
-
-# Copyright 2009, 2011 Myhailo Danylenko
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-=head1
-
-Reads source and generates documentation, embedded in comments
-
-=head1 SYNTAX
-
-docgen.pl [B<-o> I<outfile>] [B<-t> I<title>] [B<-f> I<format>] F<infile> [F<infile>] ...
-
-=cut
-
-use strict;
-use warnings;
-
-use Pod::Usage;
-use Getopt::Std;
-$Getopt::Std::STANDARD_HELP_VERSION = 1;
-
-our $VERSION = '0.0.3';
-our sub HELP_MESSAGE {
- pod2usage (-verbose => 2,
- -noperldoc => 1);
-}
-
-=head1 OPTIONS
-
-B<-o> F<outfile>
-
-Output file (if not specified - stdout).
-
-B<-t> I<title>
-
-Title for documentation html page
-
-B<-f> [I<html>|I<mdwn>]
-
-Output type: html (default) or markdown.
-
-B<-p> I<prefix>
-
-Prefix to search, by default c-like '///'
-
-B<-c> F<css-link>
-
-Url to css file to include in html header.
-
-=cut
-
-our ( $opt_o, $opt_t, $opt_f, $opt_p, $opt_c )
- = ( undef, "Docs", 'html', '///', undef );
-getopts ( 'o:t:f:p:c:' );
-$opt_c = $opt_c ? qq(\n<link rel="stylesheet" href="$opt_c" type="text/css" />) : "";
-my $prefix_rx = quotemeta $opt_p;
-
-my %docs;
-my @tags;
-my $inside;
-my $harvest;
-my @values;
-
-foreach my $file (@ARGV) {
- if ( not open SOURCE, '<', $file ) {
- print STDERR "Cannot open $file\n";
- next;
- }
-
- my $chunk = 0;
-
- while (<SOURCE>) {
- if ( $inside ) {
- if ( /^$prefix_rx\s*G:\s*(.*?)\s*$/o ) {
- $inside = 0;
- $harvest = "V: $1";
- } elsif ( /^$prefix_rx\s?(.*?)\s*$/o ) {
- push @{$docs{$file}[$chunk]}, $1;
- } else {
- $inside = 0;
- $chunk++;
- }
- } elsif ( $harvest ) {
- if ( /\{\s*NULL.*\}/o ) {
- push @{$docs{$file}[$chunk]}, $harvest . ' ' . join ( ', ', @values );
- $harvest = undef;
- @values = ();
- $chunk++;
- } elsif ( /\{\s*"(.+?)".*\}/o ) {
- push @values, $1;
- }
- } elsif ( /^$opt_p\s*(.*?)\s*$/o ) {
-
- my $tag = $1;
- $inside = 1;
- push @{$docs{$file}[$chunk]}, $tag;
- # hack to allow twoword objects be written in text with spaces
- # now it matches "lm message" instead of "lm message node" -.-
- # and even if tag list will be reverse sorted by length,
- # it will produce nested links...
- # well, that all is now solved, but in not too impressive way..
- $tag =~ s/[_\s]+/./go;
- push @tags, $tag;
- }
- }
-
- close SOURCE;
-}
-
-@tags = reverse sort { length $a <=> length $b } @tags;
-
-if ( $opt_o ) {
- open OUTPUT, ">", "$opt_o"
- or die "Cannot open destination file '$opt_o': $!";
-} else {
- *OUTPUT = *STDOUT;
-}
-
-if ( $opt_f eq 'html' ) {
-
- print OUTPUT <<HEADER
-<html>
-<head>
-<title>$opt_t</title>$opt_c
-</head>
-<body>
-HEADER
-;
-
- # TODO preserve original order
- foreach my $file ( sort keys %docs ) {
- print OUTPUT "<hr>\n";
- foreach my $chunk ( @{$docs{$file}} ) {
- my $head = shift @$chunk;
- my $tag = $head;
- my $list = undef;
- $tag =~ s/[_\s]+/./go;
- print OUTPUT "<a name='$tag'></a><h2>$head</h2>\n<p>";
- foreach ( @$chunk ) {
- s/^A: /<br\/><b>Arguments:<\/b> /o;
- s/^R: /<br\/><b>Return values:<\/b> /o;
- s/^V: /<br\/><b>Values:<\/b> /o;
- s/^\[/<br\/><pre>/o;
- s/^\]/<\/pre><br\/>/o;
- if ( $list ) {
- if ( /^\* /o ) {
- s/^\* /<\/li>\n<li>/o;
- } else {
- s/^/<\/li>\n<\/ul> /o;
- $list = undef;
- }
- } elsif ( /^\* /o ) {
- s/^\* /<ul>\n<li>/o;
- $list = 1;
- }
- foreach my $tag ( @tags ) {
- # TODO quotemeta required, but for now
- # this bug is rather desired...
- #s/\b$tag\b/<a href="#$tag">$&<\/a>/g;
- s/(.)\b($tag)\b/ if ( $1 eq '#' or $1 eq '>' ) { "$1$2" } else { "$1<a href='#$tag'>$2<\/a>" } /ge;
- }
- print OUTPUT "$_\n";
- }
- print OUTPUT "</li>\n</ul>" if $list;
- print OUTPUT "</p>\n";
- }
- print OUTPUT "<hr>\n";
- }
-
- print OUTPUT "</body>\n</html>";
-
-} elsif ( $opt_f eq 'mdwn' ) {
-
- print OUTPUT <<HEADER
-
-[[!meta title="$opt_t"]]
-
-[[!toc]]
-HEADER
-;
-
- foreach my $file ( sort keys %docs ) {
- print OUTPUT "\n\n- - -";
- foreach my $chunk ( @{$docs{$file}} ) {
- my $head = shift @$chunk;
- my $tag = $head;
- my $code = 0;
- my $list = 0;
- $tag =~ s/[_\s]+/./go;
- print OUTPUT qq(\n\n<a name="$tag"></a>\n### $head);
- foreach (@$chunk) {
- if ( $code ) {
- if ( /^\]\s*(.*?)\s*$/o ) {
- print OUTPUT "\n\n$1 ";
- $code = 0;
- } else {
- print OUTPUT "\n\t$_";
- }
- next;
- } elsif ( /^\[\s*(.*?)\s*$/o ) {
- $code = 1;
- print OUTPUT "\n\n\t$1";
- next;
- } elsif ( $list ) {
- if ( not /^\* /o ) {
- $list = 0;
- print OUTPUT "\n";
- }
- } elsif ( /^\* /o ) {
- $list = 1;
- print OUTPUT "\n";
- }
-
- if ( s/^A: (.*)$/ \n**Arguments:** $1 /o ) {
- } elsif ( s/^R: (.*)$/ \n**Return values:** $1 /o ) {
- } elsif ( s/^V: (.*)$/ \n**Values:** $1 /o ) {
- } else {
- s/^/\n/o;
- }
- foreach my $tag ( @tags ) {
- s/(.)\b($tag)\b/ if ( $1 eq '#' or $1 eq '[' ) { "$1$2" } else { "$1\[$2\](#$tag)" } /ge;
- }
- print OUTPUT "$_";
- }
- };
- print OUTPUT "\n\n- - -";
- }
-
-}
-
-close OUTPUT;
-
-# The end