Skip to content

Commit

Permalink
Merge pull request #545 from vbatts/html_img
Browse files Browse the repository at this point in the history
docs: image base reference
  • Loading branch information
jonboulle authored Mar 9, 2017
2 parents a896cfc + fec31f4 commit 5d925ee
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 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
54 changes: 54 additions & 0 deletions .tool/genheader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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 (
"bytes"
"fmt"
"os"
"os/exec"
"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") {
cmd := exec.Command("git", "log", "-1", `--pretty=%H`, "HEAD")
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

obj.Branch = strings.Trim(out.String(), " \n\r")
}
headerTemplate.Execute(os.Stdout, obj)
}
15 changes: 9 additions & 6 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 --latex-engine=xelatex -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: schema/fs.go
go test -run TestValidate ./schema

Expand All @@ -98,7 +101,6 @@ test: schema/fs.go
img/%.png: img/%.dot
dot -Tpng $^ > $@

.PHONY: .gitvalidation

# When this is running in travis, it will only check the travis commit range
.gitvalidation:
Expand All @@ -109,8 +111,6 @@ else
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
endif

.PHONY: install.tools

install.tools: .install.gitvalidation .install.glide .install.glide-vc

.install.gitvalidation:
Expand All @@ -123,13 +123,16 @@ 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 \
check-license \
clean \
lint \
install.tools \
docs \
test \
.gitvalidation \
schema/fs.go \
schema-fs

0 comments on commit 5d925ee

Please sign in to comment.