Josh Heidenreich wrote:
You can see the result here: http://thejosh.info/libreoffice/module_readmes/
So, wow again for this great work - I couldn't resist, and merged that up with the existing doxygen documentation, result is here: http://docs.libreoffice.org/ That stuff is currently generated by a little shell script - I'm not particularly attached to it, and wouldn't mind perl or python there, but php so far is not used throughout the build system, maybe we can avoid it here, too? At any rate, rather ugly conversion of your beautiful php into bash attached. Should we go for perl/python, how about using one of the readily available markdown modules for README html-ization? (http://search.cpan.org/~bobtfish/Text-Markdown-1.000031/lib/Text/Markdown.pm and http://pypi.python.org/pypi/Markdown) Cheers, -- Thorsten
diff --git a/solenv/bin/mkdocs.sh b/solenv/bin/mkdocs.sh index dbf4c46..9cecec1 100755 --- a/solenv/bin/mkdocs.sh +++ b/solenv/bin/mkdocs.sh @@ -1,27 +1,119 @@ -#!/bin/bash +#!/usr/bin/env bash # -# Doxygen Doc generation +# Doxygen / README doc generation # +# See git for contributors +# + +function header { + title=$1 + breadcrumb=$2 + output=$3 + + cat - > $output <<EOF +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> + <title>$title</title> + + <style> + * { margin: 0; padding: 0; } + body { font-family: sans-serif; font-size: 12px; } + #head { padding: 20px; background: #18A303; } + #head a { color: #000; } + #body { padding: 20px; } + #foot { padding: 10px; font-size: 9px; border-top: 1px #18A303 solid; margin-top: 25px; } + p { line-height: 1.7em; margin-bottom: 1em; } + pre { margin-bottom: 0.5em; } + .multi-col { -moz-column-width: 13em; -webkit-column-width: 13em; -moz-column-gap: 1em; -webkit-column-gap: 1em; } + h1 {margin-bottom: 0.5em;} + h2,h3,h4 { margin: 1.3em 0 0.5em 0; } + ul, ol { margin: 0.5em 1.5em; } + </style> +</head> +<body> + <div id="head"> + <h1>$title</h1> + <p>$breadcrumb</p> + </div> + <div id="body"> +EOF +} + +function footer { + output=$1 + + cat - >> $output <<EOF + +</div> +<div id="foot"> + <small> + <p>Generated by Libreoffice <a href="http://cgit.freedesktop.org/libreoffice/core/plain/solenv/bin/mkdocs.sh">Module Description Tool</a></p> + <p>Last updated: +EOF +LANG= date >> $output +cat - >> $output <<EOF + </p> + </small> +</div> +</body> +</html> +EOF + +} + +function proc_text { + # Local links [[...]] + # Git links [git:...] + # Other remote links [...] + text=$(sed -re ' s/\[\[([-_a-zA-Z0-9]+)\]\]/<a href="\1.html">\1<\/a>/g' \ + | sed -re ' s/\[git:([^]]+)\]/<a href="http:\/\/cgit.freedesktop.org\/libreoffice\/core\/tree\/\1">\1<\/a>/g' \ + | sed -re ' s/\[([^]]+)\]/<a href="\1">\1<\/a>/g' ) + + # Headings + text=$(echo $text | sed -re ' s/====([^=]+)====/<h4>\1<\/h4>/g'); + text=$(echo $text | sed -re ' s/===([^=]+)===/<h3>\1<\/h3>/g'); + text=$(echo $text | sed -re ' s/==([^=]+)==/<h2>\1<\/h2>/g'); + + # Paragraphs + text="<p>$text" + text=$(echo $text | sed -re ' s/\n\n+/<\/p><p>/g') + text="$text</p>" + + echo -e $text +} + +function setup { + parm=$1 + if [ -z "${!parm}" ] ; then + echo "grep \"${parm}=\" ./config_host.mk | sed -re \" s/${parm}=//\")" + echo "$parm=$(grep \"${parm}=\" ./config_host.mk | sed -re \" s/${parm}=//\")" + eval "$parm=$(grep \"${parm}=\" ./config_host.mk | sed -re \" s/${parm}=//\")" + fi + if [ -z "${!parm}" ] ; then + echo "could not determine $parm" >&2 + exit 1 + fi +} # binaries that we need which doxygen > /dev/null 2>&1 || { - echo "You need doxygen for doc generation" + echo "You need doxygen for doc generation" >&2 exit 1 } which dot > /dev/null 2>&1 || { - echo "You need the graphviz tools to create the nice inheritance graphs" + echo "You need the graphviz tools to create the nice inheritance graphs" >&2 exit 1 } -# otherwise, aliases are not expanded below -shopt -s expand_aliases +# suck setup +setup "INPATH" +setup "SOLARINC" +shopt -s nullglob # Title of the documentation DOXYGEN_PROJECT_PREFIX="LibreOffice" -# suck setup -. ./Env.Host.sh - # get list of modules in build order - bah, blows RAM & disk, static list below INPUT_PROJECTS="o3tl basegfx basebmp basic comphelper svl vcl canvas cppcanvas oox svtools goodies drawinglayer xmloff slideshow sfx2 editeng svx writerfilter cui chart2 dbaccess sd starmath sc sw" @@ -44,7 +136,7 @@ fi DOXYGEN_INCLUDE_PATH=`echo $SOLARINC | sed -e ' s/-I\.//'g | sed -e ' s/ -I/ /'g | sed -e ' s|/usr/[^ ]*| |g'` # setup version string -DOXYGEN_VERSION="$GITTAG" +DOXYGEN_VERSION="master" ################################################### @@ -54,12 +146,13 @@ DOXYGEN_VERSION="$GITTAG" ################################################### # cleanup -rm -rf $BASE_OUTPUT/* +echo "cleaning up" && rm -rf $BASE_OUTPUT/* # make the stuff world-readable umask 022 # generate docs +echo "generating doxygen docs" DOXYGEN_REF_TAGFILES="" for PROJECT in `echo $INPUT_PROJECTS|tr ' ' '\n'|sort|tr '\n' ' '`; do @@ -89,39 +182,48 @@ do echo "Ref-Tags: $DOXYGEN_REF_TAGFILES" echo "Title: $DOXYGEN_PROJECTNAME" - nice -15 doxygen "$DOXYGEN_CFG" || exit 1 + #nice -15 doxygen "$DOXYGEN_CFG" || exit 1 # setup referenced tagfiles for next round DOXYGEN_REF_TAGFILES="$DOXYGEN_REF_TAGFILES $DOXYGEN_OUR_TAGFILE=$BASE_URL/$PROJECT/html" done # generate entry page -cat - > $BASE_OUTPUT/index.html <<EOF -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>LibreOffice Source Code Documentation (fragmentary)</title> - </head> - <body> - <h1>LibreOffice Source Code Documentation (fragmentary)</h1> - <ul> -EOF +echo "generating index page" +header "LibreOffice Modules" " " "$BASE_OUTPUT/index.html" +for module_name in *; do + if [ -d $module_name ]; then + cur_file=$(echo $module_name/README* $module_name/readme.txt*) + if [ -f "$cur_file" ]; then + # write index.html entry + text="<h2><a href=\"${module_name}.html\">${module_name}</a></h2>\n" + text="${text}$(head -n1 $cur_file | proc_text )" + echo -e $text >> "$BASE_OUTPUT/index.html" -for PROJECT in $INPUT_PROJECTS; -do - echo "<li><a href=\"$PROJECT/html/classes.html\">$PROJECT</a></li>" >> $BASE_OUTPUT/index.html + # write detailed module content + header "$module_name" "<a href=\"index.html\">LibreOffice</a> » ${module_name}" "$BASE_OUTPUT/${module_name}.html" + text="<p><b>View module in:</b>" + text="${text} <a href=\"http://cgit.freedesktop.org/libreoffice/core/tree/${module_name}\">cgit</a>" + if $(echo $INPUT_PROJECTS | grep -q $module_name); then + text="${text} <a href=\"${module_name}/html/classes.html\">Doxygen</a>" + fi + text="${text} </p><p> </p>" + text="${text}$(cat $cur_file | proc_text )" + echo -e $text >> "$BASE_OUTPUT/${module_name}.html" + footer "$BASE_OUTPUT/${module_name}.html" + else + empty_modules[${#empty_modules[*]}]=$module_name + fi + fi done +if [ ${#empty_modules[*]} -gt 0 ]; then + echo -e "<p> </p><p>READMEs were not available for these modules:</p><ul>\n" >> "$BASE_OUTPUT/index.html" + for module_name in "${empty_modules[@]}"; do + echo -e "<li><a href=\"http://cgit.freedesktop.org/libreoffice/core/tree/${module_name}\">${module_name}</a></li>\n"
"$BASE_OUTPUT/index.html"
+ done + echo -e "</ul>\n" >> "$BASE_OUTPUT/index.html" +fi -cat - >> $BASE_OUTPUT/index.html <<EOF - </ul> - <p>Last updated: -EOF -LANG= date >> $BASE_OUTPUT/index.html - -cat - >> $BASE_OUTPUT/index.html <<EOF - </p> - </body> -</html> -EOF +footer "$BASE_OUTPUT/index.html" ## done
Attachment:
pgpZcSZ8dHIgh.pgp
Description: PGP signature