From bc5d5d8610abe147f012352cef39c787a0918ebe Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 3 May 2024 00:21:51 +0200 Subject: [PATCH] Add pre-commit configuration To install git hook scripts: pip install pre-commit pre-commit install --- .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ SCsub | 2 +- doc/source/conf.py | 25 ++++++++++++------------- gdextension/SConstruct | 30 +++++++++++++++--------------- gdextension/update_icons.py | 17 +++++++++++------ 5 files changed, 63 insertions(+), 35 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5d4976 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v17.0.6 + hooks: + - id: clang-format + files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java|glsl)$ + types_or: [text] + exclude: | + (?x)^( + tests/python_build.*| + .*thirdparty.*| + .*platform/android/java/lib/src/com.*| + .*-so_wrap.* + ) + + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.2.0 + hooks: + - id: black + files: (\.py$|SConstruct|SCsub) + types_or: [text] + exclude: .*thirdparty.* + args: + - --line-length=120 diff --git a/SCsub b/SCsub index 9c5b70d..c477576 100644 --- a/SCsub +++ b/SCsub @@ -5,7 +5,7 @@ Import("env_modules") module_env = env.Clone() -module_env.Append(CPPDEFINES = ['LIMBOAI_MODULE']) +module_env.Append(CPPDEFINES=["LIMBOAI_MODULE"]) module_env.add_source_files(env.modules_sources, "*.cpp") module_env.add_source_files(env.modules_sources, "blackboard/*.cpp") diff --git a/doc/source/conf.py b/doc/source/conf.py index c6b27a9..aaaa3b7 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -6,19 +6,19 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'LimboAI' -copyright = '2021-present Serhii Snitsaruk and the LimboAI contributors' -author = 'Serhii Snitsaruk and the LimboAI contributors' -release = '1.0' +project = "LimboAI" +copyright = "2021-present Serhii Snitsaruk and the LimboAI contributors" +author = "Serhii Snitsaruk and the LimboAI contributors" +release = "1.0" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = ['sphinx_rtd_dark_mode', 'sphinx_copybutton'] +extensions = ["sphinx_rtd_dark_mode", "sphinx_copybutton"] -master_doc = 'index' -templates_path = ['_templates'] -exclude_patterns = ['_build'] +master_doc = "index" +templates_path = ["_templates"] +exclude_patterns = ["_build"] # -- Markdown configuration (sphinx_markdown_builder). # markdown_anchor_sections = True @@ -33,12 +33,11 @@ default_dark_mode = False # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'sphinx_rtd_theme' -html_static_path = ['_static'] +html_theme = "sphinx_rtd_theme" +html_static_path = ["_static"] html_logo = "logo.png" html_theme_options = { - 'logo_only': True, - 'display_version': True, + "logo_only": True, + "display_version": True, "collapse_navigation": True, } - diff --git a/gdextension/SConstruct b/gdextension/SConstruct index 3d1217e..e4411b3 100644 --- a/gdextension/SConstruct +++ b/gdextension/SConstruct @@ -14,22 +14,22 @@ env = SConscript("godot-cpp/SConstruct") # tweak this if you want to use different folders, or more folders, to store your source code in. env.Append(CPPPATH=["limboai/"]) -env.Append(CPPDEFINES = ['LIMBOAI_GDEXTENSION']) +env.Append(CPPDEFINES=["LIMBOAI_GDEXTENSION"]) sources = Glob("limboai/*.cpp") -sources += (Glob("limboai/blackboard/*.cpp")) -sources += (Glob("limboai/blackboard/bb_param/*.cpp")) -sources += (Glob("limboai/bt/*.cpp")) -sources += (Glob("limboai/bt/tasks/*.cpp")) -sources += (Glob("limboai/bt/tasks/blackboard/*.cpp")) -sources += (Glob("limboai/bt/tasks/composites/*.cpp")) -sources += (Glob("limboai/bt/tasks/decorators/*.cpp")) -sources += (Glob("limboai/bt/tasks/scene/*.cpp")) -sources += (Glob("limboai/bt/tasks/utility/*.cpp")) -sources += (Glob("limboai/gdextension/*.cpp")) -sources += (Glob("limboai/editor/debugger/*.cpp")) -sources += (Glob("limboai/editor/*.cpp")) -sources += (Glob("limboai/hsm/*.cpp")) -sources += (Glob("limboai/util/*.cpp")) +sources += Glob("limboai/blackboard/*.cpp") +sources += Glob("limboai/blackboard/bb_param/*.cpp") +sources += Glob("limboai/bt/*.cpp") +sources += Glob("limboai/bt/tasks/*.cpp") +sources += Glob("limboai/bt/tasks/blackboard/*.cpp") +sources += Glob("limboai/bt/tasks/composites/*.cpp") +sources += Glob("limboai/bt/tasks/decorators/*.cpp") +sources += Glob("limboai/bt/tasks/scene/*.cpp") +sources += Glob("limboai/bt/tasks/utility/*.cpp") +sources += Glob("limboai/gdextension/*.cpp") +sources += Glob("limboai/editor/debugger/*.cpp") +sources += Glob("limboai/editor/*.cpp") +sources += Glob("limboai/hsm/*.cpp") +sources += Glob("limboai/util/*.cpp") if env["platform"] == "macos": diff --git a/gdextension/update_icons.py b/gdextension/update_icons.py index 7280e90..a8dcf59 100755 --- a/gdextension/update_icons.py +++ b/gdextension/update_icons.py @@ -31,18 +31,23 @@ def get_script_dir(): def main(): silent = False try: - opts, args = getopt.getopt(sys.argv[1:], - "s", ["silent"]) + opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"]) except getopt.GetoptError as e: - print('%s: %s!\n' % (os.path.basename(__file__), e.msg,)) + print( + "%s: %s!\n" + % ( + os.path.basename(__file__), + e.msg, + ) + ) usage() sys.exit(2) for opt, arg in opts: - if opt in ('-h', '--help'): + if opt in ("-h", "--help"): usage() sys.exit(0) - elif opt in ('-s','--silent'): + elif opt in ("-s", "--silent"): silent = True config_dir = get_script_dir() @@ -66,7 +71,7 @@ def main(): icon_files.sort() for icon_file in icon_files: - content += os.path.splitext(icon_file)[0] + " = \"res://addons/limboai/icons/" + icon_file + "\"\n" + content += os.path.splitext(icon_file)[0] + ' = "res://addons/limboai/icons/' + icon_file + '"\n' f = open(config_path, "w") f.write(content)