[Telepathy-commits] [telepathy-doc/master] 2008-12-23 Murray Cumming <murrayc at murrayc.com>

Murray Cumming murrayc at murrayc.com
Tue Dec 23 03:22:18 PST 2008


* docs/book/insert_example_code.pl: Base this on the gtkmm-documentation
one rather than the flumotion-doc one (but using .c, not .cc), to
read all files in a directory rather than individual files.
* doc/book/Makefile.am: Call insert_example_code.pl with the correct
path.
* doc/book/C/telepathy.xml: Add the examples at some vaguely
appropriate places, to check that this works.
---
 ChangeLog                        |   10 ++++++++++
 docs/book/C/telepathy.xml        |   33 +++++++++++++++++++++++++++++++++
 docs/book/Makefile.am            |    2 +-
 docs/book/insert_example_code.pl |   35 +++++++++++++++++++++++++++--------
 4 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de6e311..6048eac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-12-23  Murray Cumming  <murrayc at murrayc.com>
 
+	* docs/book/insert_example_code.pl: Base this on the gtkmm-documentation 
+	one rather than the flumotion-doc one (but using .c, not .cc), to 
+	read all files in a directory rather than individual files.
+	* doc/book/Makefile.am: Call insert_example_code.pl with the correct 
+	path.
+	* doc/book/C/telepathy.xml: Add the examples at some vaguely 
+	appropriate places, to check that this works.
+
+2008-12-23  Murray Cumming  <murrayc at murrayc.com>
+
 	* docs/book/C/telepathy.xml: Define a base URL entity and use ulink to 
 	link to types, interfaces and methods in the Telepathy specification.
 
diff --git a/docs/book/C/telepathy.xml b/docs/book/C/telepathy.xml
index 173da23..109f4d0 100644
--- a/docs/book/C/telepathy.xml
+++ b/docs/book/C/telepathy.xml
@@ -201,6 +201,25 @@ of the Telapathy specification.
      types of information at once (string of handle, alias, avatar, presence, etc), 
      which is more efficient.
   </para>
+
+  <sect1>
+  <title>Connection Example</title>
+  <para>This example connects to a jabber account.</para>
+  <para><ulink url="&url_examples_base;connect">Source Code</ulink></para>
+  </sect1>
+
+  <sect1>
+  <title>Presence Example</title>
+  <para>This example sets the presence for a jabber account.</para>
+  <para><ulink url="&url_examples_base;set_presence">Source Code</ulink></para>
+  </sect1>
+
+  <sect1>
+  <title>Protocols Listing Example</title>
+  <para>This example list all available connection managers and the protocols that they support.</para>
+  <para><ulink url="&url_examples_base;list_all_protocols">Source Code</ulink></para>
+  </sect1>
+
 </chapter>
 
 <chapter id="chapter-handle">
@@ -251,6 +270,13 @@ of the Telapathy specification.
      - Tells me what type of channel I can open on a connection/contact. 
        For instance, text/media/tube.
   </para>
+
+  <sect1>
+  <title>Example</title>
+  <para>This example sends a text message to a jabber contact via a text channel.</para>
+  <para><ulink url="&url_examples_base;send_message">Source Code</ulink></para>
+  </sect1>
+
 </chapter>
 
 <chapter id="chapter-group">
@@ -306,6 +332,13 @@ added in future.
    - Avatars
    - Presence
   </para>
+
+  <sect1>
+  <title>Example</title>
+  <para>This example connects to a jabber account and lists all contacts for that account.</para>
+  <para><ulink url="&url_examples_base;list_contacts">Source Code</ulink></para>
+  </sect1>
+
 </chapter>
 
 <chapter id="chapter-chat-client">
diff --git a/docs/book/Makefile.am b/docs/book/Makefile.am
index 09d8a57..0c56d5c 100644
--- a/docs/book/Makefile.am
+++ b/docs/book/Makefile.am
@@ -24,7 +24,7 @@ DOC_LINGUAS = de
 
 # Create a DocBook source file that doesn't have the examples' comments blocks:
 C/telepathy-with-examples.xml: C/telepathy.xml insert_example_code.pl
-	$(PERL_PATH) $(srcdir)/insert_example_code.pl $(top_srcdir)/doc/examples $< >$@
+	$(PERL_PATH) $(srcdir)/insert_example_code.pl $(top_srcdir)/docs/examples $< >$@
 
 
 # main xml file for the doc
diff --git a/docs/book/insert_example_code.pl b/docs/book/insert_example_code.pl
index b21785c..4f312f8 100755
--- a/docs/book/insert_example_code.pl
+++ b/docs/book/insert_example_code.pl
@@ -16,20 +16,32 @@
 
       #Beginning of comment:
       # Look for
-      # <para><ulink url="&url_examples_base;helloworld.xml">Example File</ulink></para>
+      # <para><ulink url="&url_examples_base;helloworld">Source Code</ulink></para>
 
-      if(/<para><ulink url=\"&url_examples_base;(.*)\">(.*)<\/ulink><\/para>/)
+      if(/<para><ulink url=\"&url_examples_base;([\/\w]+)\">Source Code<\/ulink><\/para>/)
       {
         #List all the source files in that directory:
-        my $source_file = $examples_base . $1;
+        my $directory = $examples_base . $1;
 
-        # print "<para>File: <filename>${source_file}</filename>\n";
-        # print "</para>\n";
-        print "<programlisting>\n";
+        opendir(DIR, $directory);
+        my @dir_contents = readdir(DIR);
+        closedir(DIR);
 
-        &process_source_file("${source_file}");
+        my @source_files = grep(/\.c$/, @dir_contents);
+        my @header_files = grep(/\.h$/,  @dir_contents);
 
-        print "</programlisting>\n";
+        print "<!-- start inserted example code -->\n";
+
+        foreach $source_file (@header_files, @source_files)
+        {
+           print "<para>File: <filename>${source_file}</filename>\n";
+           print "</para>\n";
+           print "<programlisting>\n";
+
+           &process_source_file("${directory}/${source_file}");
+
+           print "</programlisting>\n";
+        }
 
         print "<!-- end inserted example code -->\n";
       }
@@ -50,6 +62,13 @@ sub process_source_file($)
 
   while(<SOURCE_FILE>)
   {
+    # Skip all text until the first code line.
+    if(!$found_start)
+    {
+      next unless /^[#\w]/;
+      $found_start = 1;
+    }
+
     s/&/&amp;/g;
     s/</&lt;/g;
     s/>/&gt;/g;
-- 
1.5.6.5



More information about the Telepathy-commits mailing list