gtk-doc r639 - in trunk: . tests tests/gobject/examples
- From: stefkost svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-doc r639 - in trunk: . tests tests/gobject/examples
- Date: Fri, 9 Jan 2009 15:12:15 +0000 (UTC)
Author: stefkost
Date: Fri Jan 9 15:12:15 2009
New Revision: 639
URL: http://svn.gnome.org/viewvc/gtk-doc?rev=639&view=rev
Log:
* TODO:
* gtk-doc.make:
* gtk-doc.notmpl.make:
* gtkdoc-fixxref.in:
* gtkdoc-mkdb.in:
* style.css:
* tests/gobject/examples/gobject.c:
* tests/gtk-doc.make:
* tests/gtk-doc.notmpl.make:
Initial go at implementing syntax highlighting for sources using
gnu source-highlight. Needs testing and modularisation.
Modified:
trunk/ChangeLog
trunk/TODO
trunk/gtk-doc.make
trunk/gtk-doc.notmpl.make
trunk/gtkdoc-fixxref.in
trunk/gtkdoc-mkdb.in
trunk/style.css
trunk/tests/gobject/examples/gobject.c
trunk/tests/gtk-doc.make
trunk/tests/gtk-doc.notmpl.make
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Fri Jan 9 15:12:15 2009
@@ -181,8 +181,16 @@
- not packaged for ubuntu
tools:
source-highlight (/usr/bin/source-highlight)
- source-highlight -i../tests/gobject/examples/gobject.c -o./gobject.html -n -t4 -sc
- source-highlight -i../tests/gobject/examples/gobject.c -o./gobject.html -n -t4 -sc -cstyle.css --no-doc
+ source-highlight -i./tests/gobject/examples/gobject.c -o$HOME/temp/gobject.html -n -t4 -sc
+ source-highlight -i./tests/gobject/examples/gobject.c -o$HOME/temp/gobject.html -n -t4 -sc -cstyle.css --no-doc
+ source-highlight -i./tests/gobject/examples/gobject.c -o$HOME/temp/gobject.xml -n -t4 -sc -f docbook
+
+if we highlight to docbook, we just get emphasis (bold)
+if we hightlight to html we get colors, we need to cehck what tags we should process though:
+<pre class="programlisting"> is used for all code boxes.
+<div class="informalexample"><pre class="programlisting"> is used for examples.
+
+links in the same module only work once its installed
= documentation best practises #518427 =
* we'd like offer a more complete skelleton
Modified: trunk/gtk-doc.make
==============================================================================
--- trunk/gtk-doc.make (original)
+++ trunk/gtk-doc.make Fri Jan 9 15:12:15 2009
@@ -118,7 +118,7 @@
cd $(srcdir)/html && gtkdoc-mkhtml $(mkhtml_options) $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
@echo 'gtk-doc: Fixing cross-references'
- cd $(srcdir) && gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
+ cd $(srcdir) && gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
touch html-build.stamp
##############
Modified: trunk/gtk-doc.notmpl.make
==============================================================================
--- trunk/gtk-doc.notmpl.make (original)
+++ trunk/gtk-doc.notmpl.make Fri Jan 9 15:12:15 2009
@@ -104,7 +104,7 @@
cd $(srcdir)/html && gtkdoc-mkhtml $(mkhtml_options) $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
@echo 'gtk-doc: Fixing cross-references'
- cd $(srcdir) && gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
+ cd $(srcdir) && gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
touch html-build.stamp
##############
Modified: trunk/gtkdoc-fixxref.in
==============================================================================
--- trunk/gtkdoc-fixxref.in (original)
+++ trunk/gtkdoc-fixxref.in Fri Jan 9 15:12:15 2009
@@ -81,6 +81,10 @@
# print "Path prefix: $path_prefix\n";
}
+if (!defined $MODULE_DIR) {
+ $MODULE_DIR="$HTML_DIR/$MODULE";
+}
+
my $dir;
# We scan the directory containing GLib and any directories in GNOME2_PATH
@@ -89,7 +93,7 @@
$dir =~ s/\s+$//;
$dir = $dir . "/share/gtk-doc/html";
if (-d $dir && $dir ne $HTML_DIR) {
-# print "Scanning GLib directory: $dir\n";
+ #print "Scanning GLib directory: $dir\n";
if ($dir !~ m%^\Q$path_prefix\E/%) {
&ScanIndices ($dir, 1);
} else {
@@ -102,7 +106,7 @@
foreach $dir (split (/:/, $ENV{"GNOME2_PATH"})) {
$dir = $dir . "/share/gtk-doc/html";
if (-d $dir && $dir ne $HTML_DIR) {
-# print "Scanning GNOME2_PATH directory: $dir\n";
+ #print "Scanning GNOME2_PATH directory: $dir\n";
if ($dir !~ m%^\Q$path_prefix\E/%) {
&ScanIndices ($dir, 1);
} else {
@@ -118,6 +122,9 @@
#print "Scanning HTML_DIR directory: $HTML_DIR\n";
&ScanIndices ($HTML_DIR, 0);
push (@VisitedPaths, $HTML_DIR);
+#print "Scanning HTML_DIR directory: $MODULE_DIR\n";
+&ScanIndices ($MODULE_DIR, 0);
+push (@VisitedPaths, $MODULE_DIR);
# check all extra dirs, but skip already scanned dirs or subdirs of those
foreach my $dir (@EXTRA_DIRS) {
@@ -126,12 +133,12 @@
foreach $vdir (@VisitedPaths) {
if ($dir eq $vdir || $dir =~ m%^\Q$vdir\E/%) {
-# print "Skipping EXTRA_DIR directory: $dir\n";
+ #print "Skipping EXTRA_DIR directory: $dir\n";
$skip=1;
}
}
next if $skip;
-# print "Scanning EXTRA_DIR directory: $dir\n";
+ #print "Scanning EXTRA_DIR directory: $dir\n";
push (@VisitedPaths, $dir);
# If the --extra-dir option is not relative and is not sharing the same
@@ -144,12 +151,12 @@
}
}
-&FixCrossReferences (defined $MODULE_DIR ? $MODULE_DIR : "$HTML_DIR/$MODULE");
+&FixCrossReferences ($MODULE_DIR);
sub ScanIndices {
my ($scan_dir, $use_absolute_links) = @_;
-# print "Scanning source directory: $scan_dir absolute: $use_absolute_links\n";
+ #print "Scanning source directory: $scan_dir absolute: $use_absolute_links\n";
# This array holds any subdirectories found.
my (@subdirs) = ();
@@ -229,6 +236,11 @@
undef $/;
my $entire_file = <HTMLFILE>;
close (HTMLFILE);
+
+ $entire_file =~ s%<div class=\"(example-contents|informalexample)\"><pre class=\"programlisting\">(.*?)</pre></div>%&HighlightSource($1,$2);%gse;
+ # from the highlighter we get all the functions marked up
+ # now we could turn them into GTKDOCLINK items
+ $entire_file =~ s%<span class=\"function\">(.*?)</span>%&MakeGtkDocLink($1);%gse;
$entire_file =~ s%<GTKDOCLINK\s+HREF="([^"]*)"\s*>(.*?)</GTKDOCLINK\s*>% &MakeXRef($1, $2); %gse;
@@ -250,10 +262,70 @@
my $href = $Links{$id};
if ($href) {
- # print " Fixing link: $id, $href, $text\n";
- return "<a\nhref=\"$href\"\n>$text</a>";
+ # if it is a link to same module, remove path to make it work
+ # uninstalled
+ if ($href =~ m%^\.\./$MODULE/(.*)$%) {
+ $href=$1;
+ }
+ #print " Fixing link: $id, $href, $text\n";
+ return "<a href=\"$href\">$text</a>";
} else {
- # print " no link for: $id, $text\n";
+ #print " no link for: $id, $text\n";
return $text;
}
}
+
+sub MakeGtkDocLink {
+ my ($symbol) = @_;
+
+ my $id=CreateValidSGMLID($symbol);
+
+ return "<span class=\"function\"><GTKDOCLINK HREF=\"$id\">$symbol</GTKDOCLINK></span>";
+}
+
+sub HighlightSource {
+ my ($type, $source) = @_;
+
+ # chop of leading and trailing empty lines
+ $source =~ s/^[\s\n]+//gs;
+ $source =~ s/[\s\n]+$//gs;
+ # write source to a temp file
+ my $temp_source_file="$MODULE_DIR/_temp_src.$$";
+ open (NEWFILE, ">$temp_source_file")
+ || die "Can't open $temp_source_file: $!";
+ print NEWFILE $source;
+ close (NEWFILE);
+
+ # format source
+ my $highlighted_source=`source-highlight -i$temp_source_file -n -t4 -sc -cstyle.css --no-doc`;
+ $highlighted_source =~ s%^<\!-- .*? -->%%gs;
+ $highlighted_source =~ s%<pre><tt>(.*?)</tt></pre>%$1%gs;
+ # revert double entity replacement
+ $highlighted_source =~ s/&lt;/</g;
+ $highlighted_source =~ s/&gt;/>/g;
+ $highlighted_source =~ s/&amp;/&/g;
+
+ # remove temp file
+ unlink ($temp_source_file)
+ || die "Can't delete $temp_source_file: $!";
+
+ return "<div class=\"$type\"><pre class=\"programlisting\">$highlighted_source</pre></div>";
+}
+
+sub CreateValidSGMLID {
+ my ($id) = $_[0];
+
+ # Special case, '_' would end up as '' so we use 'gettext-macro' instead.
+ if ($id eq "_") { return "gettext-macro"; }
+
+ $id =~ s/[_ ]/-/g;
+ $id =~ s/[,\.]//g;
+ $id =~ s/^-*//;
+ $id =~ s/::/-/g;
+ $id =~ s/:/--/g;
+
+ # Append ":CAPS" to all all-caps identifiers
+ if ($id !~ /[a-z]/ && $id !~ /-CAPS$/) { $id .= ":CAPS" };
+
+ return $id;
+}
Modified: trunk/gtkdoc-mkdb.in
==============================================================================
--- trunk/gtkdoc-mkdb.in (original)
+++ trunk/gtkdoc-mkdb.in Fri Jan 9 15:12:15 2009
@@ -24,10 +24,10 @@
# Script : gtkdoc-mkdb
# Description : This creates the DocBook files from the edited templates.
#
-# NOTE: When creating SGML IDS, we append ":CAPS" to all
+# NOTE: When creating SGML IDS, we append ":CAPS" to all
# all-caps identifiers to prevent name clashes. (It basically
# never is the case that mixed-case identifiers would collide.)
-# See the CreateValidSGMLID function.
+# See the CreateValidSGMLID function.
#############################################################################
use strict;
@@ -2132,15 +2132,15 @@
# Special case, '_' would end up as '' so we use 'gettext-macro' instead.
if ($id eq "_") { return "gettext-macro"; }
- # Append ":CAPS" to all all-caps identifiers
- if ($id !~ /[a-z]/ && $id !~ /-CAPS$/) { $id .= ":CAPS" };
-
$id =~ s/[_ ]/-/g;
$id =~ s/[,\.]//g;
$id =~ s/^-*//;
$id =~ s/::/-/g;
$id =~ s/:/--/g;
+ # Append ":CAPS" to all all-caps identifiers
+ if ($id !~ /[a-z]/ && $id !~ /-CAPS$/) { $id .= ":CAPS" };
+
return $id;
}
Modified: trunk/style.css
==============================================================================
--- trunk/style.css (original)
+++ trunk/style.css Fri Jan 9 15:12:15 2009
@@ -47,7 +47,7 @@
height: 2em;
z-index: 1;
}
- .navigation a, a:visited
+ .navigation a, .navigation a:visited
{
/* tango:scarlet red 3 */
color: #a40000;
@@ -192,3 +192,16 @@
{
margin-bottom: 0.0em
}
+
+/* code listings */
+
+pre .cbracket { color: #a40000; } /* tango: scarlet Red 3 */
+pre .comment { color: #a1a39d; } /* tango: aluminium 4 */
+pre .function { color: #000000; font-weight: bold; }
+pre .keyword { color: #4e9a06; } /* tango: chameleon 3 */
+pre .linenum { color: #babdb6; } /* tango: aluminium 3 */
+pre .normal { color: #000000; }
+pre .number { color: #75507b; } /* tango: plum 2 */
+pre .preproc { color: #204a87; } /* tango: sky Blue 3 */
+pre .string { color: #c17d11; } /* tango: chocolate 2 */
+pre .symbol { color: #ce5c00; } /* tango: orange 3 */
Modified: trunk/tests/gobject/examples/gobject.c
==============================================================================
--- trunk/tests/gobject/examples/gobject.c (original)
+++ trunk/tests/gobject/examples/gobject.c Fri Jan 9 15:12:15 2009
@@ -14,4 +14,3 @@
return 0;
}
-
Modified: trunk/tests/gtk-doc.make
==============================================================================
--- trunk/tests/gtk-doc.make (original)
+++ trunk/tests/gtk-doc.make Fri Jan 9 15:12:15 2009
@@ -113,7 +113,7 @@
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
@echo 'gtk-doc: Fixing cross-references'
@cd $(srcdir) && PATH=$(abs_top_builddir):$(PATH) PERL5LIB=$(abs_top_builddir):$(PERL5LIB) \
- gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
+ gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
touch html-build.stamp
##############
Modified: trunk/tests/gtk-doc.notmpl.make
==============================================================================
--- trunk/tests/gtk-doc.notmpl.make (original)
+++ trunk/tests/gtk-doc.notmpl.make Fri Jan 9 15:12:15 2009
@@ -98,7 +98,7 @@
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
@echo 'gtk-doc: Fixing cross-references'
@cd $(srcdir) && PATH=$(abs_top_builddir):$(PATH) PERL5LIB=$(abs_top_builddir):$(PERL5LIB) \
- gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
+ gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
touch html-build.stamp
##############
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]