Skip to content

Commit e0b9176

Browse files
author
Patrick Sebastian Zimmermann
committed
Merge branch 'master' of https://github.com/perl6/doc
2 parents de1d46d + a011ba9 commit e0b9176

31 files changed

+634
-403
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
./*
2+
.sass-cache/
3+
.git/
4+
.gitignore
5+
.travis.yml

CONTRIBUTING.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ in the [#perl6 IRC channel](https://perl6.org/community/irc).
3030
- [Mojolicious / Web Server](#mojolicious--web-server)
3131
- [SASS compiler](#sass-compiler)
3232
- [Build and view the documentation](#build-and-view-the-documentation)
33-
- [Using Docker](#using-docker)
33+
- [Using Docker](#using-docker-to-build-and-view-the-documentation)
3434

3535
## General principles
3636

@@ -113,6 +113,11 @@ tests about whitespace and spelling that might be difficult to get right
113113
on an initial commit, and shouldn't be considered to break the build. If
114114
you're contributing a patch or pull request, please make sure this passes.
115115

116+
If you have local modifications and want to insure they pass xtest before
117+
committing, you can use this command to test only modified files:
118+
119+
TEST_FILES=`git status --porcelain --untracked-files=no | awk '{print $2}'` make xtest
120+
116121
## Writing and Testing Examples
117122

118123
See [Writing and Testing Examples](EXAMPLES.md)
@@ -264,15 +269,39 @@ render the HTML documentation
264269
Now point your web browser to http://localhost:3000 to view the
265270
documentation.
266271

267-
#### Using Docker
272+
#### Using Docker to build and view the documentation
268273

269274
You can skip all the above and just build and view documentation with these simple commands (if you have docker already installed):
270275

271276
$ docker build -t perl6-doc .
272277
$ docker run -p 3000:3000 -it -v `pwd`:/doc perl6-doc
273278

274279
This will build the documentation for you by default and it will take some time, but for subsequent use you may want to skip build part if nothing has been changed:
275-
280+
276281
$ docker run -p 3000:3000 -it -v `pwd`:/doc perl6-doc bash -c "perl app.pl daemon"
277282

278283
Now point your web browser to http://localhost:3000 to view the documentation.
284+
285+
Alternatively, you can use make to build and run your container. To build the image:
286+
287+
$ make docker-image
288+
289+
To build the HTML documentation:
290+
291+
$ make docker-htmlify
292+
293+
To run the development web server for viewing documentation (on port 3000):
294+
295+
$ make docker-run
296+
297+
Note that while this requires less typing, some assumptions will be made for you regarding the name
298+
of the resulting image, the port the content is available over, etc. If you want, you can
299+
override these default values.
300+
301+
For instance, if you want the local documentation to be available over port 5001 of the host,
302+
pass the following to make when running:
303+
304+
$ make docker-run DOCKER_HOST_PORT=5001
305+
306+
Now the documentation will be available on the host at http://localhost:5001. Please see the
307+
Makefile for a list of available options.

Dockerfile

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
FROM rakudo-star:latest
22

3-
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
4-
5-
RUN apt-get --yes --no-install-recommends install \
6-
ruby-sass \
7-
cpanminus \
8-
build-essential \
9-
nodejs \
10-
graphviz \
11-
;
12-
13-
RUN zef install Pod::To::HTML Pod::To::BigPage
14-
15-
RUN cpanm -vn Mojolicious
16-
17-
RUN cpanm -vn CSS::Sass Mojolicious::Plugin::AssetPack
18-
19-
RUN mkdir /doc
20-
21-
WORKDIR /doc
22-
23-
EXPOSE 3000
24-
25-
CMD bash -c "make init-highlights && perl6 htmlify.p6 && perl app.pl daemon"
3+
RUN buildDeps=' \
4+
build-essential \
5+
cpanminus \
6+
npm \
7+
' \
8+
runtimeDeps=' \
9+
graphviz \
10+
make \
11+
nodejs \
12+
ruby-sass \
13+
' \
14+
testDeps=' \
15+
aspell \
16+
' \
17+
18+
&& set -x \
19+
&& apt-get update \
20+
&& apt-get --yes --no-install-recommends install $buildDeps $runtimeDeps $testDeps \
21+
&& rm -rf /var/lib/apt/lists/* \
22+
23+
&& cpanm -vn Mojolicious \
24+
&& zef install Test::META \
25+
26+
&& ln -s /usr/bin/nodejs /usr/bin/node \
27+
&& npm cache clean -f \
28+
&& npm install -g n \
29+
&& n stable \
30+
31+
&& apt-get purge --yes --auto-remove $buildDeps
32+
33+
WORKDIR /perl6/doc/
34+
EXPOSE 3000
35+
36+
CMD bash -c 'make test && make html && ./app-start'

Makefile

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
REPO_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
2+
3+
DOCKER_IMAGE_NAME ?= p6doc
4+
DOCKER_HOST_PORT ?= 3000
5+
DOCKER_SELINUX_LABEL ?= 0
6+
SELINUX_OPT := $(shell [ $(DOCKER_SELINUX_LABEL) -eq 1 ] && echo ':Z' || echo '' )
7+
18
.PHONY: html init-highlights html-nohighlight sparse sass webdev-build bigpage \
29
test xtest ctest help run clean-html clean-examples clean-images \
3-
clean-search clean test-links extract-examples push
10+
clean-search clean test-links extract-examples push \
11+
docker-image docker-htmlify docker-test docker-xtest docker-ctest docker-testall docker-run
412

513
html: bigpage htmlify
614

@@ -54,11 +62,43 @@ help:
5462
@echo " xtest: run the test suite, including extra tests"
5563
@echo " ctest: run the test suite, content tests only"
5664
@echo " run: run the development webserver"
65+
@echo "docker-image: build Docker image from Dockerfile"
66+
@echo "docker-htmlify: generate the HTML documentation (in container)"
67+
@echo "docker-test: run the test suite (in container)"
68+
@echo "docker-xtest: run the test suite, including extra tests (in container)"
69+
@echo "docker-ctest: run the test suite, content tests only (in container)"
70+
@echo "docker-testall: run all tests (in container)"
71+
@echo "docker-run: run the development webserver (in container)"
5772

5873
run:
5974
@echo "Starting local server…"
6075
morbo -w assets app.pl
6176

77+
docker-image:
78+
docker build -t $(DOCKER_IMAGE_NAME) .
79+
80+
docker-htmlify: docker-image docker-test
81+
docker run --rm -v $(REPO_PATH):/perl6/doc/$(SELINUX_OPT) $(DOCKER_IMAGE_NAME) \
82+
/bin/bash -c 'make html'
83+
84+
docker-test: docker-image
85+
docker run --rm -v $(REPO_PATH):/perl6/doc/$(SELINUX_OPT) $(DOCKER_IMAGE_NAME) \
86+
/bin/bash -c 'make test'
87+
88+
docker-xtest: docker-image
89+
docker run --rm -v $(REPO_PATH):/perl6/doc/$(SELINUX_OPT) $(DOCKER_IMAGE_NAME) \
90+
/bin/bash -c 'make xtest'
91+
92+
docker-ctest: docker-image
93+
docker run --rm -v $(REPO_PATH):/perl6/doc/$(SELINUX_OPT) $(DOCKER_IMAGE_NAME) \
94+
/bin/bash -c 'make ctest'
95+
96+
docker-testall: docker-test docker-xtest docker-ctest
97+
98+
docker-run: docker-image
99+
docker run --rm -p $(DOCKER_HOST_PORT):3000 -v $(REPO_PATH):/perl6/doc/$(SELINUX_OPT) \
100+
$(DOCKER_IMAGE_NAME) /bin/bash -c './app-start' &
101+
62102
clean-html:
63103
rm -rf html/*.html html/.*.html \
64104
html/language/ \

doc/Language/grammar_tutorial.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Grammars are made up of methods that define a regex, a token, or a rule.
4949
These are all varieties of different types of match methods. Once you have a
5050
grammar defined, you call it and pass in a string for parsing.
5151
52-
=begin code :preamble<grammar G{};>
52+
=begin code :preamble<grammar G{};my $string;>
5353
my $matchObject = G.parse($string);
5454
=end code
5555

doc/Language/grammars.pod6

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ the C<my> keyword, because named regexes are normally used within grammars.
3636
Being named gives us the advantage of being able to easily reuse the regex
3737
elsewhere:
3838
39-
=begin code :preamble<my regex number{};>
39+
=begin code :preamble<my regex number{...};>
4040
say so "32.51" ~~ &number; # OUTPUT: «True␤»
4141
say so "15 + 4.5" ~~ /<number>\s* '+' \s*<number>/ # OUTPUT: «True␤»
4242
=end code
@@ -93,7 +93,7 @@ L<action object|/language/grammars#Action_Objects> is recommended to be used in
9393
conjunction with the grammar.
9494
9595
96-
=head2 X<Protoregexes| sym; :sym<>; protoregex>
96+
=head2 X«Proto regexes| sym; :sym<>; proto regex»
9797
9898
If you have a lot of alternations, it may become difficult to produce
9999
readable code or subclass your grammar. In the Actions class below, the
@@ -117,7 +117,7 @@ operations we add:
117117
118118
# OUTPUT: «5␤»
119119
120-
To make things better, we can use protoregexes that look like C«:sym<...>»
120+
To make things better, we can use proto regexes that look like C«:sym<...>»
121121
adverbs on tokens:
122122
123123
grammar Calculator {
@@ -170,7 +170,7 @@ calculator:
170170
=end code
171171
172172
All we had to add are additional rule and action to the C<calc-op> group and
173-
the thing works—all thanks to protoregexes.
173+
the thing works—all thanks to proto regexes.
174174
175175
=head2 Special Tokens
176176
@@ -363,7 +363,8 @@ A slightly more involved example follows:
363363
}
364364
}
365365
366-
my $res = KeyValuePairs.parse(q:to/EOI/, :actions(KeyValuePairsActions)).made;
366+
my $actions = KeyValuePairsActions.new;
367+
my $res = KeyValuePairs.parse(q:to/EOI/, :$actions).made;
367368
second=b
368369
hits=42
369370
perl=6
@@ -376,11 +377,11 @@ A slightly more involved example follows:
376377
377378
This produces the following output:
378379
379-
=begin code :lang<text>
380-
Key: second Value: b
381-
Key: hits Value: 42
382-
Key: perl Value: 6
383-
=end code
380+
=begin code :lang<text>
381+
Key: second Value: b
382+
Key: hits Value: 42
383+
Key: perl Value: 6
384+
=end code
384385
385386
Rule C<pair>, which parsed a pair separated by an equals sign, aliases the two
386387
calls to token C<identifier> to separate capture names to make them available

doc/Language/objects.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ This check will save you a lot of headaches:
712712
=begin code :preamble<role Bull-Like{}; role Steerable{};>
713713
class Taurus does Bull-Like does Steerable {
714714
method steer($direction?) {
715-
self.Steerable::steer($direction?)
715+
self.Steerable::steer($direction)
716716
}
717717
}
718718
=end code

0 commit comments

Comments
 (0)