blob: 02059268fe18255a1e5222f7a32173464d864e9d [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
4import subprocess
5import fileinput
6import time
7
onqtame6d0d512016-04-27 23:23:16 +03008# the version of the release
9version_major = "1"
10version_minor = "0"
11version_patch = "0"
12
13version = version_major + "." + version_minor + "." + version_patch
14
15# update version in the header file
16
17doctest_contents = ""
18for line in fileinput.input(["../doctest/doctest.h"]):
19 if line.startswith("#define DOCTEST_VERSION_MAJOR"):
20 doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
21 elif line.startswith("#define DOCTEST_VERSION_MINOR"):
22 doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
23 elif line.startswith("#define DOCTEST_VERSION_PATCH"):
24 doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
25 else:
26 doctest_contents += line
27
28readme = open("../doctest/doctest.h", "w")
29readme.write(doctest_contents)
30readme.close()
31
32os.system("git add ../doctest/doctest.h")
33
hardlyb1e7e142014-08-06 00:43:51 +030034# run generate_html.py
35print("generating html documentation from markdown")
36os.system("python generate_html.py")
37
onqtame6d0d512016-04-27 23:23:16 +030038# update changelog
39os.chdir("../")
40os.system("github_changelog_generator --future-release " + version)
41os.system("git add CHANGELOG.md")
42os.chdir("scripts")
hardlyb1e7e142014-08-06 00:43:51 +030043
onqtame6d0d512016-04-27 23:23:16 +030044examples = "../examples/"
hardlyb1e7e142014-08-06 00:43:51 +030045'''
46# create readme files in examples with 'try it online' badges with permalinks
47examples_skip = ["multiprocess"]
48
49for dir in os.listdir(examples):
50 if not os.path.isdir(examples + dir):
51 continue
52
53 # skip folders with more than 1 source file
54 sources = [s for s in os.listdir(examples + dir) if ".cpp" in s]
55 if dir in examples_skip or len(sources) > 1 or len(sources) == 0:
56 continue
57
58 print("generating readme for example '" + examples + dir + "'")
59
60 proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + dir + "/" + sources[0], stdout = subprocess.PIPE)
61 url = proc.stdout.read().strip()
62
63 if not url.startswith("http"):
64 print("skipping current example because of crappy url: '" + url + "'\n")
65 continue
66
67 readme = open(examples + dir + "/README.md", "w")
68 readme.write("[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")")
69 readme.close()
70 os.system("git add " + examples + dir + "/README.md")
71'''
72
73# update main readme 'try it online' badge permalink
74print("updating main readme")
75proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE)
76url = proc.stdout.read().strip()
77
78readme_contents = ""
79for line in fileinput.input(["../README.md"]):
80 if line.startswith("[![Try it online]"):
81 readme_contents += "[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")\n"
82 else:
83 readme_contents += line
84
85readme = open("../README.md", "w")
86readme.write(readme_contents)
87readme.close()
88
89os.system("git add ../README.md")