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: using split-by-submodule omits documentation for symbols in root namespace #1249

Merged
merged 1 commit into from
Dec 19, 2023
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
2 changes: 2 additions & 0 deletions src/docgen/render/markdown-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export class MarkdownRenderer {
public visitSubmodules(submodules: readonly reflect.Submodule[], fileSuffix: string): MarkdownDocument {
const md = new MarkdownDocument({ header: { title: 'Submodules' }, id: 'submodules' });
md.lines('The following submodules are available:');
md.lines('');
for (const submodule of submodules) {
md.lines(`- [${submoduleRelName(submodule)}](./${submoduleRelName(submodule)}.${fileSuffix})`);
}
md.lines('');
return md;
}

Expand Down
32 changes: 30 additions & 2 deletions src/docgen/view/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,40 @@ export class Documentation {

public async toIndexMarkdown(fileSuffix:string, options: RenderOptions) {
const assembly = await this.createAssembly(undefined, { loose: true, validate: false });

return MarkdownRenderer.fromSubmodules(await this.listSubmodules(), fileSuffix, {
const submodules = await this.listSubmodules();
const schema = (await this.toJson({
...options,
submodule: undefined,
allSubmodules: false,
})).content;

const ref = new MarkdownDocument({ header: { title: 'API Reference' }, id: 'api-reference' });

if (schema.version !== CURRENT_SCHEMA_VERSION) {
throw new Error(`Unexpected schema version: ${schema.version}`);
}

const renderer = new MarkdownRenderer({
language: options.language,
packageName: assembly.name,
packageVersion: assembly.version,
});

if (submodules.length) {
ref.section(renderer.visitSubmodules(submodules, fileSuffix));
}

if (schema.apiReference) {
ref.section(renderer.visitConstructs(schema.apiReference.constructs));
ref.section(renderer.visitStructs(schema.apiReference.structs));
ref.section(renderer.visitClasses(schema.apiReference.classes));
ref.section(renderer.visitInterfaces(schema.apiReference.interfaces));
ref.section(renderer.visitEnums(schema.apiReference.enums));
}

const documentation = new MarkdownDocument();
documentation.section(ref);
return documentation;
}

/**
Expand Down
Loading