aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 14:53:57 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 14:53:57 +0000
commitd7a014f9761f2bc36d7ff10d83c364cd2a2d5e83 (patch)
tree95e39015cda9e40490b614c52e80132a04cfb762
parente007424e0dcbda833c1fabc34e19d0d69045ef87 (diff)
downloadpaludis-d7a014f9761f2bc36d7ff10d83c364cd2a2d5e83.tar.gz
paludis-d7a014f9761f2bc36d7ff10d83c364cd2a2d5e83.tar.xz
More Programming with Paludis work
-rw-r--r--configure.ac1
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/doc_programming_with_paludis.doxygen55
-rw-r--r--doc/doxygen.conf.in2
-rw-r--r--doc/examples/Makefile.am26
-rw-r--r--doc/examples/pwp_basic_cplusplus_app.cc35
-rw-r--r--doc/examples/pwp_basic_ruby_app.rb14
7 files changed, 86 insertions, 49 deletions
diff --git a/configure.ac b/configure.ac
index 589c046..1c25493 100644
--- a/configure.ac
+++ b/configure.ac
@@ -645,6 +645,7 @@ AC_OUTPUT(
cran/Makefile
doc/Makefile
doc/doxygen.conf
+ doc/examples/Makefile
ebuild/Makefile
ebuild/digests/Makefile
ebuild/fetchers/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 772fb7c..6b15465 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = examples .
+
tagfiles = \
libstdc++.tag \
libwrapiter.tag
diff --git a/doc/doc_programming_with_paludis.doxygen b/doc/doc_programming_with_paludis.doxygen
index b31fd9b..0729e53 100644
--- a/doc/doc_programming_with_paludis.doxygen
+++ b/doc/doc_programming_with_paludis.doxygen
@@ -27,59 +27,13 @@ There are currently two APIs available:
A basic C++ application will look something like:
-\code
-#include <paludis/paludis.hh>
-#include <paludis/environment/default/default_environment.hh>
-
-#include <iostream>
-#include <cstdlib>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-int main(int, char *[])
-{
- try
- {
- paludis::PackageDatabaseEntryCollection::ConstPointer packages(
- paludis::DefaultEnvironment::get_instance()->package_database()->query(
- paludis::PackageDepAtom("app-editors/vim"), paludis::is_installed_only));
-
- if (packages->empty())
- cout << "Vim is not installed" << endl;
- else
- cout << "Vim " << packages->last()->version << " is installed" << endl;
- }
- catch (const paludis::Exception & e)
- {
- cerr << "Caught exception '" << e.message() << "' ("
- << e.what() << ")" << endl;
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-\endcode
+\include pwp_basic_cplusplus_app.cc
Compile this using <code>g++ -Wall -lpaludis -lpaludisdefaultenvironment</code>.
The same application written in Ruby will look something like:
-\verbatim
-#!/usr/bin/env ruby
-
-require 'Paludis'
-
-packages = Paludis::DefaultEnvironment::instance.package_database.query(
- "app-editors/vim", Paludis::InstallState::InstalledOnly)
-
-if packages.empty?
- puts "Vim is not installed"
-else
- puts "Vim " + packages.last.version + " is installed"
-end
-\endverbatim
+\verbinclude pwp_basic_ruby_app.rb
Notice how various Rubyisms (singleton styles, question mark methods, constants
for enums) are used. The Ruby interface aims to be natural to Ruby programmers
@@ -265,5 +219,10 @@ Additional capabilities are available through optional interfaces. These can be
via members named paludis::Repository::mask_interface, paludis::Repository::sets_interface
and so on -- these members will either be a pointer to the interface or a zero pointer.
+A full list of optional capabilities can be seen in the documentation for paludis::RepositoryCapabilities,
+from which paludis::Repository inherits.
+
+In Ruby, this works a bit differently. Members that return either a self reference or nil
+are available for each interface. They are named as their C++ equivalents.
*/
diff --git a/doc/doxygen.conf.in b/doc/doxygen.conf.in
index d4ba059..cdb8763 100644
--- a/doc/doxygen.conf.in
+++ b/doc/doxygen.conf.in
@@ -500,7 +500,7 @@ EXCLUDE_PATTERNS =
# directories that contain example code fragments that are included (see
# the \include command).
-EXAMPLE_PATH = ../
+EXAMPLE_PATH = ../ ./examples/
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
new file mode 100644
index 0000000..5201f6d
--- /dev/null
+++ b/doc/examples/Makefile.am
@@ -0,0 +1,26 @@
+CLEANFILES = *~
+MAINTAINERCLEANFILES = Makefile.in
+AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+SUBDIRS = .
+noinst_PROGRAMS = \
+ pwp_basic_cplusplus_app
+
+noinst_SCRIPTS = \
+ pwp_basic_ruby_app.rb
+
+EXTRA_DIST = $(check_PROGRAMS) $(check_SCRIPTS)
+
+pwp_basic_cplusplus_app_SOURCES = pwp_basic_cplusplus_app.cc
+pwp_basic_cplusplus_app_LDFLAGS = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la
+
+built-sources : $(BUILT_SOURCES)
+ for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
diff --git a/doc/examples/pwp_basic_cplusplus_app.cc b/doc/examples/pwp_basic_cplusplus_app.cc
new file mode 100644
index 0000000..9151fe3
--- /dev/null
+++ b/doc/examples/pwp_basic_cplusplus_app.cc
@@ -0,0 +1,35 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+
+#include <iostream>
+#include <cstdlib>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+int main(int, char *[])
+{
+ try
+ {
+ paludis::PackageDatabaseEntryCollection::ConstPointer packages(
+ paludis::DefaultEnvironment::get_instance()->package_database()->query(
+ paludis::PackageDepAtom("app-editors/vim"), paludis::is_installed_only));
+
+ if (packages->empty())
+ cout << "Vim is not installed" << endl;
+ else
+ cout << "Vim " << packages->last()->version << " is installed" << endl;
+ }
+ catch (const paludis::Exception & e)
+ {
+ cerr << "Caught exception '" << e.message() << "' ("
+ << e.what() << ")" << endl;
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/doc/examples/pwp_basic_ruby_app.rb b/doc/examples/pwp_basic_ruby_app.rb
new file mode 100644
index 0000000..630a0f2
--- /dev/null
+++ b/doc/examples/pwp_basic_ruby_app.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+require 'Paludis'
+
+packages = Paludis::DefaultEnvironment::instance.package_database.query(
+ "app-editors/vim", Paludis::InstallState::InstalledOnly)
+
+if packages.empty?
+ puts "Vim is not installed"
+else
+ puts "Vim " + packages.last.version + " is installed"
+end
+