Commits

Johannes Emerich committed 5ad3f8e Draft

Add configuration to use the requirejs parser

Comments (0)

Files changed (3)

coffeedomain/README.rst

 
   coffee_src_dir = os.path.abspath('../')
 
+Depending on the module system you use, you might want to change the coffeedoc
+parser from its default ``commonjs`` to ``requirejs``::
+
+  coffee_src_parser = 'requirejs'
+
 Finally, if your project is primarily CoffeeScript, you might want to
 define the primary domain as well::
 

coffeedomain/sphinxcontrib/coffeedomain/__init__.py

 def setup(app):
     app.add_config_value('coffee_src_dir', None, 'env')
+    app.add_config_value('coffee_src_parser', None, 'env')
     from .domain import CoffeeDomain
     app.add_domain(CoffeeDomain)
     from . import documenters as doc

coffeedomain/sphinxcontrib/coffeedomain/documenters.py

         filename= self.modname + '.coffee'
         modules = self.env.temp_data.setdefault('coffee:docgen', {})
         basedir = self.env.config.coffee_src_dir
+        parser  = self.env.config.coffee_src_parser or 'commonjs'
         if filename not in modules:
-            docgen = Popen(['coffeedoc', '--stdout', '--renderer', 'json',
-                            filename],
+            gencmd = ['coffeedoc', '--stdout', '--renderer', 'json', '--parser',
+                      parser, filename]
+            docgen = Popen(gencmd,
                            cwd=basedir, stdout=PIPE)
             module_data = json.load(docgen.stdout)[0]['module']
-            print "ran coffeedoc --stdout --renderer json %s" % filename
+            print "ran %s" % ' '.join(gencmd)
             modules[filename] = StubObject('module', module_data)
         return modules[filename]