Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option to remove/amend start indentation space #435

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Base File.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
23 changes: 12 additions & 11 deletions jsdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -616,7 +617,7 @@ def setupSettings(self):
+ '|'
+ '(?:' + identifier + r'\s*\(.*\)\s*\{)'
+ ')',
"commentCloser": " */",
"commentCloser": "*/",
"bool": "Boolean",
"function": "Function"
}
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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*\\(',
Expand Down Expand Up @@ -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*\\(',
Expand Down Expand Up @@ -1071,7 +1072,7 @@ def setupSettings(self):
"varIdentifier": identifier,
"fnIdentifier": identifier,
"fnOpener": '^\s*[-+]',
"commentCloser": " */",
"commentCloser": "*/",
"bool": "Boolean",
"function": "Function"
}
Expand Down Expand Up @@ -1155,7 +1156,7 @@ def setupSettings(self):
"varIdentifier": identifier,
"fnIdentifier": identifier,
"fnOpener": identifier + '(?:\\s+' + identifier + ')?\\s*\\(',
"commentCloser": " */",
"commentCloser": "*/",
"bool": "Boolean",
"function": "Function"
}
Expand Down Expand Up @@ -1277,7 +1278,7 @@ def setupSettings(self):
"varIdentifier": ".*",
"fnIdentifier": ".*",
"fnOpener": "^\s*fn",
"commentCloser": " */",
"commentCloser": "*/",
"bool": "Boolean",
"function": "Function"
}
Expand Down Expand Up @@ -1546,7 +1547,7 @@ def setupSettings(self):
"varIdentifier": identifier,
"fnIdentifier": identifier,
"fnOpener": 'function(?:\\s+' + identifier + ')?\\s*\\(',
"commentCloser": " */",
"commentCloser": "*/",
"bool": "Boolean",
"function": "Function",
"functionRE":
Expand Down