Merge pull request #103 from limbonaut/pre-commit

Add pre-commit configuration
This commit is contained in:
Serhii Snitsaruk 2024-05-03 01:31:25 +02:00 committed by GitHub
commit 5e961ec6fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 63 additions and 35 deletions

24
.pre-commit-config.yaml Normal file
View File

@ -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

2
SCsub
View File

@ -5,7 +5,7 @@ Import("env_modules")
module_env = env.Clone() 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, "*.cpp")
module_env.add_source_files(env.modules_sources, "blackboard/*.cpp") module_env.add_source_files(env.modules_sources, "blackboard/*.cpp")

View File

@ -6,19 +6,19 @@
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'LimboAI' project = "LimboAI"
copyright = '2021-present Serhii Snitsaruk and the LimboAI contributors' copyright = "2021-present Serhii Snitsaruk and the LimboAI contributors"
author = 'Serhii Snitsaruk and the LimboAI contributors' author = "Serhii Snitsaruk and the LimboAI contributors"
release = '1.0' release = "1.0"
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#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' master_doc = "index"
templates_path = ['_templates'] templates_path = ["_templates"]
exclude_patterns = ['_build'] exclude_patterns = ["_build"]
# -- Markdown configuration (sphinx_markdown_builder). # -- Markdown configuration (sphinx_markdown_builder).
# markdown_anchor_sections = True # markdown_anchor_sections = True
@ -33,12 +33,11 @@ default_dark_mode = False
# -- Options for HTML output ------------------------------------------------- # -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme' html_theme = "sphinx_rtd_theme"
html_static_path = ['_static'] html_static_path = ["_static"]
html_logo = "logo.png" html_logo = "logo.png"
html_theme_options = { html_theme_options = {
'logo_only': True, "logo_only": True,
'display_version': True, "display_version": True,
"collapse_navigation": True, "collapse_navigation": True,
} }

View File

@ -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. # tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["limboai/"]) env.Append(CPPPATH=["limboai/"])
env.Append(CPPDEFINES = ['LIMBOAI_GDEXTENSION']) env.Append(CPPDEFINES=["LIMBOAI_GDEXTENSION"])
sources = Glob("limboai/*.cpp") sources = Glob("limboai/*.cpp")
sources += (Glob("limboai/blackboard/*.cpp")) sources += Glob("limboai/blackboard/*.cpp")
sources += (Glob("limboai/blackboard/bb_param/*.cpp")) sources += Glob("limboai/blackboard/bb_param/*.cpp")
sources += (Glob("limboai/bt/*.cpp")) sources += Glob("limboai/bt/*.cpp")
sources += (Glob("limboai/bt/tasks/*.cpp")) sources += Glob("limboai/bt/tasks/*.cpp")
sources += (Glob("limboai/bt/tasks/blackboard/*.cpp")) sources += Glob("limboai/bt/tasks/blackboard/*.cpp")
sources += (Glob("limboai/bt/tasks/composites/*.cpp")) sources += Glob("limboai/bt/tasks/composites/*.cpp")
sources += (Glob("limboai/bt/tasks/decorators/*.cpp")) sources += Glob("limboai/bt/tasks/decorators/*.cpp")
sources += (Glob("limboai/bt/tasks/scene/*.cpp")) sources += Glob("limboai/bt/tasks/scene/*.cpp")
sources += (Glob("limboai/bt/tasks/utility/*.cpp")) sources += Glob("limboai/bt/tasks/utility/*.cpp")
sources += (Glob("limboai/gdextension/*.cpp")) sources += Glob("limboai/gdextension/*.cpp")
sources += (Glob("limboai/editor/debugger/*.cpp")) sources += Glob("limboai/editor/debugger/*.cpp")
sources += (Glob("limboai/editor/*.cpp")) sources += Glob("limboai/editor/*.cpp")
sources += (Glob("limboai/hsm/*.cpp")) sources += Glob("limboai/hsm/*.cpp")
sources += (Glob("limboai/util/*.cpp")) sources += Glob("limboai/util/*.cpp")
if env["platform"] == "macos": if env["platform"] == "macos":

View File

@ -31,18 +31,23 @@ def get_script_dir():
def main(): def main():
silent = False silent = False
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"])
"s", ["silent"])
except getopt.GetoptError as e: 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() usage()
sys.exit(2) sys.exit(2)
for opt, arg in opts: for opt, arg in opts:
if opt in ('-h', '--help'): if opt in ("-h", "--help"):
usage() usage()
sys.exit(0) sys.exit(0)
elif opt in ('-s','--silent'): elif opt in ("-s", "--silent"):
silent = True silent = True
config_dir = get_script_dir() config_dir = get_script_dir()
@ -66,7 +71,7 @@ def main():
icon_files.sort() icon_files.sort()
for icon_file in icon_files: 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 = open(config_path, "w")
f.write(content) f.write(content)