Skip to content

Commit

Permalink
Create an "Editor-only" section in the online class reference
Browse files Browse the repository at this point in the history
This helps to find such classes without digging
through the rest of the class reference.
Editor-only classes can still be found under
your normal "Node" and "Resource" types.

This also fixes a typo and a missed case from the recent platform docs PR.
  • Loading branch information
YuriSizov committed Apr 24, 2023
1 parent 14c582b commit 3ae282b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Documentation checks
run: |
doc/tools/make_rst.py --dry-run --color doc/classes modules platforms
doc/tools/make_rst.py --dry-run --color doc/classes modules platform
- name: Style checks via clang-format (clang_format.sh)
run: |
Expand Down
30 changes: 30 additions & 0 deletions doc/tools/make_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"Globals",
"Nodes",
"Resources",
"Editor-only",
"Other objects",
"Variant types",
"Description",
Expand Down Expand Up @@ -74,13 +75,23 @@
"node": "Nodes",
"resource": "Resources",
"object": "Other objects",
"editor": "Editor-only",
"variant": "Variant types",
}
CLASS_GROUPS_BASE: Dict[str, str] = {
"node": "Node",
"resource": "Resource",
"object": "Object",
"variant": "Variant",
}
# Sync with editor\register_editor_types.cpp
EDITOR_CLASSES: List[str] = [
"AnimationTrackEditPlugin",
"FileSystemDock",
"ScriptCreateDialog",
"ScriptEditor",
"ScriptEditorBase",
]


class State:
Expand Down Expand Up @@ -635,6 +646,11 @@ def main() -> None:
grouped_classes[group_name] = []
grouped_classes[group_name].append(class_name)

if is_editor_class(class_def):
if "editor" not in grouped_classes:
grouped_classes["editor"] = []
grouped_classes["editor"].append(class_name)

print("")
print("Generating the index file...")

Expand Down Expand Up @@ -724,6 +740,17 @@ def get_class_group(class_def: ClassDef, state: State) -> str:
return group_name


def is_editor_class(class_def: ClassDef) -> bool:
class_name = class_def.name

if class_name.startswith("Editor"):
return True
if class_name in EDITOR_CLASSES:
return True

return False


# Generator methods.


Expand Down Expand Up @@ -1472,6 +1499,9 @@ def make_rst_index(grouped_classes: Dict[str, List[str]], dry_run: bool, output_
f.write(f" class_{CLASS_GROUPS_BASE[group_name].lower()}\n")

for class_name in grouped_classes[group_name]:
if group_name in CLASS_GROUPS_BASE and CLASS_GROUPS_BASE[group_name].lower() == class_name.lower():
continue

f.write(f" class_{class_name.lower()}\n")

f.write("\n")
Expand Down
2 changes: 1 addition & 1 deletion misc/hooks/pre-commit-make-rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ if [[ "$py_ver" != "3" ]]; then
PYTHON+=3
fi

$PYTHON doc/tools/make_rst.py doc/classes modules --dry-run --color
$PYTHON doc/tools/make_rst.py doc/classes modules platform --dry-run --color

0 comments on commit 3ae282b

Please sign in to comment.