Skip to content

Commit 73ef76d

Browse files
committed
version: include version in produced docs
Fixes #398 Signed-off-by: Vincent Batts <[email protected]>
1 parent dc8aeb1 commit 73ef76d

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
output
22
schema/validate
3+
version.md

.tool/version-doc.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// +build ignore
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
"html/template"
8+
"os"
9+
10+
"github.com/opencontainers/runtime-spec/specs-go"
11+
)
12+
13+
var markdownTemplateString = `
14+
15+
**Specification Version:** *{{.}}*
16+
17+
`
18+
19+
var markdownTemplate = template.Must(template.New("markdown").Parse(markdownTemplateString))
20+
21+
func main() {
22+
if err := markdownTemplate.Execute(os.Stdout, specs.Version); err != nil {
23+
fmt.Fprintln(os.Stderr, err)
24+
}
25+
}

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
DOCKER ?= $(shell which docker)
33
# These docs are in an order that determines how they show up in the PDF/HTML docs.
44
DOC_FILES := \
5+
version.md \
56
README.md \
67
code-of-conduct.md \
78
principles.md \
@@ -20,7 +21,7 @@ EPOCH_TEST_COMMIT := 041eb73d2e0391463894c04c8ac938036143eba3
2021
docs: pdf html
2122
.PHONY: docs
2223

23-
pdf:
24+
pdf: $(DOC_FILES)
2425
@mkdir -p output/ && \
2526
$(DOCKER) run \
2627
-it \
@@ -31,7 +32,7 @@ pdf:
3132
vbatts/pandoc -f markdown_github -t latex -o /output/docs.pdf $(patsubst %,/input/%,$(DOC_FILES)) && \
3233
ls -sh $(shell readlink -f output/docs.pdf)
3334

34-
html:
35+
html: $(DOC_FILES)
3536
@mkdir -p output/ && \
3637
$(DOCKER) run \
3738
-it \
@@ -43,6 +44,9 @@ html:
4344
ls -sh $(shell readlink -f output/docs.html)
4445

4546

47+
version.md: ./specs-go/version.go
48+
go run ./.tool/version-doc.go > $@
49+
4650
HOST_GOLANG_VERSION = $(shell go version | cut -d ' ' -f3 | cut -c 3-)
4751
# this variable is used like a function. First arg is the minimum version, Second arg is the version to be checked.
4852
ALLOWED_GO_VERSION = $(shell test '$(shell /bin/echo -e "$(1)\n$(2)" | sort -V | head -n1)' == '$(1)' && echo 'true')

0 commit comments

Comments
 (0)