@@ -11,15 +11,33 @@ endif
1111all : pdf html
1212
1313
14- SOURCES = chapter01.md \
15- chapter02.md \
16- chapter03.md \
17- chapter04.md \
18- chapter05.md \
19- chapter06.md \
20- chapter07.md \
21- chapter08.md
22- APPENDIX = appendix01.md
14+ ifeq ($(DOC_LANG ) ,JA)
15+ SOURCES = chapter01.md \
16+ chapter02.md \
17+ chapter03.md \
18+ chapter04.md \
19+ chapter05.md \
20+ chapter06.md \
21+ chapter07.md \
22+ chapter08.md
23+ APPENDIX = appendix01.md
24+ HOMEPAGE = chapter01.md
25+ LINK_STRIP = chapter[0-9][0-9].md|appendix[0-9][0-9].md
26+ else
27+ SOURCES = 1-Overview.md \
28+ 2-FAQs.md \
29+ 3-Quickstart.md \
30+ 4-Architecture.md \
31+ 5-Features.md \
32+ 6-Utilities.md \
33+ 7-Examples.md \
34+ 8-Integration.md \
35+ 9-Configuration.md
36+ APPENDIX = 10-API-docs-client.md \
37+ 11-API-docs-server.md
38+ HOMEPAGE = 0-Index.md
39+ LINK_STRIP = [0-9]+-[A-Za-z0-9-]+\.md
40+ endif
2341
2442ifeq ($(DOC_LANG ) ,JA)
2543 DOXY = Doxyfile-ja
@@ -64,14 +82,14 @@ html-setup: wolfhsm-update
6482 $(Q ) cp ../common/* .css build/html/
6583 $(Q ) perl -i -pe ' s/ ```/```/g' build/html/* .md
6684 $(Q ) perl -i -pe " s/\#--/\#-/g" build/html/* .md
67- $(Q ) mv build/html/$(word 1, $( SOURCES ) ) build/html/index.md
85+ $(Q ) mv build/html/$(HOMEPAGE ) build/html/index.md
6886
6987# Override pdf-setup to ensure wolfhsm repo is cloned first
7088.PHONY : pdf-setup
7189pdf-setup : wolfhsm-update builddir
7290 $(Q ) cp -a $(SRC ) /* build/pdf/
7391 $(Q ) cp ../common/* .png build/pdf/
74- $(Q ) perl -i -pe " s/chapter[0-9][0-9].md|appendix[0-9][0-9].md //g" build/pdf/* .md
92+ $(Q ) perl -i -pe " s/$( LINK_STRIP ) //g" build/pdf/* .md
7593 $(Q ) perl -i -pe " s/\#--/\#/g" build/pdf/* .md
7694
7795# Need an index.md, so let's make it chapter01.
@@ -85,10 +103,16 @@ html-prep: api
85103
86104 $(Q)perl -i -pe "s/\/group_/group_/g" build/html/group* build/html/*8h*
87105 $(Q)perl -i -pe "s/dox_comments\/header_files\///" build/html/*8h*
106+ $(Q)perl -i -pe "s/\[([^\]]+)\]\(Classes\/[^)]+\.md\)/\1/g" build/html/*8h*
88107
89108# Set input format to gfm to fix issues with converted API docs
90109# Regexes:
91- # 1. Indent all headings by one #
110+ # 1. Demote the auto-generated API h-file headings by one # (only wh__*_8h.md)
111+ # so they nest as subsections under their parent appendix chapter. Don't
112+ # demote chapter source files — pandoc -N needs their H1 → \section for
113+ # proper "1.", "2.", ... numbering (and "A.", "B.", ... after \appendix);
114+ # if everything is demoted to ##, every chapter renders as "0.N" and the
115+ # appendix as ".N".
92116# 2. Fix broken anchors from Doxybook2
93117# 3. Remove file references from links
94118# 4. Three regexes to remove metadata which outputs in the PDF text
@@ -98,7 +122,7 @@ html-prep: api
98122pdf-prep : api
99123 $(Q ) cp -a api/md/* 8h* build/pdf/
100124
101- $(Q)perl -i -pe "s/# /## /g" build/pdf/* .md
125+ $(Q)perl -i -pe "s/# /## /g" build/pdf/wh__*_8h .md
102126 $(Q)perl -i -pe "s/(\/group_.*|Classes\/struct.*|\/.*8h)\.md//g" build/pdf/*.md
103127 $(Q)perl -i -pe "s/^-(-)+$$//" build/pdf/*.md
104128 $(Q)perl -i -pe "s/^title:.*//" build/pdf/*.md
@@ -111,4 +135,11 @@ pdf-prep: api
111135 $(Q)perl -i -pe "s/(?<=md\# function\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" build/pdf/*.md
112136 $(Q)perl -i -pe "s/(?<=md\# typedef\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" build/pdf/*.md
113137 $(Q)perl -i -pe "s/(?<=md\# enum\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" build/pdf/*.md
114- $(Q)cat build/pdf/wh__client_8h.md build/pdf/wh__client__crypto_8h.md build/pdf/wh__server_8h.md >> build/pdf/appendix01.md
138+ $(Q)perl -i -pe "s/\[([^\]]+)\]\((?:\.\.\/)*wolfhsm\/wh_[a-z_]+\.h\)/\1/g" build/pdf/*.md
139+ $(Q)perl -i -pe "s/\[([^\]]+)\]\(wh__[a-z_0-9]+\.md\)/\1/g" build/pdf/*.md
140+ $(Q)if [ "$(DOC_LANG)" = "JA" ]; then \
141+ cat build/pdf/wh__client_8h.md build/pdf/wh__client__crypto_8h.md build/pdf/wh__client__she_8h.md build/pdf/wh__server_8h.md build/pdf/wh__server__keystore_8h.md build/pdf/wh__server__img__mgr_8h.md build/pdf/wh__server__cert_8h.md build/pdf/wh__server__cert__cache_8h.md >> build/pdf/appendix01.md; \
142+ else \
143+ cat build/pdf/wh__client_8h.md build/pdf/wh__client__crypto_8h.md build/pdf/wh__client__she_8h.md >> build/pdf/10-API-docs-client.md; \
144+ cat build/pdf/wh__server_8h.md build/pdf/wh__server__keystore_8h.md build/pdf/wh__server__img__mgr_8h.md build/pdf/wh__server__cert_8h.md build/pdf/wh__server__cert__cache_8h.md >> build/pdf/11-API-docs-server.md; \
145+ fi
0 commit comments