Adding checks for things that commonly go wrong during template conversion.
authorGreg Wilson <gvwilson@third-bit.com>
Thu, 15 Sep 2016 18:37:58 +0000 (14:37 -0400)
committerGreg Wilson <gvwilson@third-bit.com>
Thu, 15 Sep 2016 18:37:58 +0000 (14:37 -0400)
1. Checking that `index.md` has `root` set to '.'
2. Checking that `_config.yml` has `root` set to '..'

bin/lesson_check.py

index 7bc09a361c1729a8a3210ea9f31690320262ca8d..311687e92ac851ba3c5c5af2720ce45d03490902 100755 (executable)
@@ -155,6 +155,10 @@ def check_config(reporter, source_dir):
     reporter.check_field(config_file, 'configuration', config, 'title')
     reporter.check_field(config_file, 'configuration', config, 'email')
 
+    reporter.check({'values': {'root': '..'}} in config.get('defaults', []),
+                   'configuration',
+                   '"root" not set to ".." in configuration')
+
 
 def read_all_markdown(source_dir, parser):
     """Read source files, returning
@@ -424,6 +428,12 @@ class CheckIndex(CheckBase):
         super(CheckIndex, self).__init__(args, filename, metadata, metadata_len, text, lines, doc)
         self.layout = 'lesson'
 
+    def check_metadata(self):
+        super(CheckIndex, self).check_metadata()
+        self.reporter.check(self.metadata.get('root', '') == '.',
+                            self.filename,
+                            'Root not set to "."')
+
 
 class CheckEpisode(CheckBase):
     """Check an episode page."""