diff --git a/index.js b/index.js index 792958c..ce276b9 100644 --- a/index.js +++ b/index.js @@ -29402,6 +29402,7 @@ var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib); `${dir}/${name}`, ).then( (buffer) => ({ + file: `${dir}/${name}`, name: external_path_default().basename(name, '.xml').toLowerCase(), buffer, }), @@ -29863,6 +29864,7 @@ const findDisplay = (line, link) => { fileName, myDisplayFields, display, + xml, }) => { await external_fs_.promises.appendFile( fileName, @@ -29876,26 +29878,47 @@ const findDisplay = (line, link) => { (animated) => () => external_fs_.promises.appendFile( fileName, `\n### ${animated.name}\n\n *${animated.type}*\n`, - ).then( - () => animations({ - fileName, - animations: animated - .animations(), - }), - ).then( - () => connections({ - fileName, - connections: animated - .connections(), - }), - ).then( - () => command({ - fileName, - command: animated - .command(), - link: './', - }), ) + .then( + () => { + const l1 = animated.xml().split(/\r?\n/)[0]; + const l = xml.split(/\r?\n/) + .reduce( + (acc, line, index) => { + if (line.indexOf(l1) > -1) { + return index; + } + return acc; + }, + -1, + ); + return external_fs_.promises.appendFile( + fileName, + `\n[xml](${'../'.repeat(fileName.split('/').length)}${display.file}#L${l + 1})\n`, + ); + }, + ) + .then( + () => animations({ + fileName, + animations: animated + .animations(), + }), + ).then( + () => connections({ + fileName, + connections: animated + .connections(), + }), + ) + .then( + () => command({ + fileName, + command: animated + .command(), + link: './', + }), + ) .then( () => touch({ fileName, @@ -29903,12 +29926,6 @@ const findDisplay = (line, link) => { .touch(), link: './', }), - ) - .then( - () => external_fs_.promises.appendFile( - fileName, - `\n#### xml\n\n\`\`\`xml\n${animated.xml()}\n\`\`\`\n`, - ), ), ), ); @@ -30029,6 +30046,10 @@ const findDisplay = (line, link) => { fileName, `# ${display.name}\n\n*display*\n`, ); + await external_fs_.promises.appendFile( + fileName, + `\n[xml](${'../'.repeat(root.split('/').length)}${display.file})\n`, + ); await reference_objects({ fileName, @@ -30039,6 +30060,7 @@ const findDisplay = (line, link) => { fileName, display, myDisplayFields, + xml: display.xml(), }); await display_references({ fileName, @@ -30056,10 +30078,6 @@ const findDisplay = (line, link) => { display, myDisplayFields, }); - await external_fs_.promises.appendFile( - fileName, - `\n## xml\n\n\`\`\`xml\n${display.xml()}\n\`\`\`\n`, - ); }), ); }); @@ -30183,6 +30201,8 @@ var ft_view_fields_build = __nccwpck_require__(3204); // dir, // myGlobalFields, object, + line: objectLine, + file, }) => { await external_fs_.promises.appendFile( fileName, @@ -30201,26 +30221,45 @@ var ft_view_fields_build = __nccwpck_require__(3204); fileName, `\n### ${animated.id} - ${animated.name} - ${animated.type}\n`, ).then( - () => animations({ - fileName, - animations: animated - .animations(), - }), - ).then( - () => connections({ - fileName, - connections: animated - .connections(), - }), - ).then( - () => command({ - fileName, - command: animated - .command(), - link: '../../displays/', - - }), + () => { + const l1 = animated.xml().split(/\r?\n/)[0]; + const l = object.xml().split(/\r?\n/) + .reduce( + (acc, line, index) => { + if (line.indexOf(l1) > -1) { + return index; + } + return acc; + }, + -1, + ); + return external_fs_.promises.appendFile( + fileName, + `\n[xml](${'../'.repeat(fileName.split('/').length)}${file}#L${objectLine + l})\n`, + ).then(l + 1); + }, ) + .then( + () => animations({ + fileName, + animations: animated + .animations(), + }), + ).then( + () => connections({ + fileName, + connections: animated + .connections(), + }), + ).then( + () => command({ + fileName, + command: animated + .command(), + link: '../../displays/', + + }), + ) .then( () => touch({ fileName, @@ -30228,12 +30267,6 @@ var ft_view_fields_build = __nccwpck_require__(3204); .touch(), link: '../../displays/', }), - ) - .then( - () => external_fs_.promises.appendFile( - fileName, - `\n#### xml\n\n\`\`\`xml\n${object.xml()}\n\`\`\`\n`, - ), ), ), ); @@ -30273,28 +30306,44 @@ var ft_view_fields_build = __nccwpck_require__(3204); `${dir}/${object.id}.md`, `# ${object.id}\n\n*object*\n`, ).then( - () => objects_parameters({ - fileName: `${dir}/${object.id}.md`, - object, - }), - ).then( - () => references({ - fileName: `${dir}/${object.id}.md`, - object, - displays, - myDisplayFields, - }), - ).then( - () => animated({ - fileName: `${dir}/${object.id}.md`, - object, - }), + () => { + const l1 = object.xml().split(/\r?\n/)[0]; + const l = global.xml().split(/\r?\n/) + .reduce( + (acc, line, index) => { + if (line.indexOf(l1) > -1) { + return index; + } + return acc; + }, + -1, + ); + return external_fs_.promises.appendFile( + fileName, + `\n[xml](${'../'.repeat(fileName.split('/').length)}${global.file}#L${l + 1})\n`, + ).then(l + 1); + }, ) .then( - () => external_fs_.promises.appendFile( - `${dir}/${object.id}.md`, - `\n## xml\n\n\`\`\`xml\n${object.xml()}\n\`\`\`\n`, - ), + (l) => objects_parameters({ + fileName: `${dir}/${object.id}.md`, + object, + }).then( + () => references({ + fileName: `${dir}/${object.id}.md`, + object, + displays, + myDisplayFields, + }), + ) + .then( + () => animated({ + file: object.file, + line: l, + fileName: `${dir}/${object.id}.md`, + object, + }), + ), ), ), ), @@ -30334,6 +30383,7 @@ var ft_view_fields_build = __nccwpck_require__(3204); ); await Promise.all( globals.map(async (global) => { + console.log(global.file); await external_fs_.promises.appendFile( `${root}/globals/README.md`, `* [${global.name}](./${global.name})\n`, @@ -30371,7 +30421,7 @@ var ft_view_fields_build = __nccwpck_require__(3204); -/* harmony default export */ const src_document = ((root) => async ({ +/* harmony default export */ const src_document = (({ root }) => async ({ displays, globals, }) => { @@ -30418,14 +30468,27 @@ var ft_view_fields_build = __nccwpck_require__(3204); +const displayFolder = process.env.DISPLAYFOLDER || core.getInput('display-folder'); +const displayExcludeFile = process.env.DISPLAYEXCLUDEFILE || core.getInput('display-exclude-file'); +const root = process.env.FOLDER || core.getInput('folder'); +const globalFolder = process.env.GLOBALFOLDER || core.getInput('global-folder'); +const globalExcludeFile = process.env.GLOBALEXCLUDEFILE || core.getInput('global-exclude-file'); + +console.log({ + displayFolder, + displayExcludeFile, + folder: root, + globalFolder, + globalExcludeFile, +}); data({ - dir: process.env.DISPLAYFOLDER || core.getInput('display-folder'), - exclude: process.env.DISPLAYEXCLUDEFILE || core.getInput('display-exclude-file'), + dir: displayFolder, + exclude: displayExcludeFile, }) .then( (displays) => data({ - dir: process.env.GLOBALFOLDER || core.getInput('global-folder'), - exclude: process.env.GLOBALEXCLUDEFILE || core.getInput('global-exclude-file'), + dir: globalFolder, + exclude: globalExcludeFile, }) .then( (globals) => ({ @@ -30434,7 +30497,11 @@ data({ }), ), ) - .then(src_document(process.env.FOLDER || core.getInput('folder'))) + .then(src_document({ + root, + displayFolder, + globalFolder, + })) .then( () => console.log('done'), )