Skip to content

Commit

Permalink
Cover all standards except HTML and Streams
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Apr 1, 2020
1 parent 9c26906 commit c4d8d7f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/deploy_key
/deploy_key.pub
/@@bs@@.html
/review.sh
/review.sh@@.gitignore@@
5 changes: 4 additions & 1 deletion Makefile.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
SHELL=/bin/bash -o pipefail
.PHONY: local remote deploy review

remote: @@bs@@.bs
curl https://api.csswg.org/bikeshed/ -f -F file=@@@bs@@.bs > @@bs@@.html -F md-Text-Macro="SNAPSHOT-LINK LOCAL COPY"

local: @@bs@@.bs
bikeshed spec @@bs@@.bs @@bs@@.html --md-Text-Macro="SNAPSHOT-LINK LOCAL COPY"

deploy: @@bs@@.bs
curl --remote-name --fail https://resources.whatwg.org/build/deploy.sh
curl --remote-name --fail https://resources.whatwg.org/build/deploy.sh@@extra_files@@@@post_build_step@@
bash ./deploy.sh

review: @@bs@@.bs
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This repository enables repositories of WHATWG standards to be organized centrally to a certain extent. This is useful for the support files (the files with the `.template` extension), which are often nearly identical and prone to errors.

`factory.py` takes care of updating existing WHATWG standard repositories. It assumes they are in parallel directories using their "shortname" as directory name. `factory.json` supplies data for a exceptional cases.

The HTML and Streams Standards are currently not handled.
14 changes: 14 additions & 0 deletions factory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compat": {
"extra_files": "*.png"
},
"console": {
"extra_files": "images/*.*",
".gitignore": ["/.idea", "/node_modules/", "/npm-debug.log"]
},
"encoding": {
"extra_files": "*.txt *.json *.css",
"post_build_step": "python visualize.py \"$$DIR/\"",
".gitignore": ["/UnicodeData.txt"]
}
}
29 changes: 23 additions & 6 deletions factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ def fill_templates(templates, variables):
return output

def fill_template(contents, variables):
for variable in variables:
contents = contents.replace("@@{}@@".format(variable), variables[variable])
for variable, data in variables.items():
if variable == "extra_files" and data != "":
data = "\n\tEXTRA_FILES=\"{}\" \\".format(data)
elif variable == "post_build_step" and data != "":
data = "\n\tPOST_BUILD_STEP='{}' \\".format(data)
elif variable == ".gitignore":
output = ""
for entry in data:
output += "\n{}".format(entry)
data = output
contents = contents.replace("@@{}@@".format(variable), data)
return contents


Expand All @@ -57,19 +66,27 @@ def update(templates, variables):
for file in files:
write_file(file, files[file])
subprocess.run(["git", "add", file])
subprocess.run(["git", "commit", "-m", "Meta: update repository files"])
subprocess.run(["git", "commit", "-m", "Meta: update repository files\n\nSee https://github.com/whatwg/spec-factory for details."])

os.chdir(".")


def main():
templates = gather_templates()

db = json.loads(requests.get("https://github.com/whatwg/sg/raw/annevk/db/db.json").text)
local_db = json.loads(read_file("factory.json"))
for workstream in db["workstreams"]:
for standard in workstream["standards"]:
shortname = href_to_shortname(standard["href"])
h1 = standard["name"]
update(templates, { "shortname": shortname, "h1": h1 })
variables = {
"shortname": shortname,
"h1": standard["name"],
"extra_files": "",
"post_build_step": "",
".gitignore": []
}
if shortname in local_db:
variables.update(local_db[shortname])
update(templates, variables)

main()

0 comments on commit c4d8d7f

Please sign in to comment.