Skip to content

Commit 8ec9301

Browse files
committed
Cleanup of build process
Cleaning up build, moving everything into /Makefile. Every (versioned) bikeshed document should now have STATUS, DATA, VERSION macros set and updated before publishing. Old cruft is moved to /old for reference, to be cleanup up later.
1 parent 78d7ab5 commit 8ec9301

16 files changed

+101
-13
lines changed

spec/LICENSE.md LICENSE.md

File renamed without changes.

Makefile

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Build all documents and diagrams from spec/ into the build/
2+
# output folder. Please read RELEASE.md for more details on
3+
# publishing the documents.
4+
#
5+
# Assumes python3 is installed
6+
# Assumes npm is installed
7+
#
8+
# Examples of usage:
9+
# make all
10+
# make a clean build
11+
# make build
12+
# build the documents and diagrams
13+
# make clean
14+
# clean the build directory
15+
# make install
16+
# Will install bikeshed and mermaid-cli globally
17+
18+
# spec/**.mmd -> build/**.svg
19+
DIAGRAMS := $(wildcard spec/v2/diagrams/*.mmd)
20+
DIAGRAMS := $(DIAGRAMS:spec/%.mmd=build/%.svg)
21+
SOURCES := $(wildcard **.bs)
22+
23+
# Build rule for bikeshed documents
24+
build/%.html: spec/%.bs
25+
@echo Check release status and version
26+
$(eval status := $(shell sed -n 's/^Text Macro: STATUS //p' $<))
27+
$(eval version := $(shell sed -n 's/^Text Macro: VERSION //p' $<))
28+
$(eval date := $(shell sed -n 's/^Text Macro: DATE //p' $<))
29+
30+
@echo Build the document
31+
mkdir -p $(dir $@)
32+
bikeshed --allow-nonlocal-files spec $< $@
33+
34+
@echo Set the status in the document
35+
@if [[ "$(status)" == "Release" ]]; then \
36+
echo "Release: add version to title"; \
37+
mv -f $@ [email protected]; \
38+
sed 's/<title>\(.*\)<\/title>/<title>\1 (Version $(version))<\/title>/g' [email protected] > $@; \
39+
mv -f $@ [email protected]; \
40+
sed 's/\(<h1 .*id="title">.*\)\(<\/h1>\)/\1 (Version $(version))\2/g' [email protected] > $@; \
41+
elif [[ "$(status)" == "Draft" || "$(status)" == "Consultation" ]]; then \
42+
echo "No release: add version-date to title"; \
43+
mv -f $@ [email protected]; \
44+
sed 's/<title>\(.*\)<\/title>/<title>\1 (Version $(version)-$(date))<\/title>/g' [email protected] > $@; \
45+
mv -f $@ [email protected]; \
46+
sed 's/\(<h1 .*id="title">.*\)\(<\/h1>\)/\1 (Version $(version)-$(date))\2/g' [email protected] > $@; \
47+
else \
48+
echo "No status can be found"; \
49+
fi
50+
mv -f $@ [email protected]; \
51+
sed 's/\(<h2 .*id="profile-and-date">\).*\(<\/h2>\)/\1$(status)\2/g' [email protected] > $@; \
52+
53+
54+
55+
# Build rule for mermaid diagrams
56+
build/%.svg: spec/%.mmd
57+
mkdir -p $(dir $@)
58+
mmdc -i $< -o $@ --theme default
59+
60+
all: clean build
61+
62+
install:
63+
@echo Install Bikeshed
64+
pip3 install bikeshed && bikeshed update
65+
@echo Install Mermaid
66+
npm list -g @mermaid-js/mermaid-cli || npm install -g @mermaid-js/mermaid-cli
67+
68+
clean:
69+
rm -rf build
70+
71+
build: \
72+
build/index.html \
73+
build/v2/index.html \
74+
build/faq/index.html \
75+
$(DIAGRAMS)

spec/RELEASE.md RELEASE.md

File renamed without changes.

spec/Makefile old/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OUTDIR := upload
1+
OUTDIR := ../upload
22
MMDC := ./node_modules/.bin/mmdc
33

44
all: index.html
@@ -11,7 +11,7 @@ publish: index.html
1111
cp $< $(OUTDIR)
1212

1313
index.html: index.bs $(DIAGRAMS)
14-
bikeshed spec $< $@
14+
bikeshed --allow-nonlocal-files spec $< $@
1515

1616
serve:
1717
bikeshed serve index.bs

spec/faq/Makefile old/faq/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OUTDIR := ../upload/faq
1+
OUTDIR := ../../upload/faq
22

33
all: index.html
44

File renamed without changes.

spec/release.sh old/release.sh

File renamed without changes.
File renamed without changes.

spec/v2/Makefile old/v2/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish: index.html computed-metadata.include
1616
cp $^ $(OUTDIR)
1717

1818
index.html: index.bs $(DIAGRAMS)
19-
bikeshed spec $< $@ --md-text-macro="$(STATUS)"
19+
bikeshed --allow-nonlocal-files spec $< $@ --md-text-macro="$(STATUS)"
2020

2121
%.svg: %.mmd
2222
mmdc -i $< -o $@
File renamed without changes.
File renamed without changes.
File renamed without changes.

spec/.gitignore

-1
This file was deleted.

spec/faq/index.bs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Abstract: This document provides Frequently Asked Questions for PACT Technical S
1111
Repository: wbcsd/data-exchange-protocol
1212
Markup Shorthands: markdown yes, idl yes, dfn yes
1313
Boilerplate: omit copyright, omit conformance
14-
1514
</pre>
1615

1716
# Frequently Asked Questions # {#faqs}

spec/index.bs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<pre class='metadata'>
2-
Title: Technical Specifications for PCF Data Exchange
2+
Text Macro: DATE 20230201
33
Text Macro: VERSION 1.0.1
4-
Shortname: data-exchange-protocol
4+
Text Macro: STATUS Release
5+
Title: Technical Specifications for PCF Data Exchange
56
Level: 1
67
Status: LD
8+
Shortname: data-exchange-protocol
79
TR: https://wbcsd.github.io/tr/2023/data-exchange-protocol-20230201/
810
Mailing List: [email protected]
911
Editor:
@@ -1384,5 +1386,5 @@ highlight: json
13841386
# Appendix A: License # {#license}
13851387

13861388
<pre class=include>
1387-
path: LICENSE.md
1389+
path: ../LICENSE.md
13881390
</pre>

spec/v2/index.bs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
<!--
2+
Before publishing, make sure to:
3+
- Add an entry to Changelog
4+
- Update the DATE below
5+
- STATUS can be Draft|Consultation|Release
6+
In addition, for publishing a release:
7+
Set STATUS Release
8+
Update VERSION major.minor.patch
9+
Update the Previous Version and TR links
10+
-->
111
<pre class='metadata'>
2-
Title: Technical Specifications for PCF Data Exchange
12+
Text Macro: DATE 20241024
313
Text Macro: VERSION 2.3.0
4-
Shortname: data-exchange-protocol
14+
Text Macro: STATUS Draft
15+
Title: Technical Specifications for PCF Data Exchange
16+
TR: https://wbcsd.github.io/tr/2024/data-exchange-protocol-20241024/
17+
Previous Version: https://wbcsd.github.io/tr/2024/data-exchange-protocol-20240410/
518
Level: 1
619
Status: LD
20+
Shortname: data-exchange-protocol
721
Mailing List: [email protected]
822
Editor: Gertjan Schuurmans (WBCSD), https://www.wbcsd.org, [email protected]
923
Former Editor: Beth Hadley (WBCSD), https://www.wbcsd.org, [email protected]
@@ -14,7 +28,6 @@ Abstract: This document specifies a data model for GHG emission data at product
1428
Markup Shorthands: markdown yes, idl yes, dfn yes
1529
Boilerplate: omit copyright, omit conformance
1630
Local Boilerplate: header yes
17-
Local Boilerplate: computed-metadata yes
1831
Metadata Include: This version off
1932
</pre>
2033

@@ -2792,7 +2805,7 @@ highlight: json
27922805
# Appendix A: License # {#license}
27932806

27942807
<pre class=include>
2795-
path: LICENSE.md
2808+
path: ../../LICENSE.md
27962809
</pre>
27972810

27982811
# Appendix B: Changelog # {#changelog}

0 commit comments

Comments
 (0)