From: g0dil Date: Tue, 1 Sep 2009 09:25:20 +0000 (+0000) Subject: First implementation of senfutil.Doxygen X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=42f4a13c65272fe04b84831dd3dee3c0be401ec7;p=senf.git First implementation of senfutil.Doxygen git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1362 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/site_scons/lib/Doxyfile.yap b/site_scons/lib/Doxyfile.yap new file mode 100644 index 0000000..44c1bf4 --- /dev/null +++ b/site_scons/lib/Doxyfile.yap @@ -0,0 +1,127 @@ + +INPUT = . +RECURSIVE = NO +PROJECT_NAME = "${PROJECTNAME}" +PROJECT_NUMBER = "(Version ${REVISION})" + +########################################################################### +# Layout customization + +DOXYFILE_ENCODING = UTF-8 +INPUT_ENCODING = UTF-8 + +ALWAYS_DETAILED_SEC = YES +MULTILINE_CPP_IS_BRIEF = YES +DETAILS_AT_TOP = YES + +ALIASES = "fixme=\xrefitem fixme \"Fix\" \"Fixmes\"" \ + "idea=\xrefitem idea \"Idea\" \"Ideas\"" \ + "implementation=\par \"Implementation note:\"" \ + "doc=\xrefitem doc \"Documentation request\" \"Documentation Requests\"" \ + "autotoc=\htmlonly
\endhtmlonly" \ + "seechapter=\htmlonly      → \endhtmlonly see " + +BUILTIN_STL_SUPPORT = YES + +SUBGROUPING = NO +EXTRACT_ALL = YES +HIDE_FRIEND_COMPOUNDS = YES +INTERNAL_DOCS = YES + +FILE_PATTERNS = *.c \ + *.cc \ + *.cci \ + *.ct \ + *.cti \ + *.h \ + *.hh \ + *.ih \ + *.mpp \ + *.dox +EXCLUDE_PATTERNS = *.test.cc \ + *.test.hh \ + .* \ + *~ \ + "#*#" +EXCLUDE_SYMBOLS = boost std +IMAGE_PATH = . + +SOURCE_BROWSER = YES +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 3 + +GENERATE_LATEX = NO +GENERATE_XML = NO +GENERATE_MAN = NO + +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +PREDEFINED = DOXYGEN \ + "SENF_PPI_MODULE(x)=" \ + "SENF_PARSER()=" \ + "SENF_FIXED_PARSER()=" \ + "SENF_PARSER_INHERIT(name)=" \ + "SENF_PARSER_FIELD(name,type)=type name() const" \ + "SENF_PARSER_FIELD_RO(name,type)=type::value_type name() const" \ + "SENF_PARSER_BITFIELD(name, bits, type)=senf::ParseField_ ## type(bits) name() const" \ + "SENF_PARSER_BITFIELD_RO(name, bits, type)=senf::ParseField_ ## type(bits)::value_type name() const" \ + "SENF_PARSER_CUSTOM_FIELD(name, type, size, isize)=type name() const" \ + "SENF_PARSER_PRIVATE_FIELD(name,type)=private: type name() const; public:" \ + "SENF_PARSER_PRIVATE_FIELD_RO(name, type)=private: type::value_type name() const; public:" \ + "SENF_PARSER_PRIVATE_BITFIELD(name, bits, type)=private: senf::ParseField_ ## type(bits) name() const; public:" \ + "SENF_PARSER_PRIVATE_BITFIELD_RO(name, bits, type)=private: senf::ParseField_ ## type(bits)::value_type name() const; public:" \ + "SENF_PARSER_SKIP(x)=" \ + "SENF_PARSER_SKIP_BITS(x)=" \ + "SENF_PARSER_GOTO(x)=" \ + "SENF_PARSER_GOTO_OFFSET(x)=" \ + "SENF_PARSER_LABEL(x)=" \ + "SENF_PARSER_INIT()=void init()" \ + "SENF_PARSER_FINALIZE(name)=" \ + "ParseField_unsigned(b)=UIntFieldParser" \ + "ParseField_signed(b)=IntFieldParser" \ + "ParseField_bool(b)=FlagParser" \ + "SENF_PARSER_ARRAY(name,elt_type,size)=senf::Parse_Array name() const" \ + "SENF_PARSER_LIST_B(name,elt_type,size_type)=senf::Parse_ListB::parser name() const" \ + "SENF_PARSER_LIST_N(name,elt_type,size_type)=senf::Parse_ListN::parser name() const" \ + "SENF_PARSER_VARIANT(name,chooser,types)=senf::Parse_Variant_Direct::parser name() const" \ + "SENF_PARSER_PRIVATE_VARIANT(name,chooser,types)=private: senf::Parse_Variant_Direct::parser name() const; public:" \ + "SENF_PARSER_VEC_N(name,elt_type,size_type)=senf::Parse_VectorN name() const" \ + "SENF_LOG_CLASS_AREA()=" \ + "SENF_LOG_DEFAULT_AREA(area)=" \ + "SENF_LOG_DEFAULT_STREAM(stream)=" \ + "BOOST_PP_ITERATE()=" \ + "BOOST_PARAMETER_KEYWORD(ns, name)=unspecified_keyword_type name;" +EXPAND_AS_DEFINED = prefix_ \ + SENF_LOG_DEF_STREAM \ + SENF_LOG_DEF_AREA \ + SENF_LOG_DEF_AREA_I + +EXTERNAL_GROUPS = NO + +HAVE_DOT = YES +COLLABORATION_GRAPH = NO +GROUP_GRAPHS = NO +GRAPHICAL_HIERARCHY = NO +DIRECTORY_GRAPH = NO +DOT_GRAPH_MAX_NODES = 10 +MAX_DOT_GRAPH_DEPTH = 5 +DOT_MULTI_TARGETS = YES +DOT_CLEANUP = NO + +SEARCHENGINE = YES + +########################################################################### +# The following options are MANDATORY to integrate with the build system + +OUTPUT_DIRECTORY = $(output_dir) +STRIP_FROM_INC_PATH = $(TOPDIR) +LAYOUT_FILE = $(LIBDIR)/DoxygenLayout.xml +GENERATE_HTML = $(html) +HTML_OUTPUT = $(html_dir) +HTML_HEADER = $(TOPDIR)/$(output_dir)/doxyheader.html +HTML_FOOTER = $(TOPDIR)/$(output_dir)/doxyfooter.html +INPUT_FILTER = $(LIBDIR)/filter.pl +TAGFILES = $(tagfiles) +GENERATE_TAGFILE = $(generate_tagfile) +DOT_PATH = $(LIBDIR) + diff --git a/site_scons/lib/DoxygenLayout.xml b/site_scons/lib/DoxygenLayout.xml new file mode 100644 index 0000000..94e2cda --- /dev/null +++ b/site_scons/lib/DoxygenLayout.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/site_scons/lib/dot b/site_scons/lib/dot new file mode 100755 index 0000000..c6bdbe4 --- /dev/null +++ b/site_scons/lib/dot @@ -0,0 +1,51 @@ +#!/bin/sh + +topdir="`dirname "$0"`"; topdir="`cd "$topdir/.."; pwd`" +if head -4 "$1" | grep -q nomunge; then + dot "$@" + exit $? +fi +sed -i -e 's/rankdir=LR/rankdir=TB/' "$1" +"$topdir/doclib/dot-munge.pl" "$1" +unflatten -l2 -c2 -f -o "$1".unflat "$1" +mv "$1".unflat "$1" + +case "$2" in + -Tpng:gd) + first="$1"; shift; shift + set -- "$first" "-Tpng" "$@" + ;; + *) +esac + +set -e + +dot "$@" + +case "$4" in + *.png) + if [ -r "$4" ]; then + size="`pngtopnm "$4" | sed -n -e '2p'`" + width_a="${size% *}" + height_a="${size#* }" + if [ $width_a -gt 800 ]; then + for file in "${1%.dot}".*; do + cp "$file" "$file.a" + done + sed -e 's/rankdir=LR/rankdir=TB/' -e t -e 's/rankdir=TB/rankdir=LR/' "$1.a" > "$1" + dot "$@" + size="`pngtopnm "$4" | sed -n -e '2p'`" + width_b="${size% *}" + height_b="${size#* }" + if [ $width_a -lt $width_b ]; then + for file in "${1%.dot}".*.a; do + mv "$file" "${file%.a}" + done + else + rm "${1%.dot}".*.a + fi + fi + fi + ;; + *) ;; +esac diff --git a/site_scons/lib/dot-munge.pl b/site_scons/lib/dot-munge.pl new file mode 100755 index 0000000..263b44e --- /dev/null +++ b/site_scons/lib/dot-munge.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -i -n + +# Reduce fontsize and change font +s/fontsize=10/fontsize=8/g; +s/fontname="FreeSans.ttf"/fontname="Verdana"/g; + +# Wrap long labels (templates and pathnames) +if (/label=\"([^"]{48,})\"/) { #"])){ # To make emacs happy ... + $pre=$`; + $post=$'; #'; # To make emacs happy ... + $label=$1; + + # Break at each komma or / + $label=~s{[,/]}{$&\\r\\ \\ \\ \\ \\ \\ \\ \\ }g; + + # If more than one '<' is in the label, break after each '<' + if (($label=~tr/1) { + $label=~s/ + + + + diff --git a/site_scons/lib/doxygen.sh b/site_scons/lib/doxygen.sh new file mode 100755 index 0000000..958a87b --- /dev/null +++ b/site_scons/lib/doxygen.sh @@ -0,0 +1,206 @@ +#!/bin/bash -e + +do_html_cleanup() +{ + sed -e 's/id="current"/class="current"/' \ + | tidy -ascii -q --wrap 0 --show-warnings no --fix-uri no \ + | sed -e 's/name="\([^"]*\)"\([^>]*\) id="\1"/name="\1"\2/g' \ + | xsltproc --novalid --nonet --html --stringparam topdir "$reltopdir" \ + "$base/html-munge.xsl" - +} + +########################################################################### + +# Build absolute, normalized pathname +abspath() +{ + case "$1" in + /*) echo "$1" ;; + *) echo "`pwd`/$1" ;; + esac | sed \ + -e 's/\/\/*/\//g' \ + -e:a \ + -e 's/\/\.\(\/\|$\)/\1/g' \ + -eta \ + -e:b \ + -e 's/\/[^\/]*\/..\(\/\|$\)/\1/' \ + -etb \ + -e 's/^\(\/..\)*\(\/\|$\)/\2/' \ + -e 's/^$/\//' +} + +# Create relative path from absolute directory $1 to absolute path $2 +relpath() +{ + local src="${1#/}" + local dst="${2#/}" + while true; do + if [ -z "$src" -a -z "$dst" ]; then + echo "Internal error in relpath()" 1>&2 + exit 1 + fi + srcd="${src%%/*}" + dstd="${dst%%/*}" + if [ "$srcd" = "$dstd" ]; then + src="${src#$srcd}"; src="${src#/}" + dst="${dst#$dstd}"; dst="${dst#/}" + else + break + fi + done + rel="`echo "$src" | sed -e "s/[^\/]*/../g"`/$dst" # `" + echo "${rel%/}" +} + +# Log executed commands +cmd() +{ + echo "+" "$@" + "$@" +} + +html_cleanup() +{ + mv "$1" "${1}.orig" + do_html_cleanup <"${1}.orig" >"$1" +} + +########################################################################### + +name="`basename "$0"`"; #`" +base="`dirname "$0"`"; base="`cd "$base"; pwd`" #`" +LIBDIR="$base" + +TEMP=`getopt -n $name -o '' -l html,tagfile,tagfile-name:,tagfiles:,output-dir:,html-dir: -- "$@"` +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi +eval set -- "$TEMP" + +tagxsl="$base/tag-munge.xsl" + +html="NO"; tagfile="NO"; tagfile_name=""; tagfiles=""; output_dir="doc"; html_dir="html" + +while true; do + case "$1" in + --html) + html="YES" ; shift ;; + --tagfile) + tagfile="YES" ; shift ;; + --tagfile-name) + tagfile_name="$2"; shift 2 ;; + --tagfiles) + for f in $2; do + f="`abspath "$f"`" #`" + tagfiles="$tagfiles${tagfiles:+ }$f" + done + shift 2 + ;; + --output-dir) + output_dir="$2"; shift 2 ;; + --html-dir) + html_dir="$2"; shift 2 ;; + --) + shift; break ;; + *) + echo "Internal error: $*"; exit 1 ;; + esac +done + +if [ -z "$1" ]; then + cat <] + [--tagfiles=] + [--output-dir=] + [--html-dir=] + +EOF + exit 1 +fi + +if [ "$tagfile" = "YES" -a -z "$tagfile_name" ]; then + echo "--tagfile-name is required with --tagfile" + exit 1 +fi + +doxydir="$1" + +if [ -f "$doxydir" ]; then + doxydir="`dirname "$doxydir"`" #`" +fi + +doxydir="`abspath "$doxydir"`" #`" + +########################################################################### + +## Find $TOPDIR + +cd "$doxydir" +while [ ! -r "SConstruct" -a "`pwd`" != "/" ]; do cd ..; done +if [ ! -r "SConstruct" ]; then + echo "topdir not found" + exit 1; +fi +TOPDIR="`pwd`"; +reltopdir="`relpath "$doxydir/$output_dir/$html_dir" "$TOPDIR"`" #`" +cd "$doxydir" + + +## Remove tagfile_name from list of tagfiles + +if [ -n "$tagfile_name" ]; then + tagfile_name="`abspath "$output_dir/$tagfile_name"`" #`" + x="$tagfiles"; tagfiles="" + for f in $x; do + if [ "$f" != "$tagfile_name" ]; then + tagfiles="$tagfiles${tagfiles:+ }$f" + fi + done +fi + +## Call doxygen proper + +generate_tagfile="" +if [ "$tagfile" = "YES" ]; then + generate_tagfile="$tagfile_name" +fi +export TOPDIR LIBDIR html tagfile tagfile_name tagfiles output_dir html_dir generate_tagfile + +cmd ${DOXYGEN:-doxygen} + + +## Clean up tagfile, if generated + +if [ "$tagfile" = "YES" ]; then + mv "$tagfile_name" "${tagfile_name}.orig" + cmd xsltproc --novalid --nonet -o "$tagfile_name" "$tagxsl" "${tagfile_name}.orig" +fi + + +## Call installdox + +if [ -n "$tagfiles" ]; then + args="" + for f in $tagfiles; do + n="`basename "$f"`" #`" + d="`dirname "$f"`" #`" + url="`relpath "$doxydir/$output_dir/$html_dir" "$d/$html_dir"`" #`" + args="$args${args:+ }-l $n@$url" + done + + ( + cd "./$output_dir/$html_dir" + cmd "./installdox" $args + ) +fi + + +## Postprocess html files, if generated + +if [ "$html" = "YES" ]; then + for h in "$doxydir/$output_dir/$html_dir"/*.html; do + cmd html_cleanup "$h" + done +fi diff --git a/site_scons/lib/doxyheader.yap b/site_scons/lib/doxyheader.yap new file mode 100644 index 0000000..22ed25a --- /dev/null +++ b/site_scons/lib/doxyheader.yap @@ -0,0 +1,26 @@ + + + +$title + + + + + + +
+
diff --git a/site_scons/lib/filter.pl b/site_scons/lib/filter.pl new file mode 100755 index 0000000..14ad930 --- /dev/null +++ b/site_scons/lib/filter.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl -n + +BEGIN { + ($topdir=$0) =~ s{doclib/.*$}{}; + print $topdir,"\n"; +} + +s/\s*$//; +while (s/\t/' 'x(8-length($`)%8)/e) {} + +if (/^\s*\\code$/ .. /\\endcode/ && !/^$/) { + $i=length($1) if /^(\s*)\\code$/; + print substr($_,$i),"\n"; +} +elsif (s/^(\s*)
$/$1
/ .. /<\/pre>/ && !/^$/) {
+    $i=length($1) if /^(\s*)
$/;
+    print substr($_,$i),"\n";
+} 
+else {
+    print $_,"\n";
+}
diff --git a/site_scons/lib/html-munge.xsl b/site_scons/lib/html-munge.xsl
new file mode 100644
index 0000000..5b35045
--- /dev/null
+++ b/site_scons/lib/html-munge.xsl
@@ -0,0 +1,509 @@
+
+
+
+  
+
+  
+  
+  
+    
+      
+      
+    
+  
+
+  
+    
+      
+        
+          
+            
+            
+            
+          
+          
+            
+          
+        
+      
+    
+  
+
+  
+
+  
+    
+    
+    
+  
+  
+  
+  
+  
+    
+    
+      
+      
+      
+    
+  
+
+  
+  
+
+  
+    
+      
+      commalist
+      
+    
+  
+ 
+  
+    
+
+ + + + + + + +
+ +
+ + + + ,
+ +
+ + + + + + + + + + glossary + + + + + + + + + + + + + + + + +

Contents

+
    + + + + + + + + + + + + + + + + #autotoc- + + + + + + + + +
+
+
+ + + + . + + + . + + + + . + + + + + + + + + + + + + + + + + anchor + + autotoc- + + + + + + + + + + + + + + + + + + + + + + + rect + + + + + + + + + + + + + + + + + + + memname + macro + + + + + + + + + + + + + + + + + + + + + ( + + + ) + + + + + + + + + ) + + + + + + + () + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Static Public Member Functions

Static Public Attributes

Public Member Functions

Public Attributes

Public Enumerators

Public Types

Non-Public Members

+
+ + + + + + + + + + + + + + + + + + + + qindextable + + + + + + + + xref-bug + + + + + + xref-fix + + + + + + xref-todo + + + + + + xref-idea + + + + + + parameters + + + + + + implementation + + + + + + sourceline + + + + + + references + + + + + + referencedby + + + + + + reimplementedfrom + + + + + + reimplementedin + + + + + + implementedin + + + + + + + + + + + + + + + + + members + + + + + + + literal + + + + + + + ext + + + + + + + anchor + + + + + + + memtitle + + + + + + + + + + + +
diff --git a/site_scons/lib/tag-munge.xsl b/site_scons/lib/tag-munge.xsl new file mode 100644 index 0000000..67f1f3d --- /dev/null +++ b/site_scons/lib/tag-munge.xsl @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/site_scons/senfutil.py b/site_scons/senfutil.py index 46e33d1..55665dc 100644 --- a/site_scons/senfutil.py +++ b/site_scons/senfutil.py @@ -1,6 +1,8 @@ -import os.path, glob +import os.path, glob, site_tools.Yaptu from SCons.Script import * +senfutildir = os.path.dirname(__file__) + # Fix for SCons 0.97 compatibility try: Variables @@ -60,12 +62,15 @@ Special command line parameters: # c) check for a local SENF, set options accordingly and update that SENF if needed def SetupForSENF(env, senf_paths = []): - senfutildir = os.path.dirname(__file__) + global senfutildir senf_paths.extend(('senf', '../senf', os.path.dirname(senfutildir), '/usr/local', '/usr')) tooldir = os.path.join(senfutildir, 'site_tools') env.Tool('Boost', [ tooldir ]) env.Tool('PhonyTarget', [ tooldir ]) + env.Tool('Yaptu', [ tooldir ]) + env.Tool('CopyToDir', [ tooldir ]) + env.Tool('Doxygen', [ tooldir ]) env.Append( LIBS = [ 'senf', 'rt', '$BOOSTREGEXLIB', @@ -90,6 +95,11 @@ def SetupForSENF(env, senf_paths = []): LOGLEVELS_ = BuildTypeOptions('LOGLEVELS'), ) + rev = 'unknown' + if os.path.isdir('.svn'): + rev = 'r'+os.popen('svnversion').read().strip().lower() + elif os.path.isdir('.git'): + rev = 'r'+os.popen('gitsvnversion').read().strip().lower() env.SetDefault( CXXFLAGS_final = [], CXXFLAGS_normal = [], @@ -106,6 +116,12 @@ def SetupForSENF(env, senf_paths = []): LOGLEVELS_final = [], LOGLEVELS_normal = [], LOGLEVELS_debug = [], + + PROJECTNAME = "Unnamed project", + DOCLINKS = [], + PROJECTEMAIL = "nobody@nowhere.org", + COPYRIGHT = "nobody", + REVISION = rev, ) # Interpret command line options @@ -159,3 +175,48 @@ def Glob(env, exclude=[], subdirs=[]): sources += [ x for x in glob.glob(os.path.join(subdir,"*.cc")) if x not in testSources and x not in exclude ] return (sources, testSources) + +def Doxygen(env, doxyheader=None, doxyfooter=None, doxycss=None, mydoxyfile=False, **kw): + # Additional interesting keyword arguments or environment variables: + # PROJECTNAME, DOCLINKS, PROJECTEMAIL, COPYRIGHT + + libdir=os.path.join(senfutildir, 'lib') + + if env.GetOption('clean'): + env.Clean('doc', env.Dir('doc')) + if not mydoxyfile: + env.Clean('doc', "Doxyfile") + + if not mydoxyfile: + # Create Doxyfile NOW + site_tools.Yaptu.yaptuAction("Doxyfile", + os.path.join(libdir, "Doxyfile.yap"), + env) + + # The other files are created using dependencies + if doxyheader: + doxyheader = env.CopyToDir(env.Dir("doc"), doxyheader) + else: + doxyheader = env.Yaptu("doc/doxyheader.html", os.path.join(libdir, "doxyheader.yap"), **kw) + if doxyfooter: + doxyfooter = env.CopyToDir(env.Dir("doc"), doxyfooter) + else: + doxyfooter = env.Yaptu("doc/doxyfooter.html", os.path.join(libdir, "doxyfooter.yap"), **kw) + if doxycss: + doxycss = env.CopyToDir(env.Dir("doc"), doxycss) + else: + doxycss = env.CopyToDir(env.Dir("doc"), os.path.join(libdir, "doxy.css")) + + doc = env.Doxygen("Doxyfile", + DOXYOPTS = [ '--html' ], + DOXYENV = { 'TOPDIR' : env.Dir('#').abspath, + 'LIBDIR' : libdir, + 'output_dir' : 'doc', + 'html_dir' : 'html', + 'html' : 'YES' }, + DOCLIBDIR = libdir, + DOXYGENCOM = "$DOCLIBDIR/doxygen.sh $DOXYOPTS $SOURCE") + + env.Depends(doc, [ doxyheader, doxyfooter, doxycss ]) + + return doc diff --git a/site_scons/site_tools/Yaptu.py b/site_scons/site_tools/Yaptu.py new file mode 100644 index 0000000..030f371 --- /dev/null +++ b/site_scons/site_tools/Yaptu.py @@ -0,0 +1,17 @@ +import SCons.Action, SCons.Builder, yaptu + +def yaptuAction(target, source, env): + source = env.arg2nodes(source) + target = env.arg2nodes(target) + file(target[0].get_path(),"w").write( + yaptu.process(file(source[0].get_path(),"r").read(), globals(), env.Dictionary())) + +YaptuAction = SCons.Action.Action(yaptuAction, + lambda t,s,e=None: 'Yaptu("%s", "%s")' % (t[0],s[0])) +YaptuBuilder = SCons.Builder.Builder(action=YaptuAction, single_source=1) + +def generate(env): + env['BUILDERS']['Yaptu'] = YaptuBuilder + +def exists(env): + return True diff --git a/site_scons/site_tools/__init__.py b/site_scons/site_tools/__init__.py new file mode 100644 index 0000000..e69de29