From 78b71c6f6e18b36940680cdf857f93fc8fe8f498 Mon Sep 17 00:00:00 2001 From: wiggin77 Date: Thu, 1 Mar 2018 16:20:38 -0500 Subject: [PATCH] fix issue 23 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- src/wiggin/codedox/Commenter.hx | 13 ++++++------- test/.vscode/settings.json | 12 ++++++------ test/Test.hx | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd72a8..1d7a9b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Codedox change log +## 1.2.6 + +* Added `fname`, `fspec`, `frel` parameters; see [issue 23](https://github.com/vshaxe/codedox/issues/23) +* Allow params in any part of method comment + ## 1.2.5 * Travis-CI integraton @@ -9,7 +14,7 @@ ## 1.2.4 * Repo moved to [vshaxe](https://github.com/vshaxe) organization -* Fix [issue 16](https://github.com/vshaxe/codedox/issues/16) support newlines in commentdescription, paramFormat, returnFormat +* Fix [issue 16](https://github.com/vshaxe/codedox/issues/16) support newlines in comment description, paramFormat, returnFormat * New config option `alwaysMultiline:true`. If true then all comments are multiline, otherwise non-functions (types) are single line * OnEnter rules dynamically generated for custom configs * Fix [issue 12](https://github.com/vshaxe/codedox/issues/12) Spaces added for non-function docs diff --git a/package.json b/package.json index ce12028..42b5c92 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "codedox", "displayname": "Codedox for Haxe", "description": "JSDoc-style comments for Haxe. @param and @return tags, plus customizable file header license and copyright comments.", - "version": "1.2.5", + "version": "1.2.6", "publisher": "wiggin77", "license": "(MIT) View license in LICENSE.md", "engines": { diff --git a/src/wiggin/codedox/Commenter.hx b/src/wiggin/codedox/Commenter.hx index 405c534..8ff8f0c 100644 --- a/src/wiggin/codedox/Commenter.hx +++ b/src/wiggin/codedox/Commenter.hx @@ -192,6 +192,7 @@ class Commenter { var strIndent = info.strIndent; var strPrefix = settings.strCommentPrefix; + var map = new Map(); var sb = new StringBuf(); sb.add(strIndent); @@ -219,23 +220,21 @@ class Commenter var mapP = ["name" => item.name, "type" => item.type]; ParamUtil.addDefaultParams(mapP); var strP = ParamUtil.applyParams(settings.strParamFormat, mapP); - composeCommentLines(sb, strP, strIndent, strPrefix); } } if(StringUtil.hasChars(info.retType) && info.retType != "Void" && StringUtil.hasChars(settings.strReturnFormat)) { - var mapR = ["type" => info.retType]; - ParamUtil.addDefaultParams(mapR); - var strR = ParamUtil.applyParams(settings.strReturnFormat, mapR); - - composeCommentLines(sb, strR, strIndent, strPrefix); + map.set("type", info.retType); + composeCommentLines(sb, settings.strReturnFormat, strIndent, strPrefix); } sb.add(info.strIndent); sb.add(settings.strCommentEnd); sb.add("\n"); - return sb.toString(); + + ParamUtil.addDefaultParams(map); + return ParamUtil.applyParams(sb.toString(), map); } /** diff --git a/test/.vscode/settings.json b/test/.vscode/settings.json index 330d2d1..ed381b6 100644 --- a/test/.vscode/settings.json +++ b/test/.vscode/settings.json @@ -15,8 +15,8 @@ ], // Codedox settings "codedox": { - //"paramFormat": "\n@param {${type}} ${name} - \n", - //"returnFormat": "\n@return ${type}\n", + "paramFormat": "${fname} - @param {${type}} ${name} - ", + //"returnFormat": "@return ${type}", //"alwaysMultiline": false, //"commentbegin": "/**", @@ -25,7 +25,7 @@ //"headerbegin": "/**", //"headerprefix": " ", //"headerend": "**/", - "commentdescription": "[Description]\n", + "commentdescription": "${fname} - [Description]\n", "fileheader": { "params": { @@ -35,9 +35,9 @@ }, "templates": { "*": [ - "${fname}\n", - "${fspec}\n", - "${frel}\n", + "// ${fname}", + "// ${fspec}", + "// ${frel}", "${license_mit}" ] } diff --git a/test/Test.hx b/test/Test.hx index 5976f27..e0681de 100644 --- a/test/Test.hx +++ b/test/Test.hx @@ -9,7 +9,7 @@ class Test trace(getMessage("Hello", 2)); } - private static function getMessage(str:String, num:Int) : String + private static function getMessage(str:String, num:Int) : String { return "message: " + str + num; }