# HG changeset patch # User Myhailo Danylenko # Date 1337460265 -10800 # Node ID 2e5d5571a4ba04069610e12c34b55917bf70adf1 # Parent 1ad8103b72d6d95995ded717a4094ac143691d04 Drop in-project docgen diff -r 1ad8103b72d6 -r 2e5d5571a4ba CMakeLists.txt --- a/CMakeLists.txt Thu Jun 30 16:19:02 2011 +0300 +++ b/CMakeLists.txt Sat May 19 23:44:25 2012 +0300 @@ -32,13 +32,14 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(GMODULE REQUIRED gmodule-2.0) pkg_check_modules(MCABBER REQUIRED mcabber) -find_package(Perl) +find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)") link_directories(${GLIB_LIBRARY_DIRS} ${GMODULE_LIBRARY_DIRS} ${MCABBER_LIBRARY_DIRS}) ## Define targets add_library(lua MODULE lua.c util.c) +get_target_property(lua_SOURCES lua SOURCES) ## Set up compiler configure_file(config.h.in config.h ESCAPE_QUOTES) @@ -55,9 +56,8 @@ set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall") ## Extra targets -if(PERL_FOUND) - get_target_property(lua_SOURCES lua SOURCES) - add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html COMMAND ${PERL_EXECUTABLE} ${lua_SOURCE_DIR}/docgen.pl ${lua_SOURCES} > ${lua_BINARY_DIR}/lua.html DEPENDS ${lua_SOURCE_DIR}/docgen.pl ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR}) +if(DOCGEN_EXECUTABLE) + add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html COMMAND ${DOCGEN_EXECUTABLE} -f html -t "Documentation for Lua module for MCabber" -o ${lua_BINARY_DIR}/lua.html -- ${lua_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR}) add_custom_target(doc ALL DEPENDS ${lua_BINARY_DIR}/lua.html) endif() @@ -93,7 +93,7 @@ ## Set up installer install(TARGETS lua DESTINATION lib/mcabber) -if(PERL_FOUND) +if(DOCGEN_EXECUTABLE) install(FILES ${lua_BINARY_DIR}/lua.html DESTINATION share/doc/${CPACK_PACKAGE_NAME}) endif() install(DIRECTORY examples DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE) diff -r 1ad8103b72d6 -r 2e5d5571a4ba docgen.pl --- a/docgen.pl Thu Jun 30 16:19:02 2011 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -#! /usr/bin/perl - -# Copyright 2009 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 . - -use strict; -use warnings; - -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 () { - if ( $inside ) { - if ( not /^\/\/\// ) { - $inside = 0; - $chunk++; - } elsif ( /^\/\/\/ G:/ ) { - $inside = 0; - $harvest = 'V: ' . substr ( $_, 6 ); - } else { - push @{$docs{$file}[$chunk]}, substr ( $_, 4 ); - } - } elsif ( $harvest ) { - if ( /\{\s*NULL.*\}/ ) { - push @{$docs{$file}[$chunk]}, $harvest . ' ' . join ( ', ', @values ); - $harvest = undef; - @values = (); - $chunk++; - } elsif ( /\{\s*"(.+)".*\}/ ) { - push @values, $1; - } - } else { - next if not /^\/\/\//; - - $inside = 1; - my $tag = substr $_, 4; - chomp $tag; - 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/_/./g; - push @tags, $tag; - } - } - - close SOURCE; -} - -print <
-lua-loudmouth docs - -HEADER -; - -@tags = reverse sort { length $a <=> length $b } @tags; -# TODO preserve original order -foreach my $file ( sort keys %docs ) { - print "
"; - foreach my $chunk ( @{$docs{$file}} ) { - my $head = shift @$chunk; - my $tag = $head; - my $list = undef; - $tag =~ s/_/./g; - print "

$head

"; - foreach ( @$chunk ) { - s/^A: /Arguments: /; - s/^R: /Return values: /; - s/^V: /Values: /; - s/^\[ /

/;
-			s/^\]/<\/pre>/;
-			if ( $list ) {
-				if ( /^\* / ) {
-					s/^\* /<\/li>
  • /; - } else { - s/^/<\/li><\/ul> /; - $list = undef; - } - } elsif ( /^\* / ) { - s/^\* /" if $list; - print "

    " - } - print "
    "; -} - -print "" - -# The end