Repository navigation
Build the wolfTPM manual from the wolfSSL/wolfTPM source repository #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aidangarske
wants to merge
2
commits into
wolfSSL:master
Choose a base branch
from
aidangarske:wolftpm-docs-sync
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
−24,523
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /build/ | ||
| /html/ | ||
| /src/ | ||
| /wolftpm/ | ||
| /api/ | ||
| /mkdocs.yml | ||
| /header.txt | ||
| /manual.generated.mk | ||
| /wolfTPM-Manual.pdf | ||
| /wolfTPM-Manual-jp.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,100 +1,56 @@ | ||
| -include ../common/common.am | ||
| .DEFAULT_GOAL := all | ||
|
|
||
| all: pdf html | ||
|
|
||
|
|
||
| SOURCES = chapter01.md \ | ||
| chapter02.md \ | ||
| chapter03.md \ | ||
| chapter04.md \ | ||
| chapter05.md \ | ||
| chapter06.md | ||
| # The manual content and build adapter live in wolfSSL/wolfTPM. | ||
| WOLFTPM_SOURCE ?= wolftpm | ||
| WOLFTPM_REF ?= master | ||
| export WOLFTPM_REF | ||
|
|
||
| # The shared documentation build sets DOC_LANG=JA for the Japanese manual. | ||
| ifeq ($(DOC_LANG),JA) | ||
| DOXY = Doxyfile-ja | ||
| PDF = wolfTPM-Manual-jp.pdf | ||
| LANG_ARG = --lang ja | ||
| else | ||
| DOXY = Doxyfile | ||
| PDF = wolfTPM-Manual.pdf | ||
| LANG_ARG = --lang en | ||
| endif | ||
|
|
||
| .DEFAULT_GOAL := all | ||
| .PHONY: all pdf html source | ||
| all: source | ||
| python3 "$(WOLFTPM_SOURCE)/tools/docs_manual.py" build \ | ||
| --documentation-root .. --source-root "$(WOLFTPM_SOURCE)" $(LANG_ARG) --target all | ||
|
|
||
| source: | ||
| @set -eu; \ | ||
| if [ "$(WOLFTPM_SOURCE)" = wolftpm ]; then \ | ||
| if [ -e wolftpm ]; then \ | ||
| if [ ! -e wolftpm/.git ]; then \ | ||
| echo 'wolftpm exists but is not a Git checkout' >&2; exit 1; \ | ||
| fi; \ | ||
| remote=$$(git -C wolftpm config --get remote.origin.url) || { \ | ||
| echo 'wolftpm has no origin remote' >&2; exit 1; \ | ||
| }; \ | ||
| if [ "$$remote" != https://github.com/wolfSSL/wolfTPM.git ]; then \ | ||
| echo "wolftpm origin is $$remote; expected https://github.com/wolfSSL/wolfTPM.git" >&2; exit 1; \ | ||
| fi; \ | ||
| if [ -n "$$(git -C wolftpm status --porcelain)" ]; then \ | ||
| echo 'wolftpm checkout has local changes; use WOLFTPM_SOURCE for local edits' >&2; exit 1; \ | ||
| fi; \ | ||
| else \ | ||
| git init -q wolftpm; \ | ||
| git -C wolftpm remote add origin https://github.com/wolfSSL/wolfTPM.git; \ | ||
| fi; \ | ||
| ref=$$WOLFTPM_REF; \ | ||
| case "$$ref" in ''|-*) echo 'WOLFTPM_REF must be a commit, tag, or branch' >&2; exit 1;; esac; \ | ||
| if printf '%s' "$$ref" | grep -Eq '^[0-9a-f]{40}$$' && \ | ||
| git -C wolftpm cat-file -e "$$ref^{commit}" 2>/dev/null; then \ | ||
| git -C wolftpm checkout --detach "$$ref"; \ | ||
| else \ | ||
| git -C wolftpm fetch --depth 1 origin "$$ref"; \ | ||
| git -C wolftpm checkout --detach FETCH_HEAD; \ | ||
| fi; \ | ||
| echo "wolfTPM source: $$(git -C wolftpm rev-parse HEAD)"; \ | ||
| else \ | ||
| test -f "$(WOLFTPM_SOURCE)/tools/docs_manual.py"; \ | ||
| fi | ||
|
|
||
| pdf html: source | ||
| python3 "$(WOLFTPM_SOURCE)/tools/docs_manual.py" build \ | ||
| --documentation-root .. --source-root "$(WOLFTPM_SOURCE)" $(LANG_ARG) --target $@ | ||
|
|
||
| wolftpm: | ||
| $(Q)git clone --depth 1 https://github.com/wolfSSL/wolfTPM wolftpm | ||
|
|
||
|
|
||
| .PHONY: wolftpm-update | ||
| wolftpm-update: wolftpm | ||
| $(Q)cd wolftpm && git pull --ff-only | ||
|
|
||
| .PHONY: api | ||
| api: wolftpm-update | ||
| $(Q)mkdir -p api/md | ||
| $(Q)cd wolftpm && doxygen docs/Doxyfile | ||
| $(Q)cd .. | ||
| $(Q)doxybook2 --input wolftpm/docs/xml --output api/md --config doxybook.cfg | ||
|
|
||
| # Need an index.md, so let's make it chapter01. | ||
| # Perl regex to fix two things: | ||
| # 1. Doxybook2 replaces underscores with dashes in anchor tags (which breaks them) | ||
| # 2. Remove leading slash on links so that mkdocs can parse them | ||
| # 3. Fix the titles of the header files markdown | ||
| .PHONY: html-prep | ||
| html-prep: api | ||
| ifeq ($(DOC_LANG),JA) | ||
| $(Q)cp -a header-ja/group* build/html/ | ||
| $(Q)cp -a header-ja/*8h* build/html/ | ||
| else | ||
| $(Q)cp -a api/md/group* build/html/ | ||
| $(Q)cp -a api/md/*8h* build/html/ | ||
| $(Q)cp -a api/md/Classes build/html/ | ||
| $(Q)perl -i -pe 's#\]\(/Classes/#](#g' build/html/Classes/*.md | ||
| $(Q)perl -i -pe "s/Classes\///g" build/html/Classes/*.md | ||
| $(Q)perl -i -pe 's#\]\(/#](../#g' build/html/Classes/*.md | ||
| $(Q)perl -i -pe 's#\]\(/#](#g' build/html/group* build/html/*8h* | ||
| $(Q)perl -i -pe "s/(\]\([^)#]*#[a-z]+-)([^)]+?)(\))/\$$1.(\$$2=~tr#-#_#r).\$$3/ge" build/html/group* build/html/*8h* build/html/Classes/*.md | ||
| endif | ||
|
|
||
| $(Q)rm -rf build/html/chapter05.md | ||
| $(Q)perl -i -pe "s/\/group_/group_/g" build/html/group* build/html/*8h* | ||
| $(Q)perl -i -pe "s/\/tpm2_/tpm2_/g" build/html/group* build/html/*8h* | ||
| $(Q)perl -i -pe "s/dox_comments\/header_files\///" build/html/*8h* | ||
|
|
||
| # Set input format to gfm to fix issues with converted API docs | ||
| # Regexes: | ||
| # 1. Indent all headings by one # | ||
| # 2. Fix broken anchors from Doxybook2 | ||
| # 3. Remove file references from links | ||
| # 4. Three regexes to remove metadata which outputs in the PDF text | ||
| # 5. Fix titles of the header files Markdown | ||
| # 6. Two regexes to handle bad Doxygen that didn't convert and the LaTeX processor thinks is LaTeX commands | ||
| # 7. For oversized enum table rows (>2000 chars), keep table formatting intact | ||
| # by splitting enum values across continuation rows to avoid LaTeX | ||
| # "Dimension too large" errors in longtable | ||
| # NOTE: The final `cat` assembles the API Reference for the PDF from a hardcoded | ||
| # list. It mirrors the "5. API Reference" nav in mkdocs.yml (which drives the | ||
| # HTML build); the PDF build does not read that nav. Keep both lists in sync. | ||
| .PHONY: pdf-prep | ||
| pdf-prep: api | ||
| $(Q)perl -i -pe "s/# /## /g" api/md/*.md | ||
| $(Q)perl -i -pe "s/(\/group_.*|Classes\/struct.*|\/.*8h)\.md//g" api/md/*.md | ||
| $(Q)perl -i -pe "s/^-(-)+$$//" api/md/*.md | ||
| $(Q)perl -i -pe "s/^title:.*//" api/md/*.md | ||
| $(Q)perl -i -pe "s/^Updated on.*//" api/md/*.md | ||
| $(Q)perl -i -pe "s/^summary.*//" api/md/*.md | ||
| $(Q)perl -i -pe "s/dox_comments\/header_files\///" api/md/*.md | ||
| $(Q)perl -i -pe "s/^\\\\//" api/md/*.md | ||
| $(Q)perl -i -pe "s/\\\\par/par/g" api/md/*.md | ||
| $(Q)perl -i -pe "s/\[(.*?)\]\(Classes\/.*?.md\)/\[\1\]\(#typedef-\1\)/g" api/md/*.md | ||
| $(Q)perl -i -pe "s/(?<=md\#function\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" api/md/*.md | ||
| $(Q)perl -i -pe "s/(?<=md\#typedef\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" api/md/*.md | ||
| $(Q)perl -i -pe "s/(?<=md\#enum\-)(.*)(?=\))/\$$1=~s#-#_#gr/ge" api/md/*.md | ||
| $(Q)perl -i -pe 's!^\| enum\| (\*\*\[.*?\]\(.*?\)\*\*) \{(.*)\} \|\s*$$!do { my ($$name, $$vals) = ($$1, $$2); my @items = split(/, /, $$vals); my @chunks; my $$cur = ""; for my $$item (@items) { my $$cand = $$cur eq "" ? $$item : "$$cur, $$item"; if (length($$cand) > 220 && $$cur ne "") { push @chunks, $$cur; $$cur = $$item; } else { $$cur = $$cand; } } push @chunks, $$cur if $$cur ne ""; @chunks <= 1 ? "| enum| $$name { $$vals} |" : "| enum| $$name { $$chunks[0] |\n" . join("", map { "| | $$chunks[$$_]" . ($$_ == $$#chunks ? " }" : "") . " |\n" } 1..$$#chunks) }!ge if length > 2000' api/md/*.md | ||
| $(Q)rm -rf build/pdf/chapter05.md | ||
| $(Q)echo '# API Reference' >> build/pdf/chapter05.md | ||
| ifeq ($(DOC_LANG),JA) | ||
| $(Q)cat header-ja/group__TPM2__Proprietary.md header-ja/tpm2_8h.md header-ja/tpm2__wrap_8h.md header-ja/group__wolfTPM2__Wrappers.md >> build/pdf/chapter05.md | ||
| else | ||
| $(Q)cat api/md/group__TPM2__Proprietary.md api/md/tpm2_8h.md api/md/tpm2__wrap_8h.md api/md/tpm__io_8h.md api/md/group__wolfTPM2__Wrappers.md >> build/pdf/chapter05.md | ||
| endif | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.