{"id":13526327,"url":"https://github.com/Scony/godot-gdscript-toolkit","last_synced_at":"2025-04-01T07:32:02.709Z","repository":{"id":41067139,"uuid":"224740379","full_name":"Scony/godot-gdscript-toolkit","owner":"Scony","description":"Independent set of GDScript tools - parser, linter, formatter, and more","archived":false,"fork":false,"pushed_at":"2024-10-21T19:23:23.000Z","size":908,"stargazers_count":995,"open_issues_count":17,"forks_count":68,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T17:12:03.419Z","etag":null,"topics":["formatter","gdscript","godot","godot-engine","linter","parser"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Scony.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-11-28T22:45:34.000Z","updated_at":"2024-10-29T03:38:50.000Z","dependencies_parsed_at":"2023-12-16T17:22:15.050Z","dependency_job_id":"b389630e-a29a-498c-8b03-66d7c42d358a","html_url":"https://github.com/Scony/godot-gdscript-toolkit","commit_stats":{"total_commits":581,"total_committers":25,"mean_commits":23.24,"dds":0.08777969018932874,"last_synced_commit":"5d45833cd3c3784d3416d27ef4146ac78281e337"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scony%2Fgodot-gdscript-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scony%2Fgodot-gdscript-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scony%2Fgodot-gdscript-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scony%2Fgodot-gdscript-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Scony","download_url":"https://codeload.github.com/Scony/godot-gdscript-toolkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222709430,"owners_count":17026761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatter","gdscript","godot","godot-engine","linter","parser"],"created_at":"2024-08-01T06:01:28.059Z","updated_at":"2025-04-01T07:32:02.703Z","avatar_url":"https://github.com/Scony.png","language":"Python","readme":"# GDScript Toolkit\n[![](https://github.com/Scony/godot-gdscript-toolkit/workflows/Tests/badge.svg)](https://github.com/Scony/godot-gdscript-toolkit/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Buy me a coffe](https://img.shields.io/badge/Buy%20me%20a%20coffe-FF5E5B?logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/pawel_lampe)\n\nThis project provides a set of tools for daily work with `GDScript`. At the moment it provides:\n\n- A parser that produces a parse tree for debugging and educational purposes.\n- A linter that performs a static analysis according to some predefined configuration.\n- A formatter that formats the code according to some predefined rules.\n- A code metrics calculator which calculates cyclomatic complexity of functions and classes.\n\n## Installation\n\nTo install this project you need `python3` and `pip`.\nRegardless of the target version, installation is done by `pip3` command and for stable releases, it downloads the package from PyPI.\n\n### Godot 4\n\n```\npip3 install \"gdtoolkit==4.*\"\n# or\npipx install \"gdtoolkit==4.*\"\n```\n\n### Godot 3\n\n```\npip3 install \"gdtoolkit==3.*\"\n# or\npipx install \"gdtoolkit==3.*\"\n```\n\n### `master` (latest)\n\nLatest version (potentially unstable) can be installed directly from git:\n```\npip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git\n# or\npipx install git+https://github.com/Scony/godot-gdscript-toolkit.git\n```\n\n## Linting with gdlint [(more)](https://github.com/Scony/godot-gdscript-toolkit/wiki/3.-Linter)\n\nTo run a linter you need to execute `gdlint` command like:\n\n```\n$ gdlint misc/MarkovianPCG.gd\n```\n\nWhich outputs messages like:\n\n```\nmisc/MarkovianPCG.gd:96: Error: Function argument name \"aOrigin\" is not valid (function-argument-name)\nmisc/MarkovianPCG.gd:96: Error: Function argument name \"aPos\" is not valid (function-argument-name)\n```\n\n## Formatting with gdformat [(more)](https://github.com/Scony/godot-gdscript-toolkit/wiki/4.-Formatter)\n\n**Formatting may lead to data loss, so it's highly recommended to use it along with Version Control System (VCS) e.g. `git`**\n\nTo run a formatter you need to execute `gdformat` on the file you want to format. So, given a `test.gd` file:\n\n```\nclass X:\n\tvar x=[1,2,{'a':1}]\n\tvar y=[1,2,3,]     # trailing comma\n\tfunc foo(a:int,b,c=[1,2,3]):\n\t\tif a in c and \\\n\t\t   b \u003e 100:\n\t\t\tprint('foo')\nfunc bar():\n\tprint('bar')\n```\n\nwhen you execute `gdformat test.gd` command, the `test.gd` file will be reformatted as follows:\n\n```\nclass X:\n\tvar x = [1, 2, {'a': 1}]\n\tvar y = [\n\t\t1,\n\t\t2,\n\t\t3,\n\t]  # trailing comma\n\n\tfunc foo(a: int, b, c = [1, 2, 3]):\n\t\tif a in c and b \u003e 100:\n\t\t\tprint('foo')\n\n\nfunc bar():\n\tprint('bar')\n```\n\n## Parsing with gdparse [(more)](https://github.com/Scony/godot-gdscript-toolkit/wiki/2.-Parser)\n\nTo run a parser you need to execute the `gdparse` command like:\n\n```\ngdparse tests/valid-gd-scripts/recursive_tool.gd -p\n```\n\nThe parser outputs a tree that represents your code's structure:\n\n```\nstart\n  class_def\n    X\n    class_body\n      tool_stmt\n      signal_stmt\tsss\n  class_def\n    Y\n    class_body\n      tool_stmt\n      signal_stmt\tsss\n  tool_stmt\n```\n\n## Calculating cyclomatic complexity with gdradon\n\nTo run cyclomatic complexity calculator you need to execute the `gdradon` command like:\n\n```\ngdradon cc tests/formatter/input-output-pairs/simple-function-statements.in.gd tests/gd2py/input-output-pairs/\n```\n\nThe command outputs calculated metrics just like [Radon cc command](https://radon.readthedocs.io/en/latest/commandline.html#the-cc-command) does for Python code:\n```\ntests/formatter/input-output-pairs/simple-function-statements.in.gd\n    C 1:0 X - A (2)\n    F 2:1 foo - A (1)\ntests/gd2py/input-output-pairs/class-level-statements.in.gd\n    F 22:0 foo - A (1)\n    F 24:0 bar - A (1)\n    C 18:0 C - A (1)\ntests/gd2py/input-output-pairs/func-level-statements.in.gd\n    F 1:0 foo - B (8)\n```\n\n## Using gdtoolkit's GitHub action\n\nIn order to setup a simple action with gdtoolkit's static checks, the base action from this repo can be used:\n\n```\nname: Static checks\n\non:\n  push:\n    branches: [ \"main\" ]\n  pull_request:\n    branches: [ \"main\" ]\n\njobs:\n  static-checks:\n    name: 'Static checks'\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - uses: Scony/godot-gdscript-toolkit@master\n    - run: gdformat --check source/\n    - run: gdlint source/\n```\n\nSee the discussion in https://github.com/Scony/godot-gdscript-toolkit/issues/239 for more details.\n\n## Using gdtookit in pre-commit\n\nTo add gdtookit as a pre-commit hook check the latest GitHub version (eg `4.2.2`) and add the followingto your `pre-commit-config.yaml` with the latest version.\n\n```Yaml\nrepos:\n  # GDScript Toolkit\n  - repo: https://github.com/Scony/godot-gdscript-toolkit\n    rev: 4.2.2\n    hooks:\n      - id: gdlint\n        name: gdlint\n        description: \"gdlint - linter for GDScript\"\n        entry: gdlint\n        language: python\n        language_version: python3\n        require_serial: true\n        types: [gdscript]\n      - id: gdformat\n        name: gdformat\n        description: \"gdformat - formatter for GDScript\"\n        entry: gdformat\n        language: python\n        language_version: python3\n        require_serial: true\n        types: [gdscript]\n```\n\n## Development [(more)](https://github.com/Scony/godot-gdscript-toolkit/wiki/5.-Development)\n\nEveryone is free to fix bugs or introduce new features. For that, however, please refer to existing issue or create one before starting implementation.\n","funding_links":["https://ko-fi.com/pawel_lampe"],"categories":["Python","Other","**资源与工具**"],"sub_categories":["3D","**辅助工具**"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScony%2Fgodot-gdscript-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FScony%2Fgodot-gdscript-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScony%2Fgodot-gdscript-toolkit/lists"}