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 ability to extend parser settings #344

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions jsdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ def flatten(theList):

class JsdocsCommand(sublime_plugin.TextCommand):

def run(self, edit, inline=False):
def run(self, edit, inline=False, prefix=" *", options = {}):

self.initialize(self.view, inline)

# reassign parser settings if needed
self.parser.settings.update(options);

# use another prefix if needed
self.prefix = prefix;

if self.parser.isExistingComment(self.line):
write(self.view, "\n *" + self.indentSpaces)
write(self.view, "\n" + self.prefix + self.indentSpaces)
return

# erase characters in the view (will be added to the output later)
Expand All @@ -163,7 +169,8 @@ 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.prefix = "*"

self.prefix = " *"

settingsAlignTags = self.settings.get("jsdocs_align_tags", 'deep')
self.deepAlignTags = settingsAlignTags == 'deep'
Expand Down Expand Up @@ -309,9 +316,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.prefix + (self.indentSpaces + line if line else "")
else:
snippet += "\n " + self.prefix + self.indentSpaces + "${0:" + self.trailingString + '}'
snippet += "\n" + self.prefix + self.indentSpaces + "${0:" + self.trailingString + '}'

snippet += "\n" + closer
return snippet
Expand Down