Skip to content

Commit ba2ba2d

Browse files
committed
Merge pull request #3 from adambullmer/parser-improvements
Enhance Parser
2 parents b4034a7 + f413969 commit ba2ba2d

File tree

12 files changed

+1007
-620
lines changed

12 files changed

+1007
-620
lines changed

DocblockrPython.py

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,14 @@
1-
import importlib
2-
31
import sublime
42

5-
from docblockr_python.formatters.registry import registry
3+
from docblockr_python.formatters.registry import populate_registry
64

75
plugin_is_loaded = False
86

9-
def get_formatter(formatter):
10-
try:
11-
temp = importlib.import_module('docblockr_python.formatters.{}'.format(formatter))
12-
Formatter = getattr(temp, '{}Formatter'.format(formatter.capitalize()))
13-
return Formatter
14-
except ImportError as exception:
15-
print(exception)
16-
except AttributeError as exception:
17-
raise ValueError('Formatter {} doesn\'t exist'.format(formatter)) from exception
18-
19-
20-
def get_setting(key, default=None):
21-
"""Gets the passed setting from the aggregated settings files.
22-
23-
Merges up settings as specified in Sublime's docs.
24-
https://www.sublimetext.com/docs/3/settings.html
25-
26-
Arguments:
27-
key {str} -- String of the key to get
28-
29-
Keyword Arguments:
30-
default {str} -- default value in case the setting is not found (default: None)
31-
32-
Returns:
33-
{str} or {None} -- value of the setting
34-
"""
35-
settings = sublime.load_settings('DocblockrPython.sublime-settings')
36-
os_specific_settings = {}
37-
38-
os_name = sublime.platform()
39-
if os_name == 'osx':
40-
os_specific_settings = sublime.load_settings('DocblockrPython (OSX).sublime-settings')
41-
elif os_name == 'windows':
42-
os_specific_settings = sublime.load_settings('DocblockrPython (Windows).sublime-settings')
43-
else:
44-
os_specific_settings = sublime.load_settings('DocblockrPython (Linux).sublime-settings')
45-
46-
return os_specific_settings.get(key, settings.get(key, default))
47-
487

498
def plugin_loaded():
50-
"""The ST3 entry point for plugins."""
9+
"""The Sublime Text 3 entry point for plugins."""
10+
populate_registry()
11+
5112
global plugin_is_loaded
5213
plugin_is_loaded = True
5314

0 commit comments

Comments
 (0)