blob: 89b52f567e94fd3aa610863b73769397c1f7a692 [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
onqtam90d95de2016-05-22 04:17:34 +03004import sys
hardlyb1e7e142014-08-06 00:43:51 +03005import subprocess
6import fileinput
7import time
8
onqtame6d0d512016-04-27 23:23:16 +03009# the version of the release
onqtame8bdda42016-06-01 15:12:36 +030010with open("version.txt") as f: version = f.read()
onqtame6d0d512016-04-27 23:23:16 +030011
onqtame8bdda42016-06-01 15:12:36 +030012def getVersionTuple(v):
13 return tuple(map(int, (v.split("."))))
14
15version_major = str(getVersionTuple(version)[0])
16version_minor = str(getVersionTuple(version)[1])
17version_patch = str(getVersionTuple(version)[2])
onqtame6d0d512016-04-27 23:23:16 +030018
19# update version in the header file
onqtame8bdda42016-06-01 15:12:36 +030020print("updating the version in the header file")
onqtame6d0d512016-04-27 23:23:16 +030021doctest_contents = ""
onqtame8bdda42016-06-01 15:12:36 +030022for line in fileinput.input(["../doctest/parts/doctest_fwd.h"]):
onqtamf3a680f2016-04-30 03:15:07 +030023 if line.startswith("#define DOCTEST_VERSION_MAJOR "):
onqtame6d0d512016-04-27 23:23:16 +030024 doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030025 elif line.startswith("#define DOCTEST_VERSION_MINOR "):
onqtame6d0d512016-04-27 23:23:16 +030026 doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030027 elif line.startswith("#define DOCTEST_VERSION_PATCH "):
onqtame6d0d512016-04-27 23:23:16 +030028 doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
onqtamd1737e42016-08-01 19:05:07 +030029 elif line.startswith("#define DOCTEST_VERSION_STR "):
30 doctest_contents += "#define DOCTEST_VERSION_STR \"" + version + "\"\n"
onqtame6d0d512016-04-27 23:23:16 +030031 else:
32 doctest_contents += line
33
onqtame8bdda42016-06-01 15:12:36 +030034readme = open("../doctest/parts/doctest_fwd.h", "w")
onqtame6d0d512016-04-27 23:23:16 +030035readme.write(doctest_contents)
36readme.close()
37
hardlyb1e7e142014-08-06 00:43:51 +030038# run generate_html.py
onqtam8126b562016-05-27 17:01:15 +030039print("generating html documentation from markdown")
40os.system("python generate_html.py")
hardlyb1e7e142014-08-06 00:43:51 +030041
onqtame6d0d512016-04-27 23:23:16 +030042examples = "../examples/"
hardlyb1e7e142014-08-06 00:43:51 +030043'''
44# create readme files in examples with 'try it online' badges with permalinks
45examples_skip = ["multiprocess"]
46
47for dir in os.listdir(examples):
48 if not os.path.isdir(examples + dir):
49 continue
50
51 # skip folders with more than 1 source file
52 sources = [s for s in os.listdir(examples + dir) if ".cpp" in s]
53 if dir in examples_skip or len(sources) > 1 or len(sources) == 0:
54 continue
55
56 print("generating readme for example '" + examples + dir + "'")
57
58 proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + dir + "/" + sources[0], stdout = subprocess.PIPE)
59 url = proc.stdout.read().strip()
60
61 if not url.startswith("http"):
62 print("skipping current example because of crappy url: '" + url + "'\n")
63 continue
64
65 readme = open(examples + dir + "/README.md", "w")
66 readme.write("[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")")
67 readme.close()
hardlyb1e7e142014-08-06 00:43:51 +030068'''
69
70# update main readme 'try it online' badge permalink
71print("updating main readme")
72proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE)
73url = proc.stdout.read().strip()
74
75readme_contents = ""
76for line in fileinput.input(["../README.md"]):
onqtam90d95de2016-05-22 04:17:34 +030077 if line.startswith("[![Try it online]"):
78 readme_contents += "[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")\n"
hardlyb1e7e142014-08-06 00:43:51 +030079 else:
80 readme_contents += line
81
82readme = open("../README.md", "w")
83readme.write(readme_contents)
84readme.close()