File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { writeFile } from 'node:fs/promises';
44import { join } from 'node:path' ;
55
66import getConfig from '@doc-kit/core/utils/configuration/index.mjs' ;
7+ import { populate } from '@doc-kit/core/utils/configuration/templates.mjs' ;
78
89import { legacyToJSON } from '../utils/legacyToJSON.mjs' ;
910
@@ -36,8 +37,10 @@ export async function generate(input) {
3637
3738 // Create a map of api name to index position for sorting
3839 const indexOrder = new Map (
39- config . index ?. map ( ( { api } , position ) => [ `doc/api/${ api } .md` , position ] ) ??
40- [ ]
40+ config . index ?. map ( ( { api } , position ) => [
41+ populate ( config . sourceURL , { path : `${ api } .md` } ) ,
42+ position ,
43+ ] ) ?? [ ]
4144 ) ;
4245
4346 // Sort input by index order (documents not in index go to the end)
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export default {
1818
1919 defaultConfiguration : {
2020 minify : false ,
21+ sourceURL : 'doc/api/{path}' ,
2122 } ,
2223
2324 generate,
Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ export interface Output {
1414}
1515
1616export type Generator = GeneratorMetadata <
17- { } ,
17+ { sourceURL : string } ,
1818 Generate < Array < Section > , Promise < Output > >
1919> ;
Original file line number Diff line number Diff line change @@ -22,11 +22,13 @@ const buildSection = createSectionBuilder();
2222 */
2323export async function processChunk ( slicedInput , itemIndices ) {
2424 const results = [ ] ;
25+ const config = getConfig ( 'legacy-json' ) ;
26+ const sourceURL = config . sourceURL ;
2527
2628 for ( const idx of itemIndices ) {
2729 const { head, nodes } = slicedInput [ idx ] ;
2830
29- results . push ( buildSection ( head , nodes ) ) ;
31+ results . push ( buildSection ( head , nodes , sourceURL ) ) ;
3032 }
3133
3234 return results ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export default {
2323 defaultConfiguration : {
2424 ref : 'main' ,
2525 minify : false ,
26+ sourceURL : 'doc/api/{path}' ,
2627 } ,
2728
2829 hasParallelProcessor : true ,
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ export interface MiscSection extends SectionBase {
179179}
180180
181181export type Generator = GeneratorMetadata <
182- { } ,
182+ { sourceURL : string } ,
183183 Generate < Array < MetadataEntry > , AsyncGenerator < Section > > ,
184184 ProcessChunk < { head : MetadataEntry ; nodes : Array < MetadataEntry > } , Section >
185185> ;
Original file line number Diff line number Diff line change 11import { enforceArray } from '@doc-kit/core/utils/array.mjs' ;
2+ import { populate } from '@doc-kit/core/utils/configuration/templates.mjs' ;
23import { buildHierarchy } from '@doc-kit/core/utils/hierarchy.mjs' ;
34import { getRemarkRehype as remark } from '@doc-kit/core/utils/remark.mjs' ;
45import { parseList } from '@doc-kit/core/utils/signature/parseList.mjs' ;
@@ -183,14 +184,14 @@ export const createSectionBuilder = () => {
183184 * Builds the module section from head metadata and entries.
184185 * @param {import('@doc-kit/core/generators/metadata/types').MetadataEntry } head - The head metadata entry.
185186 * @param {Array<import('@doc-kit/core/generators/metadata/types').MetadataEntry> } entries - The list of metadata entries.
187+ * @param {string } sourceURL - The template URL for the generated API source files.
186188 * @returns {import('../types.d.ts').ModuleSection } The constructed module section.
187189 */
188- return ( head , entries ) => {
190+ return ( head , entries , sourceURL ) => {
189191 const rootModule = {
190192 type : 'module' ,
191193 api : head . api ,
192- // TODO(@avivkeller): This should be configurable
193- source : `doc/api/${ head . api } .md` ,
194+ source : populate ( sourceURL , { path : `${ head . api } .md` } ) ,
194195 } ;
195196
196197 buildHierarchy ( entries ) . forEach ( node => handleEntry ( node , rootModule ) ) ;
You can’t perform that action at this time.
0 commit comments