Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

programatically grab version for docs and live mode #116

Merged
merged 1 commit into from Apr 12, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -8,8 +8,5 @@ Teletype is a dynamic, musical event triggering platform.
— [PDF scene recall sheet](https://monome.org/docs/modular/teletype/TT_scene_RECALL_sheet.pdf)
— [Default scenes](http://monome.org/docs/modular/teletype/scenes-1.0/)

* Current version: 2.1.0
* Current version: _VERSION_
— [Firmware update procedure](https://monome.org/docs/modular/update/)



@@ -79,4 +79,4 @@ include $(MAKEFILE_PATH)

# Add the git commit id to a file for use when printing out the version
../module/gitversion.c: ../.git/HEAD ../.git/index
echo "const char *git_version = \"$(shell git describe --always --dirty | tr '[a-z]' '[A-Z]')\";" > $@
echo "const char *git_version = \"$(shell cut -d '-' -f 1 <<< $(shell git describe --tags | cut -c 2-)) $(shell git describe --always --dirty | tr '[a-z]' '[A-Z]')\";" > $@
@@ -213,7 +213,7 @@ uint8_t screen_refresh_live() {
output.has_value = false;
}
else if (show_welcome_message) {
strcpy(s, "TELETYPE: ");
strcpy(s, "TELETYPE ");
strncat(s, git_version, 35 - strlen(s));
show_welcome_message = false;
}
@@ -8,7 +8,7 @@
import pypandoc
import pytoml as toml

from common import validate_toml
from common import validate_toml, get_tt_version

if (sys.version_info.major, sys.version_info.minor) < (3, 6):
raise Exception("need Python 3.6 or later")
@@ -19,6 +19,9 @@
DOCS_DIR = ROOT_DIR / "docs"
OP_DOCS_DIR = DOCS_DIR / "ops"
FONTS_DIR = ROOT_DIR / "utils" / "fonts"
_VERSION_ = get_tt_version()
_VERSION_STR_ = "Teletype " + \
_VERSION_["tag"] + " " + _VERSION_["hash"] + " Cheatsheet"


# We want to run inject_latex in parallel as it's quite slow, and we must run
@@ -78,7 +81,7 @@ def cheatsheet_tex():
print(f"Using ops docs directory: {OP_DOCS_DIR}")
print()

output = ""
output = _VERSION_STR_ + "\n\n"
for (section, title, new_page) in OPS_SECTIONS:
toml_file = Path(OP_DOCS_DIR, section + ".toml")
if toml_file.exists() and toml_file.is_file():
@@ -1,5 +1,6 @@
from os import path
import re
import subprocess

_THIS_FILE = path.realpath(__file__)
_THIS_DIR = path.dirname(_THIS_FILE)
@@ -105,3 +106,12 @@ def validate_toml(ops):
for k in keys - {"prototype", "prototype_set", "aliases",
"short", "description"}:
print(f" - WARNING: {name} - unknown entry - {k}")


def get_tt_version():
tag = subprocess.check_output(["git", "describe", "--tags"]) \
.decode("utf-8").split("-")[0]
hash = subprocess.check_output(["git", "describe",
"--always", "--dirty"]) \
.decode("utf-8")[:-1].upper()
return {'tag': tag, 'hash': hash}
@@ -6,8 +6,9 @@
import jinja2
import pypandoc
import pytoml as toml
import subprocess

from common import list_ops, list_mods, validate_toml
from common import list_ops, list_mods, validate_toml, get_tt_version

if (sys.version_info.major, sys.version_info.minor) < (3, 6):
raise Exception("need Python 3.6 or later")
@@ -18,6 +19,8 @@
DOCS_DIR = ROOT_DIR / "docs"
OP_DOCS_DIR = DOCS_DIR / "ops"
FONTS_DIR = ROOT_DIR / "utils" / "fonts"
_VERSION_ = get_tt_version()
_VERSION_STR_ = "Teletype " + _VERSION_["tag"] + " " + _VERSION_["hash"] + " Documentation"

env = jinja2.Environment(
autoescape=False,
@@ -71,7 +74,8 @@ def common_md():
op_extended_template = env.get_template("op_extended.jinja2.md")

output = ""
output += Path(DOCS_DIR / "intro.md").read_text() + "\n\n"
output += Path(DOCS_DIR / "intro.md").read_text() \
.replace("VERSION", _VERSION_["tag"][1:]) + "\n\n"
output += Path(DOCS_DIR / "whats_new.md").read_text() + "\n\n"
output += Path(DOCS_DIR / "quickstart.md").read_text() + "\n\n"
output += Path(DOCS_DIR / "keys.md").read_text() + "\n\n"
@@ -149,6 +153,7 @@ def main():
if ext == ".md":
p.write_text(output)
elif ext == ".html":
output = "# " + _VERSION_STR_ + "\n\n" + output
pypandoc.convert_text(
output,
format=input_format,
@@ -162,7 +167,8 @@ def main():
"--template=" + str(TEMPLATE_DIR / "template.html5")])
elif ext == ".pdf" or ext == ".tex":
latex_preamble = env.get_template("latex_preamble.jinja2.md")
latex = latex_preamble.render(fonts_dir=FONTS_DIR) + "\n\n"
latex = latex_preamble \
.render(title=_VERSION_STR_, fonts_dir=FONTS_DIR) + "\n\n"
latex += output
pypandoc.convert_text(
latex,
@@ -1,5 +1,5 @@
---
title: Teletype Documentation
title: {{title}}
documentclass: report
geometry: margin=1in
links-as-notes: true
ProTip! Use n and p to navigate between commits in a pull request.