blob: d407ca9552248554bd8e6a7ad98c758c08a323a1 [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
4import subprocess
5import fileinput
6import time
7
8# run generate_html.py
9print("generating html documentation from markdown")
10os.system("python generate_html.py")
11
12examples = "../examples/"
13
14'''
15# create readme files in examples with 'try it online' badges with permalinks
16examples_skip = ["multiprocess"]
17
18for dir in os.listdir(examples):
19 if not os.path.isdir(examples + dir):
20 continue
21
22 # skip folders with more than 1 source file
23 sources = [s for s in os.listdir(examples + dir) if ".cpp" in s]
24 if dir in examples_skip or len(sources) > 1 or len(sources) == 0:
25 continue
26
27 print("generating readme for example '" + examples + dir + "'")
28
29 proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + dir + "/" + sources[0], stdout = subprocess.PIPE)
30 url = proc.stdout.read().strip()
31
32 if not url.startswith("http"):
33 print("skipping current example because of crappy url: '" + url + "'\n")
34 continue
35
36 readme = open(examples + dir + "/README.md", "w")
37 readme.write("[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")")
38 readme.close()
39 os.system("git add " + examples + dir + "/README.md")
40'''
41
42# update main readme 'try it online' badge permalink
43print("updating main readme")
44proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE)
45url = proc.stdout.read().strip()
46
47readme_contents = ""
48for line in fileinput.input(["../README.md"]):
49 if line.startswith("[![Try it online]"):
50 readme_contents += "[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")\n"
51 else:
52 readme_contents += line
53
54readme = open("../README.md", "w")
55readme.write(readme_contents)
56readme.close()
57
58os.system("git add ../README.md")