0

I'm afraid this will a question for a very particular case. At university we have been told to generate documentation by using pydoc. The problem is that we need to create it for a Maya script, and pydoc yells when it finds import maya.cmds as cmds

So, I tried to comment this line but I keep getting errors:

python C:\Python27\Lib\pydoc.py Script.py    
problem in Script - <type 'exceptions.NameError'>: global name 'cmds' is not defined

I also tried Script, without the extension .py but it's silly doing that, we still running around the same issue.

Does anybody know how to generate documentation for Maya scripts, where import maya only works in the maya interpreter?

5
  • 1
    I edited your question to be less specific to maya, and deal more with the general case, in hopes of attracting a wider audience. Feel free to roll back my edit if you prefer your original wording Commented Apr 8, 2014 at 0:09
  • @mhlester Thanks so much! You did a very nice job for me haha Commented Apr 8, 2014 at 0:10
  • have you tried running pydoc on mayas own interpretter? Commented Apr 8, 2014 at 10:53
  • @joojaa it does not work, it doesn't find pydoc. Thank you anyway :D Commented Apr 8, 2014 at 22:08
  • 1
    @RamonBlanquer Odd pydoc works fine for me with mayas own interpretter Commented Apr 15, 2014 at 12:06

1 Answer 1

1

maya.commands is an stub module until it's run inside a working maya environment; if you just import it and inspect it outside of Maya you'll see that it's basically a placeholder.

If you want to inspect the contents, you can import the maya.standalone module and initialize it before running other commands (in this case it means you won't be able to run pydoc standalone.

You can get the documentation using the write command:

 import maya.standalone
 maya.standalone.initialize()
 import pydoc
 import mymodule
 pydoc.write(mymodule) # writes the mymodule.html to current directory

Be warned, however, that the documentation for all maya built in functions will be unhelful:

 'built-in function ls'

however you can at least document your own stuff without the maya parts crashing.

Pydoc, ironically, does not have a lot of external documentation. However you can see the code here:http://hg.python.org/cpython/file/2.7/Lib/pydoc.py (i'm not sure about the delta between this and the 2.6 version for maya pre-2014 but it works as above in maya 2011)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.