--- deliantra/Deliantra-Client/DC/Pod.pm 2006/07/23 16:11:12 1.1
+++ deliantra/Deliantra-Client/DC/Pod.pm 2006/07/30 13:16:44 1.3
@@ -1,34 +1,36 @@
-package CFClient::Pod;
+package CFPlus::Pod;
use strict;
use Pod::POM;
-use CFClient;
-use CFClient::UI;
+use CFPlus;
+use CFPlus::UI;
-our $VERSION = 1; # bump if resultant formatting changes
+our $VERSION = 1.02; # bump if resultant formatting changes
our @result;
our $indent;
-package CFClient::Pod::AsXML;
+package CFPlus::Pod::AsMarkup;
use strict;
use base "Pod::POM::View::Text";
+*view_seq_file =
*view_seq_code =
*view_seq_bold = sub { "$_[1]" };
*view_seq_italic = sub { "$_[1]" };
*view_seq_space =
-*view_seq_link =
-*view_seq_index = sub { CFClient::asxml $_[1] };
+*view_seq_link = sub { CFPlus::asxml $_[1] };
+*view_seq_zero =
+*view_seq_index = sub { };
sub view_seq_text {
my $text = $_[1];
$text =~ s/\s+/ /g;
- CFClient::asxml $text
+ CFPlus::asxml $text
}
sub view_item {
@@ -41,12 +43,12 @@
sub view_verbatim {
(join "",
map +("\t" x ($indent / 2)) . "$_\n",
- split /\n/, CFClient::asxml $_[1])
+ split /\n/, CFPlus::asxml $_[1])
. "\n"
}
sub view_textblock {
- ("\t" x ($indent / 2)) . "$_[1]\n\n"
+ ("\t" x ($indent / 2)) . "$_[1]\n"
}
sub view_head1 {
@@ -69,29 +71,41 @@
$_[1]->content->present ($_[0])
}
-package CFClient::Pod::AsParagraphs;
+package CFPlus::Pod::AsParagraphs;
use strict;
use base "Pod::POM::View";
+*view_seq_file =
*view_seq_code =
*view_seq_bold = sub { "$_[1]" };
*view_seq_italic = sub { "$_[1]" };
-*view_seq_space =
-*view_seq_link =
-*view_seq_index = sub { CFClient::asxml $_[1] };
+*view_seq_zero = sub { };
+*view_seq_space = sub { my $text = $_[1]; $text =~ s/ / /g; $text };
+*view_seq_index = sub { warn "index<@_>\n"; $result[-1]{index}{$_[1]} = undef };
sub view_seq_text {
my $text = $_[1];
$text =~ s/\s+/ /g;
- CFClient::asxml $text
+ CFPlus::asxml $text
+}
+
+sub view_seq_link {
+ my (undef, $link) = @_;
+
+ # TODO:
+ # http://...
+ # ref
+ # pod/ref
+
+ "" . (CFPlus::asxml $_[1]) . "";
}
sub view_item {
push @result, {
indent => $indent * 8,
- text => $_[1]->title->present ($_[0]) . "\n\n",
+ markup => $_[1]->title->present ($_[0]) . "\n\n",
};
$_[1]->content->present ($_[0]);
()
@@ -100,7 +114,7 @@
sub view_verbatim {
push @result, {
indent => $indent * 16,
- text => "" . (CFClient::asxml $_[1]) . "",
+ markup => "" . (CFPlus::asxml $_[1]) . "\n",
};
()
}
@@ -108,7 +122,7 @@
sub view_textblock {
push @result, {
indent => $indent * 16,
- text => "$_[1]\n",
+ markup => "$_[1]\n",
};
()
}
@@ -116,7 +130,7 @@
sub view_head1 {
push @result, {
indent => $indent * 16,
- text => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
+ markup => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
};
$_[1]->content->present ($_[0]);
()
@@ -125,7 +139,7 @@
sub view_head2 {
push @result, {
indent => $indent * 16,
- text => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
+ markup => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
};
$_[1]->content->present ($_[0]);
()
@@ -134,7 +148,7 @@
sub view_head3 {
push @result, {
indent => $indent * 16,
- text => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
+ markup => "\n\n" . $_[1]->title->present ($_[0]) . "\n",
};
$_[1]->content->present ($_[0]);
()
@@ -151,8 +165,8 @@
if ($_[1]->format eq "image") {
push @result, {
indent => $indent * 16,
- text => "\x{fffc}",
- obj => [new CFClient::UI::Image path => "pod/" . $_[1]->text],
+ markup => "\x{fffc}",
+ widget => [new CFPlus::UI::Image path => "pod/" . $_[1]->text],
};
}
()
@@ -164,9 +178,9 @@
$item->content->present ($self);
}
-package CFClient::Pod;
+package CFPlus::Pod;
-my $pod_cache = CFClient::db_table "pod_cache";
+my $pod_cache = CFPlus::db_table "pod_cache";
sub load($$$$) {
my ($path, $filtertype, $filterversion, $filtercb) = @_;
@@ -176,7 +190,10 @@
my $phash = join ",", $filterversion, $VERSION, (stat _)[7,9];
- my ($chash, $pom) = eval { @{ Storable::thaw $pod_cache->get ("$path/$filtertype") } };
+ my ($chash, $pom) = eval {
+ local $SIG{__DIE__};
+ @{ Storable::thaw $pod_cache->get ("$path/$filtertype") }
+ };
return $pom if $chash eq $phash;
@@ -196,12 +213,16 @@
$pom
}
-sub as_xml($) {
+sub section($$) {
+ my ($pod, $section) = @_;
+}
+
+sub as_markup($) {
my ($pom) = @_;
local $indent = 0;
- $pom->present ("CFClient::Pod::AsXML")
+ $pom->present ("CFPlus::Pod::AsMarkup")
}
sub as_paragraphs($) {
@@ -210,8 +231,13 @@
local @result = ( { } );
local $indent = 0;
- $pom->present ("CFClient::Pod::AsParagraphs");
+ $pom->present ("CFPlus::Pod::AsParagraphs");
+
+ [grep exists $_->{markup}, @result]
+}
- [grep exists $_->{text}, @result]
+sub pod_paragraphs($) {
+ load CFPlus::find_rcfile "pod/$_[0].pod",
+ pod_paragraphs => 1, sub { as_paragraphs $_[0] };
}