Skip to content

Commit b29a06c

Browse files
committed
Hacking markdown and Makefile cleanup
- Remove/replace stale references from hacking doc. - Add spacing for markdown. - Add code block language for syntax highlighting. - Remove leading "$ " from commands without output. - Move links to end. - Switch to automatically generated help in Makefile. Signed-off-by: Brandon Mitchell <[email protected]>
1 parent b5ec432 commit b29a06c

File tree

2 files changed

+58
-67
lines changed

2 files changed

+58
-67
lines changed

HACKING.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,96 +9,97 @@ This guide contains instructions for building artifacts contained in this reposi
99
This spec includes several Go packages, and a command line tool considered to be a reference implementation of the OCI image specification.
1010

1111
Prerequisites:
12+
1213
* Go - current release only, earlier releases are not supported
1314
* make
1415

1516
The following make targets are relevant for any work involving the Go packages.
1617

1718
### Linting
1819

19-
The included Go source code is being examined for any linting violations not included in the standard Go compiler. Linting is done using [gometalinter](https://github.com/alecthomas/gometalinter).
20+
The included Go source code is being examined for any linting violations not included in the standard Go compiler.
21+
Linting is done using [golangci-lint][golangci-lint].
2022

2123
Invocation:
22-
```
23-
$ make lint
24+
25+
```shell
26+
make lint
2427
```
2528

2629
### Tests
2730

2831
This target executes all Go based tests.
2932

3033
Invocation:
31-
```
32-
$ make test
33-
$ make validate-examples
34-
```
35-
36-
### Virtual schema http/FileSystem
37-
38-
The `schema` validator uses a virtual [http/FileSystem](https://golang.org/pkg/net/http/#FileSystem) to load the JSON schema files for validating OCI images and/or manifests.
39-
The virtual filesystem is generated using the `esc` tool and compiled into consumers of the `schema` package so the JSON schema files don't have to be distributed along with and consumer binaries.
4034

41-
Whenever changes are being done in any of the `schema/*.json` files, one must refresh the generated virtual filesystem.
42-
Otherwise schema changes will not be visible inside `schema` consumers.
43-
44-
Prerequisites:
45-
* [esc](https://github.com/mjibson/esc)
46-
47-
Invocation:
48-
```
49-
$ make schema-fs
35+
```shell
36+
make test
37+
make validate-examples
5038
```
5139

5240
### JSON schema formatting
5341

5442
This target auto-formats all JSON files in the `schema` directory using the `jq` tool.
5543

5644
Prerequisites:
57-
* [jq](https://stedolan.github.io/jq/) >=1.5
45+
46+
* [jq][jq] >=1.5
5847

5948
Invocation:
60-
```
61-
$ make fmt
49+
50+
```shell
51+
make fmt
6252
```
6353

6454
### OCI image specification PDF/HTML documentation files
6555

6656
This target generates a PDF/HTML version of the OCI image specification.
6757

6858
Prerequisites:
69-
* [Docker](https://www.docker.com/)
59+
60+
* [Docker][docker]
7061

7162
Invocation:
72-
```
73-
$ make docs
63+
64+
```shell
65+
make docs
7466
```
7567

7668
### License header check
7769

7870
This target checks if the source code includes necessary headers.
7971

8072
Invocation:
81-
```
82-
$ make check-license
73+
74+
```shell
75+
make check-license
8376
```
8477

8578
### Clean build artifacts
8679

8780
This target cleans all generated/compiled artifacts.
8881

8982
Invocation:
90-
```
91-
$ make clean
83+
84+
```shell
85+
make clean
9286
```
9387

9488
### Create PNG images from dot files
9589

9690
This target generates PNG image files from DOT source files in the `img` directory.
9791

9892
Prerequisites:
99-
* [graphviz](https://www.graphviz.org/)
93+
94+
* [graphviz][graphviz]
10095

10196
Invocation:
97+
98+
```shell
99+
make img/media-types.png
102100
```
103-
$ make img/media-types.png
104-
```
101+
102+
[docker]: https://www.docker.com/
103+
[golangci-lint]: https://github.com/golangci/golangci-lint
104+
[graphviz]: https://www.graphviz.org/
105+
[jq]: https://stedolan.github.io/jq/

Makefile

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,16 @@ DOC_FILES := \
4141
FIGURE_FILES := \
4242
img/media-types.png
4343

44-
TOOLS := esc gitvalidation
44+
TOOLS := gitvalidation
4545

4646
default: check-license lint test
4747

48-
help:
49-
@echo "Usage: make <target>"
50-
@echo
51-
@echo " * 'docs' - produce document in the $(OUTPUT_DIRNAME) directory"
52-
@echo " * 'fmt' - format the json with indentation"
53-
@echo " * 'validate-examples' - validate the examples in the specification markdown files"
54-
@echo " * 'check-license' - check license headers in source files"
55-
@echo " * 'lint' - Execute the source code linter"
56-
@echo " * 'test' - Execute the unit tests"
57-
@echo " * 'img/*.png' - Generate PNG from dot file"
58-
59-
fmt:
48+
.PHONY: fmt
49+
fmt: ## format the json with indentation
6050
for i in schema/*.json ; do jq --indent 2 -M . "$${i}" > xx && cat xx > "$${i}" && rm xx ; done
6151

62-
docs: $(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html
52+
.PHONY: docs
53+
docs: $(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html ## generate a PDF/HTML version of the OCI image specification
6354

6455
ifeq "$(strip $(PANDOC))" ''
6556
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
@@ -80,25 +71,29 @@ endif
8071
header.html: .tool/genheader.go specs-go/version.go
8172
go run .tool/genheader.go > $@
8273

83-
validate-examples: schema/schema.go
74+
.PHONY: validate-examples
75+
validate-examples: schema/schema.go ## validate examples in the specification markdown files
8476
go test -run TestValidate ./schema
8577

86-
check-license:
78+
.PHONY: check-license
79+
check-license: ## check license headers in source files
8780
@echo "checking license headers"
8881
@./.tool/check-license
8982

90-
lint: .install.lint
83+
.PHONY: lint
84+
lint: .install.lint ## lint check of Go files using golangci-lint
9185
@echo "checking lint"
9286
@GO111MODULE=on $(GOPATH)/bin/golangci-lint run
9387

94-
test: schema/fs.go
88+
.PHONY: test
89+
test: ## run the unit tests
9590
go test -race -cover $(shell go list ./... | grep -v /vendor/)
9691

97-
img/%.png: img/%.dot
92+
img/%.png: img/%.dot ## generate PNG from dot file
9893
dot -Tpng $^ > $@
9994

100-
10195
# When this is running in GitHub, it will only check the commit range
96+
.PHONY: .gitvalidation
10297
.gitvalidation:
10398
@which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false)
10499
ifdef GITHUB_SHA
@@ -107,29 +102,24 @@ else
107102
$(GOPATH)/bin/git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
108103
endif
109104

105+
.PHONY: .install.tools
110106
install.tools: $(TOOLS:%=.install.%)
111107

108+
.PHONY: .install.lint
112109
.install.lint:
113110
case "$$(go env GOVERSION)" in \
114111
go1.18.*) go install github.com/golangci/golangci-lint/cmd/[email protected];; \
115112
*) go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest;; \
116113
esac
117114

115+
.PHONY: .install.gitvalidation
118116
.install.gitvalidation:
119117
go install github.com/vbatts/git-validation@latest
120118

121-
clean:
119+
.PHONY: clean
120+
clean: ## clean all generated and compiled artifacts
122121
rm -rf *~ $(OUTPUT_DIRNAME) header.html
123122

124-
.PHONY: \
125-
$(TOOLS:%=.install.%) \
126-
validate-examples \
127-
check-license \
128-
clean \
129-
lint \
130-
install.tools \
131-
docs \
132-
test \
133-
.gitvalidation \
134-
schema/fs.go \
135-
schema-fs
123+
.PHONY: help
124+
help: # Display help
125+
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)