forked from PeterFeicht/cppreference-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
252 lines (208 loc) · 8.67 KB
/
Makefile
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Copyright (C) 2011-2014 Povilas Kanapickas <[email protected]>
#
# This file is part of cppreference-doc
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
SHELL := /bin/bash
#Common prefixes
prefix = /usr
datarootdir = $(prefix)/share
docdir = $(datarootdir)/cppreference/doc
bookdir = $(datarootdir)/devhelp/books
qhelpgenerator = qhelpgenerator
#Version
VERSION=20220201
#STANDARD RULES
all: doc_html doc_devhelp doc_qch doc_doxygen
DISTFILES= \
commands/ \
gadgets/ \
headers/ \
images/ \
index_transform/ \
reference/ \
skins/ \
tests/ \
build_link_map.py \
ddg_parse_html.py \
devhelp2qch.py \
export.py \
fix_devhelp-links.py \
index2autolinker.py \
index2browser.py \
index2ddg.py \
index2devhelp.py \
index2doxygen-tag.py \
index2highlight.py \
index2search.py \
index-chapters-c.xml \
index-chapters-cpp.xml \
index-cpp-search-app.txt \
index-functions.README \
index-functions-c.xml \
index-functions-cpp.xml \
link_map.py \
preprocess.py \
preprocess-css.css \
preprocess_qch.py \
test.sh \
xml_utils.py \
Makefile \
README.md
CLEANFILES= \
output
TAR_FORMAT := gz
TAR_OPTION := z
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
TAR_FORMAT := xz
TAR_OPTION := J
endif
clean:
rm -rf $(CLEANFILES)
check:
dist: clean
mkdir -p "cppreference-doc-$(VERSION)"
cp -r $(DISTFILES) "cppreference-doc-$(VERSION)"
tar c$(TAR_OPTION)f "cppreference-doc-$(VERSION).tar.$(TAR_FORMAT)" "cppreference-doc-$(VERSION)"
rm -rf "cppreference-doc-$(VERSION)"
install: all
# install the HTML book
pushd "output/reference" > /dev/null; \
find . -type f \
-exec install -DT -m 644 '{}' "$(DESTDIR)$(docdir)/html/{}" \; ; \
popd > /dev/null
# install the devhelp documentation
install -DT -m 644 "output/cppreference-doc-en-c.devhelp2" \
"$(DESTDIR)$(bookdir)/cppreference-doc-en-c/cppreference-doc-en-c.devhelp2"
install -DT -m 644 "output/cppreference-doc-en-cpp.devhelp2" \
"$(DESTDIR)$(bookdir)/cppreference-doc-en-cpp/cppreference-doc-en-cpp.devhelp2"
install -DT -m 644 "output/cppreference-doxygen-local.tag.xml" \
"$(DESTDIR)$(bookdir)/cppreference-doxygen-local.tag.xml"
install -DT -m 644 "output/cppreference-doxygen-web.tag.xml" \
"$(DESTDIR)$(bookdir)/cppreference-doxygen-web.tag.xml"
# install the .qch (Qt Help) documentation
install -DT -m 644 "output/cppreference-doc-en-cpp.qch" \
"$(DESTDIR)$(docdir)/qch/cppreference-doc-en-cpp.qch"
uninstall:
rm -rf "$(DESTDIR)$(docdir)"
rm -rf "$(DESTDIR)$(bookdir)"
release: all
rm -rf release
mkdir -p release
# zip the distributable
mkdir -p "cppreference-doc-$(VERSION)"
cp -r $(DISTFILES) "cppreference-doc-$(VERSION)"
tar c$(TAR_OPTION)f "release/cppreference-doc-$(VERSION).tar.$(TAR_FORMAT)" "cppreference-doc-$(VERSION)"
zip -qr "release/cppreference-doc-$(VERSION).zip" "cppreference-doc-$(VERSION)"
rm -rf "cppreference-doc-$(VERSION)"
# zip the html output
pushd "output"; \
tar c$(TAR_OPTION)f "../release/html-book-$(VERSION).tar.$(TAR_FORMAT)" "reference" \
"cppreference-doxygen-local.tag.xml" "cppreference-doxygen-web.tag.xml" ; \
zip -qr "../release/html-book-$(VERSION).zip" "reference" \
"cppreference-doxygen-local.tag.xml" "cppreference-doxygen-web.tag.xml" ; \
popd
# zip qch
pushd "output"; \
tar c$(TAR_OPTION)f "../release/qch-book-$(VERSION).tar.$(TAR_FORMAT)" "cppreference-doc-en-cpp.qch"; \
zip -qr "../release/qch-book-$(VERSION).zip" "cppreference-doc-en-cpp.qch"; \
popd
#WORKER RULES
doc_html: output/reference
doc_devhelp: output/cppreference-doc-en-c.devhelp2 output/cppreference-doc-en-cpp.devhelp2
doc_qch: output/cppreference-doc-en-cpp.qch
doc_doxygen: output/cppreference-doxygen-web.tag.xml output/cppreference-doxygen-local.tag.xml
#builds the title<->location map
output/link-map.xml: output/reference
./build_link_map.py
#build the .devhelp2 index
output/cppreference-doc-en-c.devhelp2: output/reference output/link-map.xml
./index2devhelp.py $(docdir)/html index-chapters-c.xml \
"C Standard Library reference" "cppreference-doc-en-c" "c" \
index-functions-c.xml "output/devhelp-index-c.xml"
./fix_devhelp-links.py "output/devhelp-index-c.xml" \
"output/cppreference-doc-en-c.devhelp2"
output/cppreference-doc-en-cpp.devhelp2: output/reference output/link-map.xml
./index2devhelp.py $(docdir)/html index-chapters-cpp.xml \
"C++ Standard Library reference" "cppreference-doc-en-cpp" "cpp" \
index-functions-cpp.xml "output/devhelp-index-cpp.xml"
./fix_devhelp-links.py "output/devhelp-index-cpp.xml" \
"output/cppreference-doc-en-cpp.devhelp2"
#build the .qch (QT help) file
output/cppreference-doc-en-cpp.qch: output/qch-help-project-cpp.xml
#qhelpgenerator only works if the project file is in the same directory as the documentation
cp "output/qch-help-project-cpp.xml" "output/reference_cssless/qch.qhp"
pushd "output/reference_cssless" > /dev/null; \
$(qhelpgenerator) "qch.qhp" -o "../cppreference-doc-en-cpp.qch"; \
popd > /dev/null
rm -f "output/reference_cssless/qch.qhp"
output/qch-help-project-cpp.xml: output/cppreference-doc-en-cpp.devhelp2 output/reference_cssless
#build the file list
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files>" > "output/qch-files.xml"
pushd "output/reference_cssless" > /dev/null; \
find . -type f -not -iname "*.ttf" \
-exec echo "<file>"'{}'"</file>" \; | LC_ALL=C sort >> "../qch-files.xml" ; \
popd > /dev/null
echo "</files>" >> "output/qch-files.xml"
#create the project (copies the file list)
./devhelp2qch.py --src=output/cppreference-doc-en-cpp.devhelp2 \
--dst=output/qch-help-project-cpp.xml \
--virtual_folder=cpp --file_list=output/qch-files.xml
# build doxygen tag file
output/cppreference-doxygen-local.tag.xml: output/reference output/link-map.xml
./index2doxygen-tag.py "output/link-map.xml" \
"index-functions-cpp.xml" \
"index-chapters-cpp.xml" \
"output/cppreference-doxygen-local.tag.xml"
output/cppreference-doxygen-web.tag.xml: output/reference output/link-map.xml
./index2doxygen-tag.py web \
"index-functions-cpp.xml" \
"index-chapters-cpp.xml" \
"output/cppreference-doxygen-web.tag.xml"
#create preprocessed archive
output/reference:
mkdir -p output
./preprocess.py --src reference --dst output/reference
output/reference_cssless: output/reference
./preprocess_qch.py --src output/reference --dst output/reference_cssless
# create indexes for the wiki
indexes:
mkdir -p output/indexes
./index2highlight.py index-functions-cpp.xml output/indexes/highlight-cpp
./index2highlight.py index-functions-c.xml output/indexes/highlight-c
./index2search.py index-functions-cpp.xml output/indexes/search-cpp
./index2search.py index-functions-c.xml output/indexes/search-c
cat index-cpp-search-app.txt >> output/indexes/search-cpp
./index2autolinker.py index-functions-c.xml output/indexes/autolink-c
./index2autolinker.py index-functions-cpp.xml output/indexes/autolink-cpp
#redownloads the source documentation directly from zh.cppreference.com
source:
rm -rf "reference"
mkdir "reference"
pushd "reference" > /dev/null; \
regex=".*index\\.php.*|.*/Special:.*|.*/Talk:.*" \
regex+="|.*/Help:.*|.*/File:.*|.*/Cppreference:.*" \
regex+="|.*/WhatLinksHere:.*|.*/Template:.*|.*/Category:.*" \
regex+="|.*action=.*|.*printable=.*|.*zh.cppreference.com/book.*" ; \
echo $$regex ; \
wget --adjust-extension --page-requisites --convert-links \
--force-directories --recursive --level=15 \
--span-hosts --domains=zh.cppreference.com,upload.cppreference.com \
--reject-regex $$regex -e robots=off\
--timeout=5 --tries=50 --no-verbose \
--retry-connrefused --waitretry=10 --read-timeout=20 \
https://zh.cppreference.com/w/ ; \
popd > /dev/null
./export.py --url=https://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10