OPTS="--plugin --module"
case "$PREV" in
js)
- OPTS="shift"
+ OPTS="doc shift"
+ ;;
+ doc)
+ OPTS="$(_list_instances)"
;;
*)
if [[ "$CUR" != -* ]]; then
# Check binaries.
hasErrors = False
- for k in ['git', 'php', 'java', 'recess', 'lessc']:
+ for k in ['git', 'php', 'java', 'recess', 'lessc', 'shifter', 'yuidoc']:
path = self.C.get(k)
if not path or not os.path.isfile(path):
print ' The path to \'%s\' is invalid: %s' % (k, path)
def run(self, args):
if args.mode == 'shift':
self.shift(args)
- if args.mode == 'doc':
+ elif args.mode == 'doc':
self.document(args)
if len(Mlist) < 1:
raise Exception('No instances to work on. Exiting...')
- cwd = os.path.realpath(os.path.abspath(os.getcwd()))
- mpath = Mlist[0].get('path')
- relpath = cwd.replace(mpath, '').strip('/')
-
for M in Mlist:
- if len(Mlist) > 1:
- logging.info('Let\'s document everything you wanted on \'%s\'' % (M.get('identifier')))
-
+ logging.info('Documenting everything you wanted on \'%s\'. This may take a while...', M.get('identifier'))
+ outdir = self.Wp.getExtraDir(M.get('identifier'), 'jsdoc')
+ outurl = self.Wp.getUrl(M.get('identifier'), extra='jsdoc')
processor = js.Js(M)
- processor.document(self.Wp.getPath(M.get('identifier'), 'jsdocdir'))
+ processor.document(outdir)
+ logging.info('Documentation available at:\n %s\n %s', outdir, outurl)
class JsShiftWatcher(watchdog.events.FileSystemEventHandler):
// Path to shifter
"shifter": "/usr/bin/shifter",
// Path to yuidoc
- "yuidoc": "/usr/bin/yuidoc",
+ "yuidoc": "/usr/local/bin/yuidoc",
// Path to your favourite editor. Set to null to guess it from the System environment.
"editor": null,
shifter.setCwd(path)
shifter.compile()
- def document(self, outdir=None):
+ def document(self, outdir):
"""Runs documentator"""
+ # TODO We should be able to generate outdir from here, using the workplace.
path = self._M.get('path')
documentor = Documentor(path, outdir)
- documentor.compile();
+ documentor.compile()
def getYUISrcPath(self, subsystemOrPlugin, module=None):
"""Returns the path to the module, or the component"""
def setCwd(self, cwd):
self._cwd = cwd
+
class Documentor(object):
_cwd = None
-
_outdir = None
def __init__(self, cwd=None, outdir=None):
cmd = [executable, '--outdir', self._outdir]
- logging.info("Generating YUI documentation to %s. This may take a while" % self._outdir)
(code, out, err) = process(cmd, cwd=self._cwd)
if code != 0:
raise YuidocCompileFailed('Error whilst generating documentation')
- else:
- logging.info('Documentation generation complete. Take a peek at %s'
- % self._outdir)
def setCwd(self, cwd):
self._cwd = cwd