Can I include REUSE comments in project.godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jayman2000

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?

:bust_in_silhouette: Reply From: Wakatta

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 add

extends EditorPlugin

var copyright = """; SPDX-FileCopyrightText: 2016, 2018-2019 Jane Doe <>
; 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 ="res://project.godot", File.READ)
	var license = copyright + project_file.get_as_text()
	#write contents of copyright to project.godot"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