Browse Source

Add doc comment on ToC constructor

master
buttercat1791 10 months ago
parent
commit
f9048c468c
  1. 10
      src/lib/components/publications/table_of_contents.svelte.ts

10
src/lib/components/publications/table_of_contents.svelte.ts

@ -7,12 +7,22 @@ export interface TocEntry {
children: Array<TocEntry> | null; children: Array<TocEntry> | null;
} }
// TODO: Include depth in the `TocEntry` interface, and compute it when adding entries to the ToC.
export class TableOfContents { export class TableOfContents {
#tocRoot: TocEntry | null = null; #tocRoot: TocEntry | null = null;
#addresses = $state<Map<string, TocEntry>>(new Map()); #addresses = $state<Map<string, TocEntry>>(new Map());
#publicationTree: PublicationTree; #publicationTree: PublicationTree;
#pagePathname: string; #pagePathname: string;
/**
* Constructor for the `TableOfContents` class. The constructed ToC initially contains only the
* root entry. Additional entries must be inserted programmatically using class methods.
*
* The `TableOfContents` class should be instantiated as a page-scoped singleton so that
* `pagePathname` is correct wherever the instance is used. The singleton should be made
* made available to the entire component tree under that page.
*/
constructor(rootAddress: string, publicationTree: PublicationTree, pagePathname: string) { constructor(rootAddress: string, publicationTree: PublicationTree, pagePathname: string) {
// TODO: Build out the root entry correctly. // TODO: Build out the root entry correctly.
this.#tocRoot = { this.#tocRoot = {

Loading…
Cancel
Save