From c67fa0cb6add101cc3723ef685e5d4a987724367 Mon Sep 17 00:00:00 2001 From: Neil Barsema Date: Thu, 18 Jan 2018 11:33:54 +0100 Subject: [PATCH 1/2] Restore the fix for issue #65 originally by Ramon Esteve Cuevas that got removed by the previous revert. --- lib/pmd.js | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/pmd.js b/lib/pmd.js index 2c0eb3d..831e8b3 100644 --- a/lib/pmd.js +++ b/lib/pmd.js @@ -54,6 +54,46 @@ pmd.validatePathRef = function(fullPath, objName){ } }// validatePathRef +/** + * Parses documentation between the global name and the "is"/"as" to a readable format (above the name of the package/view/type etc + * + * @example + * create or replace test_package + * {Comment} + * is + * + * will be parsed to: + * {Comment} + * create or replace test_package is + */ +pmd.parseGlobalDescription = function(data) { + /* + regex to read the following: + create or replace test_package (force) + {Comment} + is + */ + var globalCommentRegex = /((create)[\w\s]*\s(package|type|view)\s+([\w$]+\s*(force)?)\s*)(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)(\s*(as|is|begin))/gi; + + // Check if the file contains this type of comments + if(globalCommentRegex.exec(data)) { + var comments = data.split(globalCommentRegex); + + /* comments[6] inside the array is the documentation itself, comments[1] -> create or replace {name} + Replace the following: + create or replace test_package (force) + {Comment} + is + To: + {Comment} + create or replace test_package is + */ + data = data.replace(/((create)[\w\s]*\s(package|type|view)\s+([\w$]+\s*(force)?)\s*)(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)/gi, comments[6] + "\n" + comments[1]); + } + + // Return the new data + return data; +}//parseGlobalDescription /** * Processes a PL/SQL file to extract the JavaDoc contents @@ -89,7 +129,7 @@ pmd.processFile = function(file){ debug.log('\nProcessing:', file.path); - content.data = fs.readFileSync(file.path,'utf8'); + content.data = pmd.parseGlobalDescription(fs.readFileSync(file.path,'utf8')); content.json = dox.parseComments(content.data); content.entities = []; //Holds list of entities for the object @@ -139,7 +179,7 @@ pmd.processFile = function(file){ else { // debug.log('Incorrectly parsed entry:', jsonData.code); continue; // Skip this loop since we dont know what this is - } + } jsonData.tags.forEach(function(tag){ switch (tag.type) { From f54df88678b0a183d54120d10841c23bfade8f86 Mon Sep 17 00:00:00 2001 From: Neil Barsema Date: Thu, 18 Jan 2018 11:40:19 +0100 Subject: [PATCH 2/2] TOC from markdown dit not link correctly --- templates/toc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/toc.md b/templates/toc.md index cdda86e..7c36b85 100644 --- a/templates/toc.md +++ b/templates/toc.md @@ -1,5 +1,5 @@ # {{toUpperCase projectDispName}} {{#each files}} -- [{{toUpperCase name}}]({{fileName}}) +- [{{toUpperCase name}}]({{docFileName}}) {{/each}}