Skip to content

Commit

Permalink
docs: image base reference
Browse files Browse the repository at this point in the history
Fixes #247

this makes an ephemeral header that gets included into the html doc that
bases the images path to pull from the same tag on github.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
  • Loading branch information
vbatts committed Feb 1, 2017
1 parent 0beb6ff commit cec7700
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/oci-validate-examples
output
header.html
42 changes: 42 additions & 0 deletions .tool/genheader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2017 The Linux Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"os"
"strings"
"text/template"

specs "github.com/opencontainers/image-spec/specs-go"
)

var headerTemplate = template.Must(template.New("gen").Parse(`<title>image-spec {{.Version}}</title>
<base href="https://raw.githubusercontent.com/opencontainers/image-spec/{{.Branch}}/">`))

type Obj struct {
Version string
Branch string
}

func main() {
obj := Obj{
Version: specs.Version,
Branch: specs.Version,
}
if strings.HasSuffix(specs.Version, "-dev") {
obj.Branch = "master"
}
headerTemplate.Execute(os.Stdout, obj)
}
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ $(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
$(PANDOC) -f markdown_github -t latex -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
ls -sh $(shell readlink -f $@)

$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: $(DOC_FILES) $(FIGURE_FILES)
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: header.html $(DOC_FILES) $(FIGURE_FILES)
@mkdir -p $(OUTPUT_DIRNAME)/ && \
cp -ap img/ $(shell pwd)/$(OUTPUT_DIRNAME)/&& \
$(PANDOC) -f markdown_github -t html5 -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
$(PANDOC) -f markdown_github -t html5 -H $(PANDOC_SRC)/header.html --standalone -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
ls -sh $(shell readlink -f $@)
endif

header.html: .tool/genheader.go specs-go/version.go
go run .tool/genheader.go > $@

validate-examples:
go test -run TestValidate ./schema

Expand Down Expand Up @@ -121,7 +124,7 @@ install.tools: .install.gitvalidation .install.glide .install.glide-vc
go get -u github.com/sgotti/glide-vc

clean:
rm -rf *~ $(OUTPUT_DIRNAME)
rm -rf *~ $(OUTPUT_DIRNAME) header.html

.PHONY: \
validate-examples \
Expand Down

0 comments on commit cec7700

Please sign in to comment.