aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-09-22 00:21:28 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-09-22 00:21:28 +0100
commita207b43097d28ab8fc0c72376d00223518c424b7 (patch)
tree5b8446526bf35732c4226b0608c587b2de0bc3df /scripts
parent341991bd244db9f8ecf7f69f48fde5e095c84554 (diff)
downloadYAGE-a207b43097d28ab8fc0c72376d00223518c424b7.tar.gz
YAGE-a207b43097d28ab8fc0c72376d00223518c424b7.zip
updating script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/add_version_headers94
-rwxr-xr-xscripts/update_docs15
2 files changed, 109 insertions, 0 deletions
diff --git a/scripts/add_version_headers b/scripts/add_version_headers
new file mode 100755
index 00000000..def7d55a
--- /dev/null
+++ b/scripts/add_version_headers
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# -----------------------------------------------------------------------------
+# add_version_headers
+#
+# Add version header
+#
+# Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
+# See file LICENSE for more details
+# -----------------------------------------------------------------------------
+
+"""\file add_version_headers
+\brief Adds the version headers to every file.
+
+Add Version Headers
+===================
+
+This file adds the version headers to every file in the directory
+
+
+Improvements
+------------
+
+Add the ability to input command line arguments.
+"""
+
+import os
+import re
+import sys
+
+
+header = """/* ---------------------------------------------------------------\
+-------------
+ * {0}
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+"""
+
+
+class HeaderUpdate(object):
+ """Updates the header in all the source and header files in the code"""
+ def __init__(self, **kwargs):
+ self.match_re = ".*[.]cpp$|.*[.]hpp$"
+ self.exclude_re = "^$"
+ self.exclude_build = True
+ self.exclude_dir = ".*build.*"
+ self.match_dir = ""
+ self.comment_match = "^\/[*] -+"
+ self.starting_dir = os.getcwd()
+ for key, value in kwargs.items():
+ setattr(self, key, value)
+
+ def writeHeader(self):
+ def writeFileOperation(filePath, src):
+ if not re.match(self.comment_match, src):
+ print(filePath, end=" ")
+ with open(filePath, 'w') as src_file_lic:
+ src_file_lic.write(header.format(filePath))
+ src_file_lic.write(src)
+ print("-- done")
+
+ self._traverseDir(self.starting_dir, writeFileOperation)
+
+ def updateHeader(self):
+ ...
+
+ def removeHeader(self):
+ ...
+
+ def _traverseDir(self, path, fileOperation):
+ for subdir, dirs, files in os.walk(os.getcwd()):
+ if (not re.match(self.exclude_dir, subdir)) and \
+ (re.match(self.match_dir, subdir)):
+ for fileName in files:
+ if (re.match(self.match_re, fileName)) and \
+ (not re.match(self.exclude_re, fileName)):
+ with open(os.path.join(subdir, fileName), 'r') \
+ as src_file:
+ src = src_file.read()
+ fileOperation(os.path.join(subdir, fileName), src)
+
+
+def main(argv):
+ update = HeaderUpdate(exclude_re="^picopng[.]cpp",
+ exclude_dir=".*build.*|.*google.*",
+ match_dir=".*src.*|.*include.*|.*test.*")
+ update.writeHeader()
+
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/scripts/update_docs b/scripts/update_docs
new file mode 100755
index 00000000..f1ba2ba9
--- /dev/null
+++ b/scripts/update_docs
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+if [[ "$TRAVIS_BRANCH" == "master" ]]; then
+ doxygen ./docs/Doxyfile
+ cd html
+ git init
+ git config user.name "TravisBot"
+ git config user.email ""
+ git remote add upstream "https://$GH_TOKEN@github.com/ymherklotz/YAGE.git"
+ git fetch upstream
+ git reset upstream/gh-pages
+ git add -A
+ git commit -m "Rebuilding documentation"
+ git push -q upstream HEAD:gh-pages
+fi