Skip to content

Commit f169ca1

Browse files
committed
[htmlify] refactor pod generation a bit
1 parent 8e1102b commit f169ca1

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

htmlify.pl

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -65,61 +65,67 @@ ($out_dir = 'html')
6565
}
6666
}
6767

68-
sub write-index-file($out_dir) {
69-
my $pod = Pod::Block::Named.new(
68+
sub pod-with-title($title, *@blocks) {
69+
Pod::Block::Named.new(
7070
name => "pod",
71-
content => Array.new(
71+
content => [
7272
Pod::Block::Named.new(
7373
name => "TITLE",
7474
content => Array.new(
7575
Pod::Block::Para.new(
76-
content => ["Perl 6 Documentation"],
76+
content => [$title],
7777
)
7878
)
7979
),
80-
Pod::Block::Para.new(
81-
content => ['Official Perl 6 documentation'],
82-
),
83-
# TODO: add more
84-
Pod::Heading.new(
80+
@blocks,
81+
]
82+
);
83+
}
84+
85+
sub write-index-file($out_dir) {
86+
my $pod = pod-with-title('Perl 6 Documentation',
87+
Pod::Block::Para.new(
88+
content => ['Official Perl 6 documentation'],
89+
),
90+
# TODO: add more
91+
Pod::Heading.new(
92+
level => 1,
93+
content => Array.new(
94+
Pod::Block::Para.new(content => ["Language Documentation"])
95+
)
96+
),
97+
%types<language>.pairs.sort.map({
98+
Pod::Item.new(
8599
level => 1,
86-
content => Array.new(
87-
Pod::Block::Para.new(content => ["Language Documentation"])
88-
)
89-
),
90-
%types<language>.pairs.sort.map({
91-
Pod::Item.new(
92-
level => 1,
93-
content => [
94-
Pod::FormattingCode.new(
95-
type => 'L',
96-
content => [
97-
.key ~ '|' ~ .value;
98-
],
99-
),
100-
],
101-
);
102-
}),
103-
Pod::Heading.new(
100+
content => [
101+
Pod::FormattingCode.new(
102+
type => 'L',
103+
content => [
104+
.key ~ '|' ~ .value;
105+
],
106+
),
107+
],
108+
);
109+
}),
110+
Pod::Heading.new(
111+
level => 1,
112+
content => Array.new(
113+
Pod::Block::Para.new(content => ["Types"])
114+
)
115+
),
116+
%types<type>.sort.map({
117+
Pod::Item.new(
104118
level => 1,
105-
content => Array.new(
106-
Pod::Block::Para.new(content => ["Types"])
107-
)
119+
content => [
120+
Pod::FormattingCode.new(
121+
type => 'L',
122+
content => [
123+
.key ~ '|' ~ .value;
124+
],
125+
),
126+
],
108127
),
109-
%types<type>.sort.map({
110-
Pod::Item.new(
111-
level => 1,
112-
content => [
113-
Pod::FormattingCode.new(
114-
type => 'L',
115-
content => [
116-
.key ~ '|' ~ .value;
117-
],
118-
),
119-
],
120-
),
121-
}),
122-
)
128+
})
123129
);
124130
my $file = open :w, "$out_dir/index.html";
125131
$file.print: pod2html($pod);

0 commit comments

Comments
 (0)