Skip to content

Commit 558802d

Browse files
committed
Docs: Update pandoc for rendering documentation
The main reason for this is to fix the links in the output docs, which currently all 404. This upgrades pandoc to 3.1, which isn't the latest, due to a regression in the relative links between markdown files. I pulled out the "header.html" logic, injected the title directly, and configured the build to embed images into the output doc for better portability (and the ability to generate dev docs). Signed-off-by: Brandon Mitchell <[email protected]>
1 parent ab80ff1 commit 558802d

File tree

3 files changed

+40
-71
lines changed

3 files changed

+40
-71
lines changed

.tool/curver.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2025 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"fmt"
19+
20+
"github.com/opencontainers/image-spec/specs-go"
21+
)
22+
23+
// This package is intended to be executed using "go run .tool/curver.go".
24+
func main() {
25+
fmt.Println(specs.Version)
26+
}

.tool/genheader.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

Makefile

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ GOPATH:=$(shell go env GOPATH)
88
OUTPUT_DIRNAME ?= output
99
DOC_FILENAME ?= oci-image-spec
1010

11-
PANDOC_CONTAINER ?= ghcr.io/opencontainers/pandoc:2.9.2.1-8.fc33.x86_64@sha256:5d81ff930a043295a557be8b003ece2a33d14e91b28c50d368413b83372f8d28
11+
# pinned to a 3.1 release due to a regression, see https://github.com/jgm/pandoc/issues/10952 before upgrading
12+
PANDOC_CONTAINER ?= docker.io/pandoc/latex:3.1@sha256:1cf54d9214a9b52de2f58cf5895cc596a5960711a54d7938dc72f2b23473caf3
1213
ifeq "$(strip $(PANDOC))" ''
1314
ifneq "$(strip $(DOCKER))" ''
1415
PANDOC = $(DOCKER) run \
1516
--rm \
16-
-v $(shell pwd)/:/input/:ro \
17-
-v $(shell pwd)/$(OUTPUT_DIRNAME)/:/$(OUTPUT_DIRNAME)/ \
18-
-u $(shell id -u) \
19-
--workdir /input \
17+
-v "$(CURDIR)/:/workdir/:ro" \
18+
-v "$(CURDIR)/$(OUTPUT_DIRNAME)/:/workdir/$(OUTPUT_DIRNAME)/" \
19+
-u "$(shell id -u):$(shell id -g)" \
20+
--workdir /workdir \
2021
$(PANDOC_CONTAINER)
21-
PANDOC_SRC := /input/
22-
PANDOC_DST := /
2322
endif
2423
endif
2524

@@ -55,24 +54,22 @@ fmt: ## format the json with indentation
5554
docs: $(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html ## generate a PDF/HTML version of the OCI image specification
5655

5756
ifeq "$(strip $(PANDOC))" ''
58-
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
57+
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).%: $(DOC_FILES) $(FIGURE_FILES)
5958
$(error cannot build $@ without either pandoc or docker)
6059
else
6160
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
6261
@mkdir -p $(OUTPUT_DIRNAME)/ && \
63-
$(PANDOC) -f gfm -t latex --pdf-engine=xelatex -V geometry:margin=0.5in,bottom=0.8in -V block-headings -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
64-
ls -sh $(realpath $@)
62+
version="v$$(go run .tool/curver.go)" && \
63+
$(PANDOC) -f gfm -t latex -o $@ --metadata "title=image-spec $${version}" --standalone --file-scope --pdf-engine=xelatex -V geometry:margin=0.5in,bottom=0.8in -V block-headings $(DOC_FILES)
64+
ls -sh $@
6565

66-
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: header.html $(DOC_FILES) $(FIGURE_FILES)
66+
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: $(DOC_FILES) $(FIGURE_FILES)
6767
@mkdir -p $(OUTPUT_DIRNAME)/ && \
68-
cp -ap img/ $(shell pwd)/$(OUTPUT_DIRNAME)/&& \
69-
$(PANDOC) -f gfm -t html5 -H $(PANDOC_SRC)header.html --standalone -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
70-
ls -sh $(realpath $@)
68+
version="v$$(go run .tool/curver.go)" && \
69+
$(PANDOC) -f gfm -t html5 -o $@ --metadata "title=image-spec $${version}" --standalone --file-scope --embed-resources -V "maxwidth:95%" $(DOC_FILES)
70+
ls -sh $@
7171
endif
7272

73-
header.html: .tool/genheader.go specs-go/version.go
74-
go run .tool/genheader.go > $@
75-
7673
.PHONY: validate-examples
7774
validate-examples: schema/schema.go ## validate examples in the specification markdown files
7875
cd schema && go test -run TestValidate .

0 commit comments

Comments
 (0)