Repository navigation
Expand file tree
/
Copy pathJamfile
More file actions
198 lines (184 loc) · 8.41 KB
/
Copy pathJamfile
File metadata and controls
198 lines (184 loc) · 8.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)
#
# The site: its pages, rendered from OpenUI Lang into static HTML, and its
# own tests. b2 site, at the superproject, assembles them with every
# library's page into bin/site/ (its tools/site/site.jam, imported as site).
import modules ;
import path ;
import site ;
# This directory, absolute: an action starts in the directory b2 was started
# in, the superproject's root, never here.
.here = [ path.parent [ path.root [ path.make [ modules.binding $(__name__) ] ] [ path.pwd ] ] ] ;
# The superproject's root, this directory's parent, whose bin/site/ is what
# valid-html checks.
.root = [ path.parent $(.here) ] ;
# The superproject's b2 site writes bin/site/, which b2 would make this
# project's build directory (bin/<its directory>), so it builds in
# bin/site-work/. With --build-dir, b2 puts it under that directory, apart
# from bin/site/ already, and accepts no build-dir here.
if [ MATCH "^(--build-dir=)" : [ modules.peek : ARGV ] ]
{
project /webcpp/site ;
}
else
{
project /webcpp/site : build-dir ../bin/site-work ;
}
make node-modules.stamp : package.json package-lock.json : @webcpp-doc%install-packages-in
: <webcpp-boost-check>off ;
alias node-modules : node-modules.stamp : <webcpp-boost-check>off ;
always node-modules.stamp ;
# What the pages are rendered with: the channel, the superproject's commit and
# its date, the version and the catalogue (site.write-context).
make context.json : /webcpp//libraries.json : @site%write-context : <webcpp-boost-check>off ;
always context.json ;
# The pages, rendered by the npm script build into pages/ beside the stamp,
# with their cards, assets and the client bundle, and the two headers b2 site
# lays out: docs-header.html, of the libraries' light pages, and
# site-header.html, of a page of the site's own style it does not render (the
# report's). All are removed first, so that a page deleted from pages/ is gone
# from what b2 site reads.
make pages.stamp : context.json : @pages
: <dependency>node-modules <webcpp-boost-check>off ;
always pages.stamp ;
alias pages : pages.stamp : <webcpp-boost-check>off ;
rule pages ( targets * : sources * : properties * )
{
BUNDLE on $(targets) = [ site.npm build : --bundle ] ;
RENDER on $(targets) = [ site.npm build : --render --pages pages --out $out/pages
--context $context --chrome $out/docs-header.html
--site-chrome $out/site-header.html ] ;
}
actions pages
{
set -e
out=`dirname "$(<)"`
out=`cd "$out" && pwd`
context=`dirname "$(>)"`
context=`cd "$context" && pwd`/`basename "$(>)"`
rm -rf "$out/pages" "$out/docs-header.html" "$out/site-header.html"
$(BUNDLE)
$(RENDER)
echo rendered > "$(<)"
}
# The site's own tests: its npm test, which bundles first (package.json's
# pretest, so npm alone never reads a stale build/server.mjs) and runs every
# test/**/*_test.mjs, and its typecheck. b2 /webcpp/site//test.
notfile test : @test : : <dependency>node-modules <webcpp-boost-check>off ;
rule test ( targets * : sources * : properties * )
{
TEST on $(targets) = [ site.npm test ] ;
TYPECHECK on $(targets) = [ site.npm typecheck ] ;
}
actions test
{
set -e
$(TEST)
$(TYPECHECK)
}
# Every page of bin/site/, the superproject's, is valid HTML: html-validate, run
# twice, never
# writing a configuration into bin/site itself. The site's own pages (every
# *.html outside
# docs/ and libs/) take every rule of htmlvalidate.json's
# html-validate:recommended; docs/ and
# libs/*/, the libraries' Asciidoctor pages, take htmlvalidate.docs.json's, with
# no-trailing-
# whitespace off there alone, since a listing of pratt's guide shows literal
# trailing whitespace
# and tabs as the parser's own example output (libs/pratt/doc/pratt.adoc),
# inside a <pre> the rule
# has no option to tell from formatting; a page outside docs/ and libs/ with
# trailing whitespace
# still fails. A dependency of b2 site's last step (tools/site/site.jam), after
# site-pages has
# moved bin/site.tmp/ onto bin/site/, so a page that is not valid HTML fails the
# build, naming the
# file and this rule.
#
# Neither config's own JSON holds a comment, so each rule either one turns off
# is explained here:
#
# doctype-style (site's own pages) the shell writes `<!doctype
# html>`
# (src/server.tsx), HTML5's own spelling; recommended
# wants it
# uppercase, a style choice.
# void-style (both: the chrome header is on every page) React
# serialises a void
# element self-closed, `<img/>` (the logo); HTML5
# reads that as
# `<img>`, a style choice.
# no-inline-style (both, for two different values no static sheet can
# hold) the site's
# own pages: React's hydration-fade overlay (opacity,
# transition);
# docs/ and libs/: a table's column widths, which
# cols computes per
# table (postprocess.mjs).
# attribute-boolean-style (site's own pages) React writes a boolean attribute
# as `attr=""`
# (the search form's `required`); HTML5 reads that as
# the bare
# attribute, a style choice.
# attr-case (site's own pages) React keeps the DOM property's
# spelling for some
# attributes it writes verbatim, `autoComplete`,
# `spellCheck`
# (search_form.tsx); HTML attributes are read
# case-insensitively, a
# style choice.
# form-dup-name (site's own pages) the search form's two fields
# share name="q" on
# purpose (search_form.tsx): a hidden one restricts
# the search to the
# site, the reader's own holds the terms, and Google
# joins the two
# into one query.
# no-trailing-whitespace (docs/ and libs/ alone) pratt's own example output,
# above.
notfile valid-html : @valid-html
: : <dependency>node-modules <dependency>/webcpp//site-pages <webcpp-boost-check>off ;
rule valid-html ( targets * : sources * : properties * )
{
HTML_VALIDATE on $(targets) = [ path.native $(.here)/node_modules/.bin/html-validate ] ;
CONFIG on $(targets) = [ path.native $(.here)/htmlvalidate.json ] ;
DOCS_CONFIG on $(targets) = [ path.native $(.here)/htmlvalidate.docs.json ] ;
PAGES on $(targets) = [ path.native $(.root)/bin/site ] ;
}
# find -H, which follows bin/site, a link b2 site swaps onto each build
# (tools/swap.mjs), where a
# plain find would stop at the link and find no page, so that the check would
# pass on nothing;
# find, never a glob of b2's or the shell's, so a page's path that holds a space
# is one argument;
# -print0 piped to xargs -0, never -exec ... +, since find's own exit status
# says nothing of
# html-validate's: with -exec, a page that fails validation would still leave
# find, and so this
# action, exit 0. Each pass runs only once there is a page for it, so what finds
# none (every page
# in a scratch fixture under docs/, say) invokes html-validate with no file and
# no false "no page
# given" fault.
actions valid-html
{
set -e
site=`find -H "$(PAGES)" -name '*.html' ! \( -path "$(PAGES)/docs/*" -o -path "$(PAGES)/libs/*" \)`
if [ -n "$site" ]
then
find -H "$(PAGES)" -name '*.html' ! \( -path "$(PAGES)/docs/*" -o -path "$(PAGES)/libs/*" \) -print0 \
| xargs -0 "$(HTML_VALIDATE)" --config "$(CONFIG)"
fi
docs=`find -H "$(PAGES)" -name '*.html' \( -path "$(PAGES)/docs/*" -o -path "$(PAGES)/libs/*" \)`
if [ -n "$docs" ]
then
find -H "$(PAGES)" -name '*.html' \( -path "$(PAGES)/docs/*" -o -path "$(PAGES)/libs/*" \) -print0 \
| xargs -0 "$(HTML_VALIDATE)" --config "$(DOCS_CONFIG)"
fi
}
explicit node-modules.stamp node-modules context.json pages.stamp pages test valid-html ;