• Stars
    star
    240
  • Rank 168,229 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create documentation and class references from your Godot GDScript code

GDScript Docs Maker

GitHub release (latest by date) Docker Image Version (latest semver)

Project banner

Introduction

GDScript Docs Maker is a set of tools to convert documentation you write inside your code to an online or offline code reference in the markdown or hugo format. If you make plugins or a framework for Godot, GDScript Docs Maker will generate API reference documentation from your code.

It creates documents following Godot's built-in class reference. You can see an example with our Godot Steering Toolkit documentation

Usage

GDScript Docs Maker can be either used using the official Docker image or by installing it locally. For the docker image, only Docker is required.

For the local installation, Godot 3.2+ and Python 3.7+ are required.

Using the container image

To generate your API documentation, you mount the path of your game and the path of the output into the container and run it like this:

docker run --rm -v /my/game:/game -v /my/game/docs/api:/output gdquest/gdscript-docs-maker:latest /game -o /output

This will generate the API documentation in the subpath docs/api of your game located at /my/game. See below for further parameters.

Local installation

You can install the GDScript Docs Maker python package with pip:

# On Linux and MacOS:
python3 -m pip install gdscript_docs_maker

# On Windows, if you installed Python 3.7+, you can use:
python -m pip install gdscript_docs_maker

Although to use the shell script that simplifies creating the reference, generate_reference, you need to clone this repository. More on that below.

Writing your code reference

Docstring or doc-comments in GDScript don't have any special markup.

You can document classes, properties, and functions with comment blocks placed on the line before their definition.

Example of docstrings for Godot 3:

# A linear and angular amount of acceleration.
class_name GSTTargetAcceleration


# Linear acceleration
var linear: = Vector3.ZERO
# Angular acceleration
var angular: = 0.0


# Resets the accelerations to zero
func reset() -> void:
	linear = Vector3.ZERO
	angular = 0.0

Example of docstrings for Godot 4:

## A linear and angular amount of acceleration.
class_name GSTTargetAcceleration


## Linear acceleration
var linear: = Vector3.ZERO
## Angular acceleration
var angular: = 0.0


## Resets the accelerations to zero
func reset() -> void:
	linear = Vector3.ZERO
	angular = 0.0

If you need long docstrings, you can use multiple commented lines:

## A specialized steering agent that updates itself every frame so the user does
## not have to using a KinematicBody2D
## category: Specialized agents
extends GSAISpecializedAgent
class_name GSAIKinematicBody2DAgent

Generating the markdown files

We wrote two shell scripts to automate the steps in generating a code reference: ./generate_reference for Linux or MacOS, and ./generate_reference.bat for Windows.

Use either of them to quickly generate your code reference:

Generate a code reference from GDScript
Usage:
generate_reference $project_directory [options]

Required arguments:

$project_directory -- path to your Godot project directory.
This directory or one of its subdirectories should contain a
project.godot file.

Options:

-h/--help             -- Display this help message.
-o/--output-directory -- directory path to output the documentation into.
-d/--directory        -- Name of a directory to find files and generate the code reference in the Godot project.
                         You can use the option multiple times to generate a reference for multiple directories.
-f/--format           -- Either `markdown` or `hugo`. If `hugo`, the output document includes a TOML front-matter
                         at the top. Default: `markdown`.
-a/--author           -- If --format is `hugo`, controls the author property in the TOML front-matter.


Usage example:

generate_reference ~/Repositories/other/nakama-godot/project/ -o export-nakama -d addons

This command walks files in the res://addons directory of the Godot Nakama project, and converts it
to markdown files output in ./export-nakama.

To use them:

Hugo output

You can output markdown files for hugo, the static website engine.

To do so, call GDScript docs maker with the --format hugo option. You can use two extra flags with this:

--date YYYY-MM-DD, the date in iso format, if you want the documents to have a date other than today. Default: datetime.date.today()
--author author_id, the id of the author on your hugo website, to assign an the author for the documents. Default: ""

Here's how I generate the Godot Steering Toolkit's documentation. This command outputs the class reference straight into the website:

python3 -m gdscript_docs_maker $HOME/Repositories/godot-steering-toolkit/project/reference.json --format hugo --author razoric --path $HOME/Repositories/website/content/docs/godot-steering-toolkit/reference/classes/

The manual way

If you want to generate the JSON and convert it manually, there are three steps involved:

  1. Copying the GDScript files to your Godot project:
    • ./godot-scripts/Collector.gd and ./godot-scripts/ReferenceCollectorCLI.gd or ./godot-scripts/ReferenceCollectorCLI.gd for Godot 3
    • ./godot-scripts/CollectorGd4.gd and ./godot-scripts/ReferenceCollectorCLIGd4.gd or ./godot-scripts/ReferenceCollectorCLIGd4.gd for Godot 4
  2. Running the GDScript code with Godot, either from the editor (ReferenceCollector.gd / ReferenceCollectorGd4.gd) or by calling Godot from the command line (ReferenceCollectorCLI.gd / ReferenceCollectorCLIGd4.gd).
  3. Running gdscript_docs_maker on the reference.json file that Godot generated in the previous step.

Note: to parse and collect data from GDScript code, we rely on the GDScript language server that's new in Godot 3.2.

Converting JSON

Call the gdscript-docs-maker package directly using the python -m option:

Usage: gdscript_docs_maker [-h] [-p PATH] [-v] [--dry-run] files [files ...]

Merges or converts json data dumped by Godot's GDScript language server to
create a code reference.

positional arguments:
  files                 A list of paths to JSON files.

optional arguments:
  -h, --help            Show this help message and exit.
  -p PATH, --path PATH  Path to the output directory.
  -v, --verbose         Set the verbosity level. For example, -vv sets the
                        verbosity level to 2. Default: 0.
  --dry-run             Run the script without creating
                        files and folders. For debugging purposes.

The program takes a list of JSON files. For example, we generate the code reference of our AI framework Godot Steering Toolkit like so with the shell:

python -m gdscript-docs-maker ~/Repositories/godot-steering-toolkit/src/reference.json

More Repositories

1

godot-shaders

A large library of free and open-source shaders for the Godot game engine. Here, you'll get 2D and 3D shaders with playable demos.
GLSL
2,164
star
2

learn-gdscript

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

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+
GDScript
1,753
star
4

godot-open-rpg

Learn to create turn-based combat with this Open Source RPG demo βš”
GDScript
1,432
star
5

godot-steering-ai-framework

A complete framework for Godot to create beautiful and complex AI motion. Works both in 2D and in 3D.
GDScript
1,144
star
6

godot-procedural-generation

Procedural generation algorithms and demos for the Godot game engine
GDScript
1,103
star
7

godot-make-pro-2d-games

A-RPG demo made with Godot, MIT-licensed, from our Godot course
GDScript
891
star
8

godot-3d-mannequin

An Open Source 3d character and character controller for the Godot game engine
C#
760
star
9

blender-power-sequencer

Add-on for video editing in Blender 3D: edit videos faster! Included in Blender 2.81+
Python
688
star
10

godot-2d-space-game

A 2D space exploration and mining game made with Godot and our AI framework
GDScript
675
star
11

godot-visual-effects

Open-source visual effects designed in Godot, from our VFX Secrets course.
GDScript
622
star
12

godot-platformer-2d

2d Metroidvania-inspired game for the 2019 GDquest Godot Kickstarter course project.
GDScript
532
star
13

godot-power-pitch

International pitch for the Godot Game Engine, made in Godot, available in 15+ languages
GDScript
383
star
14

godot-2d-builder

A simulation game demo made in Godot and inspired by Factorio.
GDScript
375
star
15

godot-demos-2022

Free and open-source Godot demos for learning, with guides and tutorials: 2022 edition.
GDScript
362
star
16

godot-beginner-2d-platformer

Learn to create a 2d platform game with the Godot game engine. This is a beginner programming tutorial.
GDScript
326
star
17

krita-batch-exporter

A Free Krita plugin to batch export layers and groups with maximum flexibility. Scale, trim, export multiple copies of your layers...
Python
281
star
18

krita-free-brushes

A collection of Free Krita brushes, by GDQuest, for concept artists, illustrators and game artists
256
star
19

godot-kickstarter-2019

Create your Own Games with Godot, the Free Game Engine: sources from the January Kickstarter project from GDQuest
GDScript
238
star
20

godot-2d-jrpg-combat

A 2D Japanese RPG Active Time Battle demo for the Godot game engine
GDScript
182
star
21

godot-mini-tuts-demos

Code from our Godot mini tutorials
GDScript
128
star
22

godot-design-patterns

Code design patterns in Godot and in GDScript. State machines and the likes.
C#
123
star
23

godot-tours

A framework for interactive step-by-step tutorials in the Godot editor
GDScript
101
star
24

godot-2d-visual-novel

A Visual Novel demo made with the Godot game engine
GDScript
95
star
25

godot-2d-tactical-space-combat

A 2D Tactical Space Combat demo for the Godot game engine. Inspired by FTL
GDScript
90
star
26

godot-2d-rhythm

This demo is a rhythm game designed for the course Godot 2D Secrets.
GDScript
88
star
27

godot-2d-tactical-rpg-movement

Grid-based movement for a Tactical RPG
GDScript
79
star
28

godot-presentations

Create beautiful interactive presentations and localize them! Made with the Godot game engine
GDScript
69
star
29

krita-tileset-templates

Tileset and tilemap templates for Krita, Photoshop and Tiled 1.0
67
star
30

godot-getting-started-2021

Downloads for the Getting Started with Godot in 2021 free course.
GDScript
57
star
31

godot-2d-tower-defense

GDScript
50
star
32

product-packager

A portable shell program to package and prepare courses, tutorial series, and other products to release on e-commerce platforms like Gumroad and Mavenseed.
Python
50
star
33

godot-guides-v3.0

Work in progress guides and tutorials for the official Godot 3.0 documentation
GDScript
43
star
34

website

HTML
43
star
35

game-sprites

A library of Free game assets to prototype your games
38
star
36

godot-new-features-v3.1

Tutorial series and demos to learn the new features in Godot 3.1
GDScript
31
star
37

learn-gdscript-translations

Translations for the open-source app Learn GDScript From Zero
Python
31
star
38

godot-3d-fps-beginner-series

A beginner-friendly tutorial series hosted by James Taft to learn to create a First Person Shooter in Godot
GDScript
27
star
39

godot-demo-projects-remake

Proof of concept to greatly improve to the official godot demo projects repository.
GDScript
26
star
40

blender-proxies-generator

Command line program to generate video proxies faster for Blender's Video Sequence Editor, using ffmpeg
Python
26
star
41

blender-sequencer-multithreaded-render

Multithreaded renders for the Blender video sequence editor, from the command line
Python
25
star
42

godot-visualization-tools

Tools for debug drawing and animation for visualizations and tutorials
GDScript
23
star
43

godot-2d-action-platformer

GDScript
22
star
44

godot-steering-ai-framework-submodule

A complete framework for Godot to create beautiful and complex AI motion. Works both in 2D and in 3D. For use as Git submodules.
GDScript
21
star
45

godot-steering-ai-framework-demos

Repository of demos and test scenes for GDQuest's Steering AI Framework
GDScript
18
star
46

godot-debug-ui-toolkit

Modular UI components to create debug interfaces and add-on interfaces in Godot.
GDScript
15
star
47

meta

A repository to talk about GDQuest at large, guidelines, etc. all in one place. This is where public discussions that don't belong to a specific repository go.
13
star
48

godot-text-tools

A collection of addons to help to edit text and UI faster within Godot. Color palette, rich text editor...
GDScript
11
star
49

blender-power-sequencer-docs

Documentation sources for Power Sequencer, the Blender add-on for video makers
10
star
50

emacs-flycheck-gdscript

Emacs flycheck extension to lint GDScript code with gdlint
7
star
51

3D-graphics-benchmark-PoC

GDScript
5
star
52

GDPractice

A framework to create interactive coding practices in the Godot engine.
GDScript
4
star
53

godot-plugin-highlighter

Highlights parts of the editor interface that are under the mouse
GDScript
4
star
54

godot-addons

GDQuest Godot Addons
GDScript
4
star
55

godot-js-types

Javascript and Typescript types for Godot related files and the in-browser Godot runtime
JavaScript
3
star
56

godot-plugin-tour

Utilities to create Godot tours
GDScript
3
star
57

godot-colorpicker-presets

Reads a color presets hex file in the project directory and adds the colors to the editor ColorPicker for quick access.
GDScript
3
star
58

godot-learning-app-exporter

Exports Godot projects for usage in the GDQuest learning app
JavaScript
3
star
59

process-course

TypeScript
1
star