@@ -18,39 +18,40 @@ let crossRefIndex: Map<string, CrossRefTarget> | null = null;
1818
1919/**
2020 * Build the cross-reference index from all API data
21+ * Paths are stored as absolute (starting with /) for single source of truth
2122 */
2223function buildCrossRefIndex ( ) : Map < string , CrossRefTarget > {
2324 const index = new Map < string , CrossRefTarget > ( ) ;
2425
2526 for ( const [ packageId , pkg ] of Object . entries ( apiData ) ) {
26- const basePath = `${ packageId } /api` ;
27+ // Absolute path from site root
28+ const apiPath = `/${ packageId } /api` ;
2729
2830 for ( const [ moduleName , module ] of Object . entries ( pkg . modules ) ) {
2931 // Add module
30- const moduleShortName = moduleName . split ( '.' ) . pop ( ) || moduleName ;
3132 index . set ( moduleName , {
3233 name : moduleName ,
3334 type : 'module' ,
3435 packageId,
3536 moduleName,
36- path : `${ basePath } #${ moduleName . replace ( / \. / g, '-' ) } `
37+ path : `${ apiPath } #${ moduleName . replace ( / \. / g, '-' ) } `
3738 } ) ;
3839
3940 // Add classes
4041 for ( const cls of module . classes ) {
4142 // Full path: pathsim.blocks.integrator.Integrator
42- const fullPath = `${ moduleName } .${ cls . name } ` ;
43+ const fullModulePath = `${ moduleName } .${ cls . name } ` ;
4344 const target : CrossRefTarget = {
4445 name : cls . name ,
4546 type : 'class' ,
4647 packageId,
4748 moduleName,
48- path : `${ basePath } #${ cls . name } `
49+ path : `${ apiPath } #${ cls . name } `
4950 } ;
5051
5152 // Index by multiple keys for flexible lookup
5253 index . set ( cls . name , target ) ; // Just class name
53- index . set ( fullPath , target ) ; // Full path
54+ index . set ( fullModulePath , target ) ; // Full path
5455 index . set ( `${ packageId } .${ cls . name } ` , target ) ; // package.ClassName
5556
5657 // Add methods
@@ -63,7 +64,7 @@ function buildCrossRefIndex(): Map<string, CrossRefTarget> {
6364 packageId,
6465 moduleName,
6566 parentClass : cls . name ,
66- path : `${ basePath } #${ method . name } `
67+ path : `${ apiPath } #${ method . name } `
6768 } ;
6869
6970 // Index by ClassName.method_name
@@ -73,17 +74,17 @@ function buildCrossRefIndex(): Map<string, CrossRefTarget> {
7374
7475 // Add functions
7576 for ( const func of module . functions ) {
76- const fullPath = `${ moduleName } .${ func . name } ` ;
77+ const fullModulePath = `${ moduleName } .${ func . name } ` ;
7778 const target : CrossRefTarget = {
7879 name : func . name ,
7980 type : 'function' ,
8081 packageId,
8182 moduleName,
82- path : `${ basePath } #${ func . name } `
83+ path : `${ apiPath } #${ func . name } `
8384 } ;
8485
8586 index . set ( func . name , target ) ;
86- index . set ( fullPath , target ) ;
87+ index . set ( fullModulePath , target ) ;
8788 }
8889 }
8990 }
@@ -121,11 +122,9 @@ export function lookupRef(name: string): CrossRefTarget | undefined {
121122export function processCrossRefs ( html : string , basePath : string = '' , currentPackageId ?: string ) : string {
122123 const index = getCrossRefIndex ( ) ;
123124
124- // Helper to build full path with base - ensure it starts with /
125- const fullPath = ( path : string ) => {
126- const full = `${ basePath } /${ path } ` ;
127- return full . startsWith ( '/' ) ? full : `/${ full } ` ;
128- } ;
125+ // Helper to build full URL: basePath (deployment prefix) + path (absolute from site root)
126+ // path is already absolute like /pathsim/api#ClassName
127+ const fullPath = ( path : string ) => `${ basePath } ${ path } ` ;
129128
130129 // 1. Handle RST role syntax: :class:`Name`, :func:`Name`, :meth:`Name`, :mod:`Name`
131130 // These often get converted to various forms by docutils
0 commit comments