diff --git a/docs/Makefile b/docs/Makefile index dabd9922..73b68440 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,3 +1,5 @@ -workshop.md: workshop.yml *.md - ./markmaker.py < workshop.yml > workshop.md - # open http://localhost:8888/workshop.html +workshop.html: + +%.html: %.yml *.md workshop.html + ./markmaker.py < $< > $@ || rm $@ + # open $@ diff --git a/docs/dockercon.yml b/docs/dockercon.yml index 4f63cde9..a46de8c8 100644 --- a/docs/dockercon.yml +++ b/docs/dockercon.yml @@ -1,3 +1,7 @@ +exclude: +- self-paced +- snap + chapters: - | class: title diff --git a/docs/kube.yml b/docs/kube.yml index 29c9e648..5870376e 100644 --- a/docs/kube.yml +++ b/docs/kube.yml @@ -1,3 +1,7 @@ +exclude: +- self-paced +- snap + chapters: - | class: title diff --git a/docs/markmaker.py b/docs/markmaker.py index 20550242..255c519d 100755 --- a/docs/markmaker.py +++ b/docs/markmaker.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# transforms a YAML manifest into a MARKDOWN workshop file +# transforms a YAML manifest into a HTML workshop file import glob import logging @@ -19,15 +19,26 @@ class InvalidChapter(ValueError): ValueError.__init__(self, "Invalid chapter: {!r}".format(chapter)) -def yaml2markdown(inf, outf): - manifest = yaml.load(inf) +def generatefromyaml(manifest): + manifest = yaml.load(manifest) + markdown, titles = processchapter(manifest["chapters"]) logging.debug(titles) toc = gentoc(titles) markdown = markdown.replace("@@TOC@@", toc) for (s1,s2) in manifest.get("variables", {}).items(): markdown = markdown.replace(s1, s2) - outf.write(markdown) + + exclude = manifest.get("exclude", []) + logging.debug("exclude={!r}".format(exclude)) + if not exclude: + logging.warning("'exclude' is empty.") + exclude = ",".join('"{}"'.format(c) for c in exclude) + + html = open("workshop.html").read() + html = html.replace("@@MARKDOWN@@", markdown) + html = html.replace("@@EXCLUDE@@", exclude) + return html def gentoc(titles, depth=0, chapter=0): @@ -65,7 +76,6 @@ def processchapter(chapter): if "\n" in chapter: return (chapter, findtitles(chapter)) if os.path.isfile(chapter): - mdfiles.remove(chapter) return processchapter(open(chapter).read()) if isinstance(chapter, list): chapters = [processchapter(c) for c in chapter] @@ -75,6 +85,4 @@ def processchapter(chapter): raise InvalidChapter(chapter) -mdfiles = set(glob.glob("*.md")) -yaml2markdown(sys.stdin, sys.stdout) -logging.debug("The following files were unused: {}".format(mdfiles)) +sys.stdout.write(generatefromyaml(sys.stdin)) diff --git a/docs/selfpaced.yml b/docs/selfpaced.yml index 102a9dbc..f34f75a4 100644 --- a/docs/selfpaced.yml +++ b/docs/selfpaced.yml @@ -1,3 +1,6 @@ +exclude: +- in-person + chapters: - | class: title diff --git a/docs/workshop.html b/docs/workshop.html index 400d268d..4ccae8c2 100644 --- a/docs/workshop.html +++ b/docs/workshop.html @@ -7,6 +7,7 @@
+ +