0 votes

I'm working on a project that will be free software. I would like to make the project REUSE compliant because it makes it easy for me to clearly communicate my copyright intent.

To be REUSE compliant, each file must have its copyright status clearly defined. There's three ways of doing that. In order of preference:

  1. Add comments at the top of the file
  2. Add a .license file
  3. Add the file to a DEP5 file

project.godot has comments at the top of it, but if I add any comments, Godot deletes them when I open the project. Is there any way to get Godot to keep REUSE comments at the top of project.godot?

Godot version 3.2.3
in Engine by (369 points)

1 Answer

+1 vote
Best answer

The fact that it deletes the comments when opened is actually a good thing.
Using that knowledge to your advantage.

Create a new Plugin
Project > ProjectSettings > Plugins Tab > Create

In your plugin.gd add

extends EditorPlugin

var copyright = """; SPDX-FileCopyrightText: 2016, 2018-2019 Jane Doe <[email protected]>
; SPDX-FileCopyrightText: 2019 Example Company
; SPDX-License-Identifier: GPL-3.0-or-later


func save_external_data():
    #opens project file and append contents to copyright
    var project_file = File.new()
    project_file.open("res://project.godot", File.READ)
    var license = copyright + project_file.get_as_text()

    #write contents of copyright to project.godot
    project_file.open("res://project.godot", File.WRITE)

This way every time you close or save the project the copyright information gets added and since Godot cleans up the file on re-open it can be used again in this same way

Edit: forgot to mention Godot will throw a fit if you don't use ;in project.godot to comment the lines so change your # Comment Line to ; Comment Line

by (6,262 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.