Skip to content

Commit b92758e

Browse files
committed
Merge branch 'master' of github.com:perl6/doc
2 parents af090f6 + 321b666 commit b92758e

File tree

3 files changed

+76
-52
lines changed

3 files changed

+76
-52
lines changed

htmlify.pl

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
my %routines;
1111

1212
sub MAIN($out_dir = 'html') {
13-
for ('', <type language>) {
13+
for ('', <type language routine>) {
1414
mkdir "$out_dir/$_" unless "$out_dir/$_".IO ~~ :e;
1515
}
1616

@@ -39,11 +39,14 @@ ($out_dir = 'html')
3939
my $name = $chunk[0].content[0].content[0];
4040
next if $name ~~ /\s/;
4141
%names{$name}<routine>.push: "/type/$podname.html#$name";
42-
%routines{$name}.push: $chunk;
42+
%routines{$name}.push: $podname => $chunk;
4343
}
4444
unlink $tempfile;
4545
}
46-
write-index-file($out_dir);
46+
write-index-file(:$out_dir);
47+
for %routines.kv -> $name, @chunks {
48+
write-routine-file(:$out_dir, :$name, :@chunks);
49+
}
4750
# TODO: write per-routine docs
4851
# TODO: write top-level disambiguation files
4952
}
@@ -65,63 +68,82 @@ ($out_dir = 'html')
6568
}
6669
}
6770

68-
sub write-index-file($out_dir) {
69-
my $pod = Pod::Block::Named.new(
71+
sub pod-with-title($title, *@blocks) {
72+
Pod::Block::Named.new(
7073
name => "pod",
71-
content => Array.new(
74+
content => [
7275
Pod::Block::Named.new(
7376
name => "TITLE",
7477
content => Array.new(
7578
Pod::Block::Para.new(
76-
content => ["Perl 6 Documentation"],
79+
content => [$title],
7780
)
7881
)
7982
),
80-
Pod::Block::Para.new(
81-
content => ['Official Perl 6 documentation'],
82-
),
83-
# TODO: add more
84-
Pod::Heading.new(
85-
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(
104-
level => 1,
105-
content => Array.new(
106-
Pod::Block::Para.new(content => ["Types"])
107-
)
108-
),
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-
)
83+
@blocks,
84+
]
85+
);
86+
}
87+
88+
sub pod-block(*@content) {
89+
Pod::Block::Para.new(:@content);
90+
}
91+
92+
sub pod-link($text, $url) {
93+
Pod::FormattingCode.new(
94+
type => 'L',
95+
content => [
96+
join('|', $text, $url),
97+
],
98+
);
99+
}
100+
101+
sub pod-item(*@content, :$level = 1) {
102+
Pod::Item.new(
103+
:$level,
104+
:@content,
105+
);
106+
}
107+
108+
sub pod-heading($name, :$level = 1) {
109+
Pod::Heading.new(
110+
:$level,
111+
:content[pod-block($name)],
112+
);
113+
}
114+
115+
sub write-index-file(:$out_dir!) {
116+
say "Writing $out_dir/index.html";
117+
my $pod = pod-with-title('Perl 6 Documentation',
118+
Pod::Block::Para.new(
119+
content => ['Official Perl 6 documentation'],
120+
),
121+
# TODO: add more
122+
pod-heading("Language Documentation"),
123+
%types<language>.pairs.sort.map({
124+
pod-item( pod-link(.key, .value) )
125+
}),
126+
pod-heading('Types'),
127+
%types<type>.sort.map({
128+
pod-item(pod-link(.key, .value))
129+
}),
123130
);
124131
my $file = open :w, "$out_dir/index.html";
125132
$file.print: pod2html($pod);
126133
$file.close;
127134
}
135+
136+
sub write-routine-file(:$name!, :$out_dir!, :@chunks!) {
137+
say "Writing $out_dir/routine/$name.html";
138+
my $pod = pod-with-title("Documentation for routine $name",
139+
pod-block("Documentation for routine $name, assembled from the
140+
following types:"));
141+
$pod.content.push: @chunks.map(-> Pair (:key($type), :value($chunk)) {
142+
pod-heading($type),
143+
pod-block("From ", pod-link($type, "/type/{$type}#$name")),
144+
@$chunk
145+
});
146+
my $file = open :w, "$out_dir/routine/$name.html";
147+
$file.print: pod2html($pod);
148+
$file.close;
149+
}

lib/Str.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ If no matcher is supplied, a list of characters in the string
150150
Returns a list of lines (without trailing newline characters), i.e. the
151151
same as a call to C<$input.comb( / ^^ \N* /, $limit )> would.
152152
153-
=item words
153+
=head2 words
154154
155155
multi sub words(Str:D $input, $limit = Inf) returns Positional
156156
multi method words(Str:D $input: $limit = Inf) returns Positional
157157
158158
Returns a list of non-whitespace bits, i.e. the same as a call to
159159
C<$input.comb( / \S+ /, $limit )> would.
160160
161-
=item flip
161+
=head2 flip
162162
163163
multi sub flip(Str:D ) returns Str:D
164164
multi method flip(Str:D:) returns Str:D

sync

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
rsync -az --delete html/* feather2.perl6.nl:/var/www/doc.perl6.org

0 commit comments

Comments
 (0)