-#!/usr/bin/env python
-
"""
Check lesson files and their contents.
"""
# What kinds of blockquotes are allowed?
KNOWN_BLOCKQUOTES = {
'callout',
+ 'caution',
'challenge',
'checklist',
'discussion',
'prereq',
'quotation',
'solution',
- 'testimonial'
+ 'testimonial',
+ 'warning'
}
# What kinds of code fragments are allowed?
+# Below we allow all 'language-*' code blocks
KNOWN_CODEBLOCKS = {
'error',
'output',
'source',
- 'language-bash',
- 'html',
- 'language-make',
- 'language-matlab',
- 'language-python',
- 'language-r',
- 'language-shell',
- 'language-sql'
+ 'warning'
}
# What fields are required in teaching episode metadata?
args = parse_args()
args.reporter = Reporter()
- check_config(args.reporter, args.source_dir)
+ life_cycle = check_config(args.reporter, args.source_dir)
+ # pre-alpha lessons should report without error
+ if life_cycle == "pre-alpha":
+ args.permissive = True
check_source_rmd(args.reporter, args.source_dir, args.parser)
args.references = read_references(args.reporter, args.reference_path)
reporter.check_field(config_file, 'configuration',
config, 'kind', 'lesson')
reporter.check_field(config_file, 'configuration',
- config, 'carpentry', ('swc', 'dc', 'lc', 'cp'))
+ config, 'carpentry', ('swc', 'dc', 'lc', 'cp', 'incubator'))
reporter.check_field(config_file, 'configuration', config, 'title')
reporter.check_field(config_file, 'configuration', config, 'email')
reporter.check(defaults in config.get('defaults', []),
'configuration',
'"root" not set to "." in configuration')
+ return config['life_cycle']
def check_source_rmd(reporter, source_dir, parser):
"""Check that Rmd episode files include `source: Rmd`"""
result = {}
urls_seen = set()
- with open(ref_path, 'r') as reader:
+ with open(ref_path, 'r', encoding='utf-8') as reader:
for (num, line) in enumerate(reader, 1):
if P_INTERNAL_INCLUDE_LINK.search(line): continue
{path : {'metadata':yaml, 'metadata_len':N, 'text':text, 'lines':[(i, line, len)], 'doc':doc}}
"""
+ all_dirs = [os.path.join(source_dir, d) for d in SOURCE_DIRS]
+ all_patterns = [os.path.join(d, '*.md') for d in all_dirs]
result = {}
- for d in SOURCE_DIRS:
- dpath = os.path.join(source_dir, d)
-
- pattern = os.path.join(dpath, '*.md')
- for filename in glob.glob(pattern):
+ for pat in all_patterns:
+ for filename in glob.glob(pat):
data = read_markdown(parser, filename)
if data:
result[filename] = data
-
return result
for node in self.find_all(self.doc, {'type': 'codeblock'}):
cls = self.get_val(node, 'attr', 'class')
- self.reporter.check(cls in KNOWN_CODEBLOCKS,
+ self.reporter.check(cls in KNOWN_CODEBLOCKS or cls.startswith('language-'),
(self.filename, self.get_loc(node)),
'Unknown or missing code block type {0}',
cls)
(re.compile(r'README\.md'), CheckNonJekyll),
(re.compile(r'index\.md'), CheckIndex),
(re.compile(r'reference\.md'), CheckReference),
- (re.compile(r'_episodes/.*\.md'), CheckEpisode),
+ (re.compile(os.path.join('_episodes', '*\.md')), CheckEpisode),
(re.compile(r'.*\.md'), CheckGeneric)
]