7 # I prefer writing python code rather than JSON natively
8 # plus, this might be the place to inject subindexes for the tutorials page some day
11 # '*' means this is visible to all input files unless overridden
12 # in a more specific location
13 '*' : { 'logos_height': '18px'}
16 title_header = 'title:'
18 def tuto_contents(md):
20 input is a markdown filename
21 which is expected to define title:
22 output is a tuple (name, title)
23 with name having its '.md' removed
24 and title being said title
26 basename = md.replace('.md', '')
27 title = 'No title set'
28 with open(md) as input:
29 for line in input.readlines():
30 if line.startswith(title_header):
31 title = line[len(title_header):].strip()
32 return (basename, title)
36 meta = hard_wired_meta
39 # get the list of tutorials
40 tuto_files = glob.glob("tuto*.md")
41 # make sure the '*' key is present
42 wildcard = meta.setdefault('*', None)
43 wildcard['tutos'] = [ tuto_contents(tf) for tf in tuto_files]
46 with open('markdown/meta.json', 'w') as output:
47 json.dump(meta, output)
50 if __name__ == '__main__':