From 6ac6cfb60a5a09a7ae59164ca5a71a7223207736 Mon Sep 17 00:00:00 2001 From: CasVT Date: Thu, 1 Feb 2024 14:53:30 +0100 Subject: [PATCH] Fixed error linking in API doc generation script --- project_management/generate_api_docs.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/project_management/generate_api_docs.py b/project_management/generate_api_docs.py index b3cfeca..b24e13e 100644 --- a/project_management/generate_api_docs.py +++ b/project_management/generate_api_docs.py @@ -21,6 +21,15 @@ url_var_map = { 'int:s_id': ReminderNotFound } +def make_exception_instance(cls: Exception) -> Exception: + try: + return cls() + except TypeError: + try: + return cls('1') + except TypeError: + return cls('1', '2') + result = f"""# API Below is the API documentation. Report an issue on [GitHub](https://github.com/Casvt/MIND/issues). @@ -112,7 +121,7 @@ Replace `<{url_var}>` with the ID of the entry. For example: `{rule.replace(f'<{ url_exception = [url_var_map[url_var]] if url_var in url_var_map else [] variable_exceptions = [e for v in data['input_variables'].get(method, []) for e in v.related_exceptions] related_exceptions = sorted( - (e() for e in set(variable_exceptions + url_exception)), + (make_exception_instance(e) for e in set(variable_exceptions + url_exception)), key=lambda e: (e.api_response['code'], e.api_response['error']) ) for related_exception in related_exceptions: @@ -130,9 +139,9 @@ else: with open(folder_path('docs', 'api.md'), 'w+') as f: f.write(result) - run(["git", "config", "--global", "user.email", '"casvantijn@gmail.com"']) - run(["git", "config", "--global", "user.name", '"CasVT"']) - run(["git", "checkout", "Development"]) - run(["git", "add", folder_path('docs', 'api.md')]) - run(["git", "commit", "-m", "Updated API docs"]) - run(["git", "push"]) + # run(["git", "config", "--global", "user.email", '"casvantijn@gmail.com"']) + # run(["git", "config", "--global", "user.name", '"CasVT"']) + # run(["git", "checkout", "Development"]) + # run(["git", "add", folder_path('docs', 'api.md')]) + # run(["git", "commit", "-m", "Updated API docs"]) + # run(["git", "push"])