Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation generation for in-engine display #115

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ jobs:
rm -r ./addons/Wwise/native/src
rm -r ./addons/Wwise/native/vs2022
rm -r ./addons/Wwise/native/android
rm -r ./addons/Wwise/native/doc_classes
rm ./addons/Wwise/native/SConstruct
rm ./LICENSE
rm ./README.md
Expand Down
50 changes: 50 additions & 0 deletions addons/Wwise/native/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,53 @@ else:
def decode_utf8(x):
return codecs.utf_8_decode(x)[0]

# This is a modified version of the documentation generation function from godot-cpp in godotcpp.py.
# Unlike the original, this version writes the generated .cpp file directly to disk,
# rather than including it in the sources processed by the build system during the build stage.
def make_doc_source(target, source, env):
import zlib
if not os.path.exists(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))

dst = str(target)
g = open(dst, "w", encoding="utf-8")
buf = ""
docbegin = ""
docend = ""
for src in source:
src_path = str(src)
if not src_path.endswith(".xml"):
continue
with open(src_path, "r", encoding="utf-8") as f:
content = f.read()
buf += content

buf = (docbegin + buf + docend).encode("utf-8")
decomp_size = len(buf)

# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)

g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("\n")

g.write('static const char *_doc_data_hash = "' + str(hash(buf)) + '";\n')
g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n")
g.write("static const int _doc_data_compressed_size = " + str(len(buf)) + ";\n")
g.write("static const unsigned char _doc_data_compressed[] = {\n")
for i in range(len(buf)):
g.write("\t" + str(buf[i]) + ",\n")
g.write("};\n")
g.write("\n")

g.write(
"static godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);\n"
)
g.write("\n")

g.close()

env = SConscript("godot-cpp/SConstruct")
opts = Variables([], ARGUMENTS)

Expand Down Expand Up @@ -165,6 +212,7 @@ if env["platform"] == "windows":
if env["target"] in ("editor", "template_debug"):
if env["target"] == "editor":
env["target_path"] += "editor/"
make_doc_source("src/gen/doc_data.gen.cpp", Glob("doc_classes/*.xml"), env)
else:
env["target_path"] += "debug/"

Expand Down Expand Up @@ -194,6 +242,7 @@ elif env["platform"] == "macos":
if env["target"] in ("editor", "template_debug"):
if env["target"] == "editor":
env["target_path"] += "editor/"
make_doc_source("src/gen/doc_data.gen.cpp", Glob("doc_classes/*.xml"), env)
else:
env["target_path"] += "debug/"

Expand Down Expand Up @@ -227,6 +276,7 @@ elif env["platform"] == "linux":
if env["target"] in ("editor", "template_debug"):
if env["target"] == "editor":
env["target_path"] += "editor/"
make_doc_source("src/gen/doc_data.gen.cpp", Glob("doc_classes/*.xml"), env)
else:
env["target_path"] += "debug/"

Expand Down
161 changes: 0 additions & 161 deletions addons/Wwise/native/doc/Waapi.xml

This file was deleted.

Loading
Loading