From 04857ec79b217a430fcee043fd2740495d4aea22 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 4 Jan 2021 18:38:05 +0000 Subject: [PATCH] added a function to add the build information to the documents --- binarycpython/utils/functions.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 407c1caf9..45b829a4e 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -881,6 +881,27 @@ def get_help_super(print_help: bool=False, fail_silently: bool=True) -> dict: return help_all_super_dict +def make_build_text() -> str: + """ + Function to make build text + + Returns: + string containing information about the build and the git branch + """ + + + version_info = return_binary_c_version_info(parsed=True) + + git_revision = version_info['miscellaneous']['git_revision'] + git_branch = version_info['miscellaneous']['git_branch'] + build_datetime = version_info['miscellaneous']['build'] + + + info_string = "This information was obtained by the following binary_c build: \n\t**binary_c git branch**: {}\t**binary_c git revision**: {}\t**Built on**: {}".format(git_branch, git_revision, build_datetime) + + return info_string + + def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: """ Function that calls the get_help_super() to get the help text/descriptions for all the parameters available in that build. @@ -896,6 +917,8 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: # Get the whole arguments dictionary arguments_dict = get_help_super() + build_info = make_build_text() + if not output_file.endswith(".rst"): print("Filename doesn't end with .rst, please provide a proper filename") return None @@ -906,6 +929,8 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: print("{}".format("="*len("Binary\\_c parameters")), file=f) print("The following chapter contains all the parameters that the current version of binary\\_c can handle, along with their descriptions and other properties.", file=f) print("\n", file=f) + print(build_info, file=f) + print("\n", file=f) for el in arguments_dict.keys(): print("Section: {}".format(el), file=f) @@ -927,6 +952,7 @@ def write_binary_c_parameter_descriptions_to_rst_file(output_file: str) -> None: print("| **Extra**: {}".format(argdict["rest"]), file=f) print("", file=f) + ######################################################## # logfile functions ######################################################## -- GitLab