From 7a4beed6a666abc4eef3de9538cb5ae46333bc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 3 Aug 2019 10:44:57 +0200 Subject: [PATCH] Make release script update version placeholders in docs --- scripts/releaseCommon.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/releaseCommon.py b/scripts/releaseCommon.py index 9cdc4f6c..87c6e261 100644 --- a/scripts/releaseCommon.py +++ b/scripts/releaseCommon.py @@ -4,6 +4,8 @@ import os import sys import re import string +import glob +import fnmatch from scriptCommon import catchPath @@ -123,6 +125,25 @@ def updateVersionDefine(version): 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): # First update version file, so we can regenerate single header and # have it ready for upload to wandbox, when updating readme @@ -143,3 +164,4 @@ def performUpdates(version): updateReadmeFile(version) updateCmakeFile(version) + updateDocumentationVersionPlaceholders(version)