Make release script update version placeholders in docs

This commit is contained in:
Martin Hořeňovský 2019-08-03 10:44:57 +02:00
parent 67b4ada6b0
commit 7a4beed6a6
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -4,6 +4,8 @@ import os
import sys import sys
import re import re
import string import string
import glob
import fnmatch
from scriptCommon import catchPath from scriptCommon import catchPath
@ -123,6 +125,25 @@ def updateVersionDefine(version):
file.write(line) file.write(line)
def updateVersionPlaceholder(filename, version):
with open(filename, 'rb') as file:
lines = file.readlines()
placeholderRegex = re.compile(b'\) in Catch X.Y.Z')
replacement = '\) in Catch {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii')
with open(filename, 'wb') as file:
for line in lines:
file.write(placeholderRegex.sub(replacement, line))
def updateDocumentationVersionPlaceholders(version):
print('Updating version placeholder in documentation')
docsPath = os.path.join(catchPath, 'docs/')
for basePath, _, files in os.walk(docsPath):
for file in files:
if fnmatch.fnmatch(file, "*.md") and "contributing.md" != file:
updateVersionPlaceholder(os.path.join(basePath, file), version)
def performUpdates(version): def performUpdates(version):
# First update version file, so we can regenerate single header and # First update version file, so we can regenerate single header and
# have it ready for upload to wandbox, when updating readme # have it ready for upload to wandbox, when updating readme
@ -143,3 +164,4 @@ def performUpdates(version):
updateReadmeFile(version) updateReadmeFile(version)
updateCmakeFile(version) updateCmakeFile(version)
updateDocumentationVersionPlaceholders(version)