22
33const { crawlReference} = require ( "./crawl-reference-explorer" ) ;
44const { crawlTutorials} = require ( "./crawl-tutorials" ) ;
5- const { traverse } = require ( "@webdoc/model" ) ;
5+ const model = require ( "@webdoc/model" ) ;
66const { linker} = require ( "../linker" ) ;
77
88// This file crawls the document tree to:
@@ -15,6 +15,10 @@ import type {
1515 DocType,
1616} from "@webdoc/types";
1717
18+ import type {
19+ LinkTable,
20+ } from "@webdoc/template-library";
21+
1822import type {ExplorerTarget} from './crawl-reference-explorer';
1923
2024export type CategorizedDocumentList = {
@@ -63,18 +67,22 @@ function crawl(tree /*: RootDoc */, index /*: string */)/*: CrawlData */ {
6367
6468module . exports = ( { crawl} /*: {crawl: typeof crawl} */ ) ;
6569
66- function buildLinks ( tree /*: RootDoc */ ) /*: void */ {
67- traverse ( tree , ( doc ) => {
70+ function buildLinks ( tree /*: RootDoc */ ) /*: LinkTable */ {
71+ const linkTable = { } ;
72+
73+ model . traverse ( tree , ( doc ) => {
6874 if ( doc . type === "RootDoc" ) {
6975 doc . packages . forEach ( ( packageDoc ) => {
70- linker . getURI ( packageDoc ) ;
76+ linkTable [ packageDoc . path ] = linker . getURI ( packageDoc ) ;
7177 } ) ;
7278
7379 return ;
7480 }
7581
76- linker . getURI ( doc ) ;
82+ linkTable [ doc . path ] = linker . getURI ( doc ) ;
7783 } ) ;
84+
85+ return linkTable ;
7886}
7987
8088function buildIndex (
@@ -86,7 +94,7 @@ function buildIndex(
8694 classes : Object . assign ( ( [ ] /*: any */ ) , { url : classIndexUrl } ) ,
8795 } ;
8896
89- traverse ( tree , ( doc ) => {
97+ model . traverse ( tree , ( doc ) => {
9098 switch ( doc . type ) {
9199 case "ClassDoc" :
92100 index . classes . push ( doc ) ;
0 commit comments