[asterisk-commits] tzafrir: branch tzafrir/docs r121082 - /team/tzafrir/docs/build_tools/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 7 12:56:09 CDT 2008


Author: tzafrir
Date: Sat Jun  7 12:56:09 2008
New Revision: 121082

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121082
Log:
A simple script to extract documentation from sources.

Added:
    team/tzafrir/docs/build_tools/extract_docs   (with props)

Added: team/tzafrir/docs/build_tools/extract_docs
URL: http://svn.digium.com/view/asterisk/team/tzafrir/docs/build_tools/extract_docs?view=auto&rev=121082
==============================================================================
--- team/tzafrir/docs/build_tools/extract_docs (added)
+++ team/tzafrir/docs/build_tools/extract_docs Sat Jun  7 12:56:09 2008
@@ -1,0 +1,71 @@
+#!/usr/bin/perl -w
+
+# extract_docs: Asterisk modules documentation extraction script.
+#
+# Usage: 
+#   ./build_tools/extract_docs */*.c >modules_doc
+#
+# Optoinally:
+#   asciidoc -n -a toc modules_doc
+
+use strict;
+
+my %types_map = (
+	AST_APPLICATION_INFO => 'app',
+	AST_MANAGER_CMD_INFO => 'man',
+);
+
+my %docs = ();
+
+while (<>) {
+	if (/
+		^(AST_APPLICATION_INFO|AST_MANAGER_CMD_INFO)\(\s*
+		(\w*)\s*,
+		\s*"([^"]+)"\s*,
+	/x ) {
+		my ($type, $name, $name_str) = ($1, $2, $3);
+		<>; # next line: synopsys
+		m/^\s*("[^"]*")\s*,/;
+		my $synopsis = $1;
+		my @description = ();
+
+		# now: the lines of the description:
+		while(<>) {
+			last if /^\s*\);/;
+			chomp;
+			if (/^\s*"(.*)\\n"\s*$/) {
+				push @description, ($1);
+			}
+		}
+
+		$docs{$types_map{$type}}{$name_str} = {
+			file => $ARGV[0],
+			name => $name_str,
+			synopsis => $synopsis,
+			description => [@description],
+		}
+
+	}
+}
+
+print 
+"Asterisk Modules Documentation
+==============================
+
+Generated by \$Id$ .
+
+";
+
+for my $type (keys %docs) {
+	print "== $type\n";
+	for my $doc_ref (sort values %{$docs{$type}}) {
+		print
+			"=== $doc_ref->{name}\n".
+			".Synopsis: $doc_ref->{synopsis}\n".
+			"\n".
+			"Source: $doc_ref->{file}\n".
+			"\n".
+			(join "\n", @{$doc_ref->{description}})."\n".
+			"\n";
+	}
+}

Propchange: team/tzafrir/docs/build_tools/extract_docs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/docs/build_tools/extract_docs
------------------------------------------------------------------------------
    svn:executable = *

Propchange: team/tzafrir/docs/build_tools/extract_docs
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/docs/build_tools/extract_docs
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list