Zurück zum Ranking

Scony/godot-gdscript-toolkit

Python

Independent set of GDScript tools - parser, linter, formatter, and more

gdscriptgodotformatterlinterparsergodot-engine
Sterne-Wachstum
Sterne
1.6k
Forks
108
Wochenwachstum
Issues
37
5001k1.5k
Dez. 2019Feb. 2022Mai 2024Juli 2026
ArtefaktePyPIpip install godot-gdscript-toolkit
README

GDScript Toolkit

License: MIT Code style: black Buy me a coffe

This project provides a set of tools for daily work with GDScript. At the moment it provides:

  • A parser that produces a parse tree for debugging and educational purposes.
  • A linter that performs a static analysis according to some predefined configuration.
  • A formatter that formats the code according to some predefined rules.
  • A code metrics calculator which calculates cyclomatic complexity of functions and classes.

Installation

To install this project you need python3 and pip. Regardless of the target version, installation is done by pip3 command and for stable releases, it downloads the package from PyPI.

Godot 4

pip3 install "gdtoolkit==4.*"
# or
pipx install "gdtoolkit==4.*"

Godot 3

pip3 install "gdtoolkit==3.*"
# or
pipx install "gdtoolkit==3.*"

master (latest)

Latest version (potentially unstable) can be installed directly from git:

pip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git
# or
pipx install git+https://github.com/Scony/godot-gdscript-toolkit.git

Linting with gdlint (more)

To run a linter you need to execute gdlint command like:

$ gdlint misc/MarkovianPCG.gd

Which outputs messages like:

misc/MarkovianPCG.gd:96: Error: Function argument name "aOrigin" is not valid (function-argument-name)
misc/MarkovianPCG.gd:96: Error: Function argument name "aPos" is not valid (function-argument-name)

Formatting with gdformat (more)

Formatting may lead to data loss, so it's highly recommended to use it along with Version Control System (VCS) e.g. git

To run a formatter you need to execute gdformat on the file you want to format. So, given a test.gd file:

class X:
	var x=[1,2,{'a':1}]
	var y=[1,2,3,]     # trailing comma
	func foo(a:int,b,c=[1,2,3]):
		if a in c and \
		   b > 100:
			print('foo')
func bar():
	print('bar')

when you execute gdformat test.gd command, the test.gd file will be reformatted as follows:

class X:
	var x = [1, 2, {'a': 1}]
	var y = [
		1,
		2,
		3,
	]  # trailing comma

	func foo(a: int, b, c = [1, 2, 3]):
		if a in c and b > 100:
			print('foo')


func bar():
	print('bar')

Parsing with gdparse (more)

To run a parser you need to execute the gdparse command like:

gdparse tests/valid-gd-scripts/recursive_tool.gd -p

The parser outputs a tree that represents your code's structure:

start
  class_def
    X
    class_body
      tool_stmt
      signal_stmt	sss
  class_def
    Y
    class_body
      tool_stmt
      signal_stmt	sss
  tool_stmt

Calculating cyclomatic complexity with gdradon

To run cyclomatic complexity calculator you need to execute the gdradon command like:

gdradon cc tests/formatter/input-output-pairs/simple-function-statements.in.gd tests/gd2py/input-output-pairs/

The command outputs calculated metrics just like Radon cc command does for Python code:

tests/formatter/input-output-pairs/simple-function-statements.in.gd
    C 1:0 X - A (2)
    F 2:1 foo - A (1)
tests/gd2py/input-output-pairs/class-level-statements.in.gd
    F 22:0 foo - A (1)
    F 24:0 bar - A (1)
    C 18:0 C - A (1)
tests/gd2py/input-output-pairs/func-level-statements.in.gd
    F 1:0 foo - B (8)

Using gdtoolkit's GitHub action

In order to setup a simple action with gdtoolkit's static checks, the base action from this repo can be used:

name: Static checks

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  static-checks:
    name: 'Static checks'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: Scony/godot-gdscript-toolkit@master
    - run: gdformat --check source/
    - run: gdlint source/

See the discussion in https://github.com/Scony/godot-gdscript-toolkit/issues/239 for more details.

Using gdtookit in pre-commit

To 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.

repos:
  # GDScript Toolkit
  - repo: https://github.com/Scony/godot-gdscript-toolkit
    rev: 4.2.2
    hooks:
      - id: gdlint
        name: gdlint
        description: "gdlint - linter for GDScript"
        entry: gdlint
        language: python
        language_version: python3
        require_serial: true
        types: [gdscript]
      - id: gdformat
        name: gdformat
        description: "gdformat - formatter for GDScript"
        entry: gdformat
        language: python
        language_version: python3
        require_serial: true
        types: [gdscript]

Development (more)

Everyone is free to fix bugs or introduce new features. For that, however, please refer to existing issue or create one before starting implementation.

Ähnliche Repositories
Orama-Interactive/Pixelorama

Unleash your creativity with Pixelorama, a powerful and accessible open-source pixel art multitool. Whether you want to create sprites, tiles, animations, or just express yourself in the language of pixel art, this software will realize your pixel-perfect dreams with a vast toolbox of features. Available on Windows, Linux, macOS and the Web!

GDScriptMIT Licensegodot-enginegamedev
pixelorama.org
9.9k526
dialogic-godot/dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!

GDScriptMIT Licenseaddonplugin
dialogic.pro
5.8k340
nathanhoad/godot_dialogue_manager

A powerful nonlinear dialogue system for Godot

GDScriptMIT Licensegodotdialogue
dialogue.nathanhoad.net
3.7k263
bitbrain/beehave

🐝 behavior tree AI for Godot Engine

GDScriptMIT Licenseaibehavior-tree
bitbra.in/beehave
3.2k164
gdquest-demos/godot-open-rpg

Learn to create turn-based combat with this Open Source RPG demo ⚔

GDScriptMIT Licenserpgcombat
youtube.com/c/gdquest/
2.9k349
GDQuest/learn-gdscript

Learn Godot's GDScript programming language from zero, right in your browser, for free.

GDScriptOthergame-developmentgodot
school.gdquest.com/courses/learn_2d_gamedev_godot_4/learn_gdscript/
2.7k231
MewPurPur/GodSVG

A vector graphics application for structured SVG editing, available on all major desktop platforms and on web. Currently in late alpha.

GDScriptMIT Licensegdscriptgodot
godsvg.com
2.6k120
gdquest-demos/godot-3-demos

Dozens of free and open source demos for the Godot game engine, version 3. Head to the link below for newer demos for Godot 4+

GDScriptMIT Licensetutorialgodot
github.com/gdquest-demos/
2k961
gdquest-demos/godot-4-procedural-generation

Procedural generation algorithms and demos for the Godot game engine

GDScriptOthergodot-engineprocedural-generation
1.9k101
nezvers/Godot-GameTemplate

Template for top-down shooter, with solutions for tough problems.

GDScriptMIT Licensegodotmenu
1.6k103
gdquest-demos/godot-procedural-generation

Procedural generation algorithms and demos for the Godot game engine

GDScriptOthergodot-engineprocedural-generation
1.6k85
GDQuest/godot-steering-ai-framework

A complete framework for Godot to create beautiful and complex AI motion. Works both in 2D and in 3D.

GDScriptMIT Licensegodotai
gdquest.com/docs/godot-steering-ai-framework
1.5k91