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

Fix poor documentation formatting of class titles and inheritance chain #628

Merged
merged 5 commits into from
Apr 17, 2024
Merged
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
26 changes: 7 additions & 19 deletions src/providers/documentation_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,12 @@ export function make_symbol_document(symbol: GodotNativeSymbol): string {
}

if (symbol.kind == SymbolKind.Class) {
let doc = element("h2", `Native class ${symbol.name}`);
const parts = /extends\s+([A-z0-9]+)/.exec(symbol.detail);
let inherits = parts && parts.length > 1 ? parts[1] : "";
if (inherits) {
let inherits_chain = "";
let base_class = symbol.class_info[inherits];
while (base_class) {
inherits_chain += `${inherits_chain ? " >" : ""} ${make_link(
base_class.name,
undefined
)}`;
base_class = symbol.class_info[base_class.inherits];
}
inherits = `Inherits: ${inherits_chain}`;
doc += element("p", inherits);
let doc = element("h2", `Class: ${symbol.name}`);
if (symbol.class_info.inherits) {
const inherits = make_link(symbol.class_info.inherits, undefined);
doc += element("p", `Inherits: ${inherits}`);
}

if (symbol.class_info && symbol.class_info.extended_classes) {
let inherited = "";
for (const c of symbol.class_info.extended_classes) {
Expand All @@ -267,6 +257,8 @@ export function make_symbol_document(symbol: GodotNativeSymbol): string {
doc += element("p", `Inherited by:${inherited}`);
}

doc += element("p", format_documentation(symbol.documentation, symbol.native_class));

let constants = "";
let signals = "";
let methods_index = "";
Expand Down Expand Up @@ -307,10 +299,6 @@ export function make_symbol_document(symbol: GodotNativeSymbol): string {
}
};

doc += element(
"p",
format_documentation(symbol.documentation, symbol.native_class)
);
add_group("Properties", properties_index);
add_group("Constants", constants);
add_group("Signals", signals);
Expand Down
Loading