`make docs' compiles documentation.
It uses asciidoc and is enriched by taking data directly from source code.
Some tests are done with ucw/doc/fastbuf.txt and ucw/fastbuf.h.
Created documentation is saved into the obj dir.
datafiles: $(DATAFILES)
tests: $(TESTS)
configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
+docs: runtree $(DOCS)
tags:
etags `find . -name "*.[ch]"`
$(Q)cp $^ $@
$(Q)$(call symlink,$@,run/$(DATADIR))
+# Rules for documentation
+$(o)/%.html: $(o)/%.txt
+ $(M)"AD $< -> $@"
+ $(Q)asciidoc $<
+
+$(o)/%.txt: $(s)/%.txt
+ $(M)"ED $< -> $@"
+ $(Q)$(s)/build/extract-doc.pl $< $@ $(o)/depend.new $(s)
+
# Default installation target
default-install:
testclean::
rm -f `find obj -name "*.test"`
+docclean::
+ rm -f $(DOCS) $(patsubst %.html,%.txt,$(DOCS))
+
# Extra default rules (appended to by submakefiles)
extras::
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my( $inname, $outname, $depname, $basedir ) = @ARGV;
+if( defined $inname ) {
+ open IN, $inname or die "Could not read $inname ($!)\n";
+} else {
+ open IN, "<&STDIN" or die "Could not read stdin ($!)\n";
+}
+if( defined $outname ) {
+ open OUT, ">$outname" or die "Could not write $outname ($!)\n";
+} else {
+ open OUT, ">&STDOUT" or die "Could not write to stdout ($!)\n";
+}
+my $hasdep;
+if( defined $depname ) {
+ open DEP, ">>$depname" or die "Could not write $depname ($!)\n";
+ $hasdep = 1;
+}
+
+print DEP "$outname:" if( $hasdep );
+
+sub process( $ ) {
+ my $file = shift;
+ open FILE, $file or die "Could nod read $file ($!)\n";
+ my $line;
+ my $active;
+ my $verbatim;
+ my $buff;
+ my $head;
+ while( defined( $line = <FILE> ) ) {
+ chomp $line;
+ if( $verbatim ) {
+ if( $line =~ /\*\// ) {
+ $verbatim = 0;
+ } else {
+ $line =~ s/^\s*\* ?//;
+ print OUT "$line\n";
+ }
+ } elsif( $active ) {
+ if( $line =~ /END\*\// ) {
+ print OUT "$buff\n";
+ } elsif( $line =~ /\*\// ) {
+ $active = 0;
+ } else {
+ $line =~ s/^\s*\* ?//;
+ $line =~ s/^\s*$/+/;
+ $buff .= "$line\n";
+ }
+ } else {
+ if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
+ chomp $line;
+ $line =~ s/^\s*//;
+ $line =~ s/\/\/.*//;
+ $head .= "\n$line";
+ if( $head =~ /;/ ) {
+ $head =~ s/\/\*.*?\*\///gs;
+ $head =~ s/\s+/ /g;
+ $head =~ s/;.*/;/;
+ print OUT "- + +++$head+++ +\n+\n$buff\n";
+ $head = undef;
+ $buff = undef;
+ }
+ } elsif( $line =~ /\/\*VERBATIM/ ) {
+ $verbatim = 1;
+ } elsif( $line =~ /\/\*DOC/ ) {
+ $active = 1;
+ }
+ }
+ }
+ close FILE;
+}
+
+my $line;
+while( defined( $line = <IN> ) ) {
+ chomp $line;
+ if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) {
+ $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir );
+ process( $fname );
+ print DEP " $fname" if( $hasdep );
+ } else {
+ print OUT "$line\n";
+ }
+}
+
+print DEP "\n" if( $hasdep );
+
+close IN;
+close OUT;
+close DEP;
endif
include $(s)/ucw/sorter/Makefile
+include $(s)/ucw/doc/Makefile
LIBUCW_MOD_PATHS=$(addprefix $(o)/ucw/,$(LIBUCW_MODS))
--- /dev/null
+# Makefile for the UCW GetOpt Library (c) 2007 Pavel Charvat <pchar@ucw.cz>
+
+DIRS+=ucw/doc
+
+DOCS+=$(addprefix $(o)/ucw/doc/,fastbuf.html)
--- /dev/null
+Fastbufs
+========
+
+Fastbufs are stream and file abstractions. They work with normal
+files, network sockets, memory buffers or just any file descriptor. It
+should be easy to implement other types by providing functions to
+refill and read the buffer.
+
+Apart from abstraction, they are very fast.
+
+The main iclude file is +ucw/fastbuf.h+: +
+!!ucw/fastbuf.h
extern struct cf_section fbpar_cf;
extern struct fb_params fbpar_def;
+/*DOC
+ * Opens a file.
+ */
struct fastbuf *bopen_file(const char *name, int mode, struct fb_params *params); /* Use params==NULL for defaults */
-struct fastbuf *bopen_file_try(const char *name, int mode, struct fb_params *params);
+/*DOC
+ * Tries to open a file (does not die, if it isn't sucessful).
+ */
+struct fastbuf /*BLAXLA*/ *bopen_file_try(const /*BAX*/ char *name, int mode, struct fb_params *params);
+/*DOC
+ * Opens a temporary file.
+ * It is placed with other temp filenames and deleted when closed.
+ */
struct fastbuf *bopen_tmp_file(struct fb_params *params);
struct fastbuf *bopen_fd_name(int fd, struct fb_params *params, const char *name);
static inline struct fastbuf *bopen_fd(int fd, struct fb_params *params)