Changes post merge of JS documentation support
authorFrederic Massart <fred@moodle.com>
Wed, 5 Nov 2014 04:29:35 +0000 (12:29 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 5 Nov 2014 04:29:35 +0000 (12:29 +0800)
extra/bash_completion
mdk/commands/doctor.py
mdk/commands/js.py
mdk/config-dist.json
mdk/js.py

index 74502f8..1cb8f1d 100644 (file)
@@ -145,7 +145,10 @@ function _mdk() {
                 OPTS="--plugin --module"
                 case "$PREV" in
                     js)
-                        OPTS="shift"
+                        OPTS="doc shift"
+                        ;;
+                    doc)
+                        OPTS="$(_list_instances)"
                         ;;
                     *)
                         if [[ "$CUR" != -* ]]; then
index d80d395..cb3da5c 100644 (file)
@@ -226,7 +226,7 @@ class DoctorCommand(Command):
 
         # 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)
index 5b99229..fe486c3 100644 (file)
@@ -109,7 +109,7 @@ class JsCommand(Command):
     def run(self, args):
         if args.mode == 'shift':
             self.shift(args)
-        if args.mode == 'doc':
+        elif args.mode == 'doc':
             self.document(args)
 
 
@@ -181,16 +181,13 @@ class JsCommand(Command):
         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):
index cf33435..541e914 100644 (file)
     // 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,
 
index 66c899d..f480671 100644 (file)
--- a/mdk/js.py
+++ b/mdk/js.py
@@ -62,12 +62,13 @@ class Js(object):
             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"""
@@ -108,10 +109,10 @@ class Shifter(object):
     def setCwd(self, cwd):
         self._cwd = cwd
 
+
 class Documentor(object):
 
     _cwd = None
-
     _outdir = None
 
     def __init__(self, cwd=None, outdir=None):
@@ -126,13 +127,9 @@ class Documentor(object):
 
         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