From 8c2095626bef023853924faf093067e0f53431ed Mon Sep 17 00:00:00 2001 From: viwell Date: Sat, 11 Mar 2017 00:50:53 -0500 Subject: [PATCH] Add configuration option to remove/amend start indentation space --- Base File.sublime-settings | 10 ++++++++++ jsdocs.py | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Base File.sublime-settings b/Base File.sublime-settings index bfc179e..5bba7ac 100644 --- a/Base File.sublime-settings +++ b/Base File.sublime-settings @@ -41,6 +41,16 @@ // @property {Number} blahblah desc3 "jsdocs_align_tags": "deep", + // The number of spaces to add before the leading * in lines under the first line of each + // paragraph. For example, a value of 3 might look like this: + // /** + // * Duis sed arcu non tellus eleifend ullamcorper quis non erat. + // * @param {String} foo Lorem ipsum dolor sit amet. + // * @param {Number} bar Nullam fringilla feugiat pretium. + // * @return {[Type]} + // */ + "jsdocs_star_indentation": 1, + // Any additional boilerplate tags which should be added to each block. Should be an array of strings. // Note that this only applies when a docblock is opened directly preceding a function. // Tab points can be added by using snippet syntax, eg: ${1:default text} diff --git a/jsdocs.py b/jsdocs.py index 3f81588..fa67998 100644 --- a/jsdocs.py +++ b/jsdocs.py @@ -178,6 +178,7 @@ def initialize(self, v, inline=False): self.trailingString = escape(re.sub('\\s*\\*\\/\\s*$', '', self.trailingString)) self.indentSpaces = " " * max(0, self.settings.get("jsdocs_indentation_spaces", 1)) + self.startIndentation = " " * max(0, self.settings.get("jsdocs_star_indentation", 1)) self.prefix = "*" settingsAlignTags = self.settings.get("jsdocs_align_tags", 'deep') @@ -306,7 +307,7 @@ def swapTabs(m): def createSnippet(self, out): snippet = "" - closer = self.parser.settings['commentCloser'] + closer = self.startIndentation + self.parser.settings['commentCloser'] if out: if self.settings.get('jsdocs_spacer_between_sections') == True: lastTag = None @@ -328,9 +329,9 @@ def createSnippet(self, out): out.insert(idx, "") lastLineIsTag = True for line in out: - snippet += "\n " + self.prefix + (self.indentSpaces + line if line else "") + snippet += "\n" + self.startIndentation + self.prefix + (self.indentSpaces + line if line else "") else: - snippet += "\n " + self.prefix + self.indentSpaces + "${0:" + self.trailingString + '}' + snippet += "\n" + self.startIndentation + self.prefix + self.indentSpaces + "${0:" + self.trailingString + '}' snippet += "\n" + closer return snippet @@ -616,7 +617,7 @@ def setupSettings(self): + '|' + '(?:' + identifier + r'\s*\(.*\)\s*\{)' + ')', - "commentCloser": " */", + "commentCloser": "*/", "bool": "Boolean", "function": "Function" } @@ -764,7 +765,7 @@ def setupSettings(self): 'fnIdentifier': nameToken, 'typeIdentifier': '\\\\?' + nameToken + '(\\\\' + nameToken + ')*', 'fnOpener': 'function(?:\\s+' + nameToken + ')?\\s*\\(', - 'commentCloser': ' */', + 'commentCloser': '*/', 'bool': 'bool' if shortPrimitives else 'boolean', 'function': "function" } @@ -893,7 +894,7 @@ def setupSettings(self): 'typeInfo': False, 'curlyTypes': False, 'typeTag': 'param', - 'commentCloser': ' */', + 'commentCloser': '*/', 'fnIdentifier': identifier, 'varIdentifier': '(' + identifier + ')\\s*(?:\\[(?:' + identifier + r')?\]|\((?:(?:\s*,\s*)?[a-z]+)+\s*\))*', 'fnOpener': identifier + '\\s+' + identifier + '\\s*\\(', @@ -1014,7 +1015,7 @@ def setupSettings(self): 'typeInfo': False, 'curlyTypes': False, 'typeTag': '', - 'commentCloser': ' */', + 'commentCloser': '*/', 'fnIdentifier': nameToken, 'varIdentifier': '(%s)(?::%s)?' % (nameToken, nameToken), 'fnOpener': 'function(?:\\s+[gs]et)?(?:\\s+' + nameToken + ')?\\s*\\(', @@ -1071,7 +1072,7 @@ def setupSettings(self): "varIdentifier": identifier, "fnIdentifier": identifier, "fnOpener": '^\s*[-+]', - "commentCloser": " */", + "commentCloser": "*/", "bool": "Boolean", "function": "Function" } @@ -1155,7 +1156,7 @@ def setupSettings(self): "varIdentifier": identifier, "fnIdentifier": identifier, "fnOpener": identifier + '(?:\\s+' + identifier + ')?\\s*\\(', - "commentCloser": " */", + "commentCloser": "*/", "bool": "Boolean", "function": "Function" } @@ -1277,7 +1278,7 @@ def setupSettings(self): "varIdentifier": ".*", "fnIdentifier": ".*", "fnOpener": "^\s*fn", - "commentCloser": " */", + "commentCloser": "*/", "bool": "Boolean", "function": "Function" } @@ -1546,7 +1547,7 @@ def setupSettings(self): "varIdentifier": identifier, "fnIdentifier": identifier, "fnOpener": 'function(?:\\s+' + identifier + ')?\\s*\\(', - "commentCloser": " */", + "commentCloser": "*/", "bool": "Boolean", "function": "Function", "functionRE":