forked from guillermooo/dart-sublime-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docgen.py
66 lines (51 loc) · 1.94 KB
/
docgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) 2014, Guillermo López-Anglada. Please see the AUTHORS file for details.
# All rights reserved. Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.)
import sublime
import sublime_plugin
import os
from Dart.lib.pub_package import find_pubspec
# TODO(guillermooo): This process cannot be killed with DartStopAll.
class DartGenerateDocsCommand(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
if not view:
return
if not view.file_name():
return
path = find_pubspec(view.file_name())
if not path:
return
path = os.path.dirname(path)
cmd = ["docgen", "--no-include-sdk", path]
if sublime.platform() == 'windows':
cmd = ["docgen.bat", "--no-include-sdk", path]
elif sublime.platform() == 'osx':
cmd = ["/bin/bash", "--login", "-c",
"docgen --no-include-sdk " + path]
self.window.run_command('exec', {
"cmd": cmd,
"working_dir": path,
})
# TODO(guillermooo): This process cannot be killed with DartStopAll.
class DartServeDocsCommand(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
if not view:
return
if not view.file_name():
return
path = find_pubspec(view.file_name())
if not path:
return
path = os.path.dirname(path)
cmd = ["docgen", "--no-include-sdk", "--serve", path]
if sublime.platform() == 'windows':
cmd = ["docgen.bat", "--no-include-sdk", "--serve", path]
elif sublime.platform() == 'osx':
cmd = ["/bin/bash", "--login", "-c",
"docgen --no-include-sdk --serve " + path]
self.window.run_command('exec', {
"cmd": cmd,
"working_dir": path,
})