[gtkmm-documentation] Insert listings of .css and .gresource.xml files
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Insert listings of .css and .gresource.xml files
- Date: Fri, 2 Jan 2015 12:22:30 +0000 (UTC)
commit 61b152cdce023bdf0ac60c600356433728346dc3
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Fri Jan 2 13:20:23 2015 +0100
Insert listings of .css and .gresource.xml files
* docs/tutorial/insert_example_code.pl: Make it possible to insert listings
of files other than .h and .cc in the tutorial.
* docs/tutorial/C/index-in.docbook: Insert listings of .css and
.gresource.xml files.
docs/tutorial/C/index-in.docbook | 6 ++--
docs/tutorial/insert_example_code.pl | 40 +++++++++++++++++++++------------
2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/docs/tutorial/C/index-in.docbook b/docs/tutorial/C/index-in.docbook
index 79458f4..bfb4735 100644
--- a/docs/tutorial/C/index-in.docbook
+++ b/docs/tutorial/C/index-in.docbook
@@ -3623,7 +3623,7 @@ A class is derived from <classname>Gtk::Window</classname>.
</screenshot>
</figure>
-<para><ulink url="&url_examples_base;menus_and_toolbars">Source Code</ulink></para>
+<para><ulink url="&url_examples_base;menus_and_toolbars">Source Code</ulink></para> <!-- Insert
toolbar.gresource.xml -->
</sect2>
@@ -4652,7 +4652,7 @@ context->restore();</programlisting>
</screenshot>
</figure>
- <para><ulink url="&url_examples_base;drawingarea/image">Source Code</ulink></para>
+ <para><ulink url="&url_examples_base;drawingarea/image">Source Code</ulink></para> <!-- Insert
image.gresource.xml -->
</sect2>
</sect1>
<!--
@@ -7310,7 +7310,7 @@ The following example shows a simple use of a custom style property.
</screenshot>
</figure>
-<para><ulink url="&url_examples_base;custom/custom_widget/">Source Code</ulink></para>
+<para><ulink url="&url_examples_base;custom/custom_widget/">Source Code</ulink></para> <!-- Insert
custom_gtk.css -->
</sect2>
</sect1>
diff --git a/docs/tutorial/insert_example_code.pl b/docs/tutorial/insert_example_code.pl
index 139bc7b..383c4b0 100755
--- a/docs/tutorial/insert_example_code.pl
+++ b/docs/tutorial/insert_example_code.pl
@@ -1,22 +1,23 @@
#! /usr/bin/perl -w
+use strict;
+
#sub main()
{
my $examples_base = shift(@ARGV);
$examples_base .= "/" unless($examples_base =~ /\/$/);
- foreach $file (@ARGV)
+ foreach my $file (@ARGV)
{
open(FILE, $file);
while(<FILE>)
{
- #Beginning of comment:
# Look for
- # <para><ulink url="&url_examples_base;helloworld">Source Code</ulink></para>
+ # <para><ulink url="&url_examples_base;helloworld">Source Code</ulink></para> [<!-- Insert
filenames... -->]
- if(/<para><ulink url=\"&url_examples_base;([\/\w]+)\">Source Code<\/ulink><\/para>/)
+ if(/<para><ulink url=\"&url_examples_base;([\/\w]+)\">Source
Code<\/ulink><\/para>\s*(?:<!--\s*Insert\s+(.*?)-->)?/)
{
#Modify the line to add the branch, so people see the correct version.
#This is particularly important during major API changes every few years,
@@ -26,6 +27,10 @@
#List all the source files in that directory:
my $directory = $examples_base . $1;
+ #And possibly other files in that directory:
+ my @extra_files;
+ @extra_files = split ' ', $2 if defined($2);
+
opendir(DIR, $directory);
my @dir_contents = readdir(DIR);
closedir(DIR);
@@ -35,15 +40,14 @@
print "<!-- start inserted example code -->\n";
- foreach $source_file (@header_files, @source_files)
+ foreach my $source_file (@header_files, @source_files)
{
- print "<para>File: <filename>${source_file}</filename> (For use with gtkmm 3, not gtkmm 2)\n";
- print "</para>\n";
- print "<programlisting>\n";
-
- &process_source_file("${directory}/${source_file}");
+ &process_source_file($directory, $source_file, 1);
+ }
- print "</programlisting>\n";
+ foreach my $source_file (@extra_files)
+ {
+ &process_source_file($directory, $source_file, 0);
}
print "<!-- end inserted example code -->\n";
@@ -61,12 +65,16 @@
exit 0;
}
-sub process_source_file($)
+sub process_source_file($$$)
{
- my ($source_file) = @_;
- my $found_start = 0;
+ my ($directory, $source_file, $skip_leading_comments) = @_;
+ my $found_start = !$skip_leading_comments;
+
+ print "<para>File: <filename>$source_file</filename> (For use with gtkmm 3, not gtkmm 2)\n";
+ print "</para>\n";
+ print "<programlisting>\n";
- open(SOURCE_FILE, $source_file);
+ open(SOURCE_FILE, "$directory/$source_file");
while(<SOURCE_FILE>)
{
@@ -86,4 +94,6 @@ sub process_source_file($)
}
close(SOURCE_FILE);
+
+ print "</programlisting>\n";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]