Skip to content

Commit 9484ffc

Browse files
committed
categories on language page
1 parent 83ea8ae commit 9484ffc

File tree

8 files changed

+1211
-23
lines changed

8 files changed

+1211
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ highlights/package-lock.json
2929
.pod-cache
3030
retest
3131
build/
32+
notesOnInstalling.md

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ COLON_Z := :Z
77
SELINUX_OPT := $(shell [ $(DOCKER_SELINUX_LABEL) -eq 1 ] && echo "$(COLON_Z)" || echo '' )
88
# dependencies for a new doc/Language build:
99
LANG_POD6_SOURCE := $(wildcard doc/Language/*.pod6)
10+
# set to True if the language index page is to be managed
11+
USE_CATEGORIES := False
1012

1113
.PHONY: html init-highlights html-nohighlight sparse assets webdev-build \
1214
bigpage test xtest ctest help run clean-html clean-images \
@@ -17,10 +19,10 @@ LANG_POD6_SOURCE := $(wildcard doc/Language/*.pod6)
1719
html: gen-pod6-source bigpage htmlify
1820

1921
htmlify: gen-pod6-source init-highlights assets
20-
perl6 htmlify.p6
22+
perl6 htmlify.p6 --manage=$(USE_CATEGORIES)
2123

2224
gen-pod6-source: $(LANG_POD6_SOURCE) doc/Language/00-POD6-CONTROL
23-
perl6 util/manage-page-order.p6 update
25+
perl6 util/manage-page-order.p6 update --manage=$(USE_CATEGORIES)
2426

2527
init-highlights:
2628
ATOMDIR="./highlights/atom-language-perl6"; \

doc/Language/00-POD6-CONTROL

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#
44
# DO NOT REMOVE OR MODIFY THE FILE NAME AT THE END OF EACH LINE
55

6+
section: AT THE BEGINNING
67

8+
Brief Introduction FILE: intro
79
Perl 6 Example P6-101 FILE: 101-basics
810

911
section: MIGRATION GUIDES

doc/Language/intro.pod6

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
=begin pod
2+
3+
=TITLE Brief Introduction
4+
5+
=SUBTITLE Using the Perl6 Documentation
6+
7+
Documenting a large language like Perl6 has to balance several contradictory goals, such as being brief
8+
whilst being comprehensive, catering to professional developers with wide experience whilst also being accessible to
9+
newcomers to the language.
10+
11+
For a quick hands-on introduction, there is a short L<C<annotated programming example>|/language/101-basics>.
12+
13+
For programmers with experience in other languages, there are a number of B<Migration> guides that compare and
14+
contrast the features of Perl6 with other languages.
15+
16+
A number of B<Tutorials> cover several areas in which Perl6 is particularly innovative. The section headers should help navigate
17+
the remaining documents.
18+
19+
There are a number of L<C<useful resources>|https://perl6.org/resources> listed elsewhere on the perl6.org site.
20+
These include articles, books, slide presentations, and videos.
21+
22+
It has been found that newcommers to Perl6 often ask questions that indicate assumptions carried over from other
23+
programming paradigms. It is suggested that the following sections in the FUNDAMENTAL TOPICS section
24+
should be reviewed first.
25+
26+
=item L<C<Signatures>|/type/Signature> - each routine, which includes subroutines and methods, has a signature.
27+
Understanding the information given in the signature of a C<sub> or C<method> provides a quick way to
28+
grasp the operation and effect of the routine.
29+
30+
=item L<C<Containers>|/language/containers> - variables, which are like the nouns of a computer language, are
31+
containers in which information is stored. The first letter in the formal
32+
name of a container, such as the '$' of $my-variable, or '@' of @an-array-of-things, or '%' of %the-scores-in-the-competition,
33+
conveys information about the container. However, Perl6 is more abstract than other languages about what can be stored
34+
in a container. So, for example, a $scaler container can contain an object that is in fact an array.
35+
36+
=item L<C<Classes and Roles>|/language/classtut> - Perl6 is fundamentally based on objects, which are described
37+
in terms of classes and roles. Perl6, unlike some languages, does not
38+
B<impose> object-oriented programming practices, and useful programs can be written as if Perl6 was purely procedural in
39+
nature. However, complex software, such as the Perl6 compiler itself, is made much simpler by writing in object-oriented idioms,
40+
which is why the Perl6 documentation is more easily understood by reviewing what a class is and what a role is. Without understanding
41+
about Classes and Roles, it would be difficult to understand Types, to which a whole section of the documentation is devoted.
42+
43+
=item L<C<Traps to Avoid>|/language/traps> - Several common assumptions lead to code that does not work
44+
as the programmer intended. This section identifies some. It is worth reviewing when something doesn't quite work out.
45+
46+
=end pod

htmlify.p6

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ sub MAIN(
178178
Bool :$search-file = True,
179179
Bool :$no-highlight = False,
180180
Int :$parallel = 1,
181+
Bool :$manage = False,
181182
) {
182183
if !$no-highlight {
183184
if ! $coffee-exe.IO.f {
@@ -215,19 +216,22 @@ sub MAIN(
215216
spurt "html{$doc.url}.html",
216217
p2h($doc.pod, 'programs', pod-path => $pod-path);
217218
}
219+
218220
for $*DR.lookup("language", :by<kind>).list -> $doc {
219221
say "Writing language document for {$doc.name} ...";
220222
my $pod-path = pod-path-from-url($doc.url);
221223
spurt "html{$doc.url}.html",
222224
p2h($doc.pod, 'language', pod-path => $pod-path);
223225
}
226+
224227
for $*DR.lookup("type", :by<kind>).list {
225228
write-type-source $_;
226229
}
227230

231+
228232
write-disambiguation-files if $disambiguation;
229233
write-search-file if $search-file;
230-
write-index-files;
234+
write-index-files($manage);
231235

232236
for (set(<routine syntax>) (&) set($*DR.get-kinds)).keys -> $kind {
233237
write-kind $kind;
@@ -239,6 +243,7 @@ sub MAIN(
239243
}
240244

241245
spurt('links.txt', $url-log.URLS.sort.unique.join("\n"));
246+
242247
}
243248

244249
sub process-pod-dir(:$topdir, :$dir, :&sorted-by = &[cmp], :$sparse, :$parallel) {
@@ -309,6 +314,7 @@ sub process-pod-dir(:$topdir, :$dir, :&sorted-by = &[cmp], :$sparse, :$parallel)
309314
sub process-pod-source(:$kind, :$pod, :$filename, :$pod-is-complete) {
310315
my $summary = '';
311316
my $name = $filename;
317+
my Bool $section = ($pod.config<class>:exists and $pod.config<class> eq 'section-start');
312318
my $first = $pod.contents[0];
313319
if $first ~~ Pod::Block::Named && $first.name eq "TITLE" {
314320
$name = $pod.contents[0].contents[0].contents[0];
@@ -319,6 +325,15 @@ sub process-pod-source(:$kind, :$pod, :$filename, :$pod-is-complete) {
319325
else {
320326
note "$filename does not have a =TITLE";
321327
}
328+
if $first ~~ Pod::Block::Named && $first.name eq "TITLE" {
329+
$name = $pod.contents[0].contents[0].contents[0];
330+
if $kind eq "type" {
331+
$name = $name.split(/\s+/)[*-1];
332+
}
333+
}
334+
else {
335+
note "$filename does not have a =TITLE";
336+
}
322337
if $pod.contents[1] ~~ {$_ ~~ Pod::Block::Named and .name eq "SUBTITLE"} {
323338
$summary = $pod.contents[1].contents[0].contents[0];
324339
}
@@ -344,6 +359,7 @@ sub process-pod-source(:$kind, :$pod, :$filename, :$pod-is-complete) {
344359
:$summary,
345360
:$pod-is-complete,
346361
:subkinds($kind),
362+
:$section,
347363
|%type-info,
348364
);
349365

@@ -862,7 +878,7 @@ sub write-disambiguation-files() {
862878
say '';
863879
}
864880

865-
sub write-index-files() {
881+
sub write-index-files($manage) {
866882
say 'Writing html/index.html and html/404.html...';
867883
spurt 'html/index.html',
868884
p2h(extract-pod('doc/HomePage.pod6'),
@@ -884,14 +900,40 @@ sub write-index-files() {
884900

885901
# sort language index by file name to allow author control of order
886902
say 'Writing html/language.html ...';
887-
spurt 'html/language.html', p2h(pod-with-title(
888-
'Perl 6 Language Documentation',
889-
pod-block("Tutorials, general reference, migration guides and meta pages for the Perl 6 language."),
890-
pod-table($*DR.lookup('language', :by<kind>).map({[
903+
if $manage {
904+
my @p-chunks;
905+
my @end;
906+
for $*DR.lookup('language', :by<kind>).list {
907+
if .section {
908+
@p-chunks.push( pod-table(@end.map({[
909+
pod-link(.name, .url),
910+
.summary
911+
]})) ) if +@end;
912+
@p-chunks.push: pod-heading( .name, :level(2) );
913+
@end = ();
914+
} else {
915+
@end.push: $_;
916+
}
917+
}
918+
@p-chunks.push( pod-table(@end.map({[
891919
pod-link(.name, .url),
892920
.summary
893-
]}))
894-
), 'language');
921+
]})) ) if +@end;
922+
spurt 'html/language.html', p2h(pod-with-title(
923+
'Perl 6 Language Documentation',
924+
pod-block("Tutorials, general reference, migration guides and meta pages for the Perl 6 language."),
925+
@p-chunks
926+
), 'language');
927+
} else {
928+
spurt 'html/language.html', p2h(pod-with-title(
929+
'Perl 6 Language Documentation',
930+
pod-block("Tutorials, general reference, migration guides and meta pages for the Perl 6 language."),
931+
pod-table($*DR.lookup('language', :by<kind>).map({[
932+
pod-link(.name, .url),
933+
.summary
934+
]}))
935+
), 'language');
936+
}
895937

896938
my &summary;
897939
&summary = {

0 commit comments

Comments
 (0)