OK to summarize:

I didn't want to add a help flag because I don't know how people would 
discover it.

The only built-in way, is to do as Ian Jones suggested and use MEL's help 
function. That will give you a list of parameters but no description.

As Justin suggested, for a Python plugin, it's relatively easy to add a 
Python docstring, so you can do help(cmds.myPluginCmd), by adding this to 
the end of initializePlugin(mobject):

cmdsPlugin = getattr(cmds, kPluginCmdName)
cmdsPlugin.__doc__ = MyPluginClass.__doc__ # Typically this is a nice 
description of the class, though it doesn't describe the flags.


For a C++ plugin, it's harder but it also works. I added a getDocString 
method that returns a very long MString and then did this, also in 
initializePlugin:

MString pyCmd;
pyCmd += "import maya.cmds as cmds\n";
pyCmd += "cmds." MY_PLUGIN_CMD ".__doc__ = '''";
pyCmd += MyPlugin::getDocString();
pyCmd += "'''\n";
MGlobal::executePythonCommand(pyCmd);


I also call MGlobal::displayError(MyPlugin::getDocString().asChar());
if my MArgDatabase constructor doesn't return kSuccess (ie if the user 
supplies illegal arguments).


On Thursday, 15 March 2018 14:32:43 UTC+11, Ian Jones wrote:
>
> That works for C++ command plugins too. I verified it on one specifically.
>
> Ian
>
> On Wed, Mar 14, 2018, 7:27 PM Michael Boon <[email protected] 
> <javascript:>> wrote:
>
>> That works for Python plugins! It won't be quite so simple for a C++ 
>> plugin (which my exporter is) but I will  give it a try and report back.
>>
>> @Ian Jones - I didn't know that worked in MEL, thank you.
>>
>> On Wednesday, 14 March 2018 21:00:14 UTC+11, Justin Israel wrote:
>>
>>>
>>>
>>> On Wed, Mar 14, 2018, 2:18 PM justin hidair <[email protected]> wrote:
>>>
>>>> I guess you can do a command with a help flag  to accommodate as a 
>>>> workaround, that’s a good question tho
>>>>
>>> Help flag seems like a good suggestion, seeing as you don't have control 
>>> over the function that gets injected into the commands namespace to wrap 
>>> your plugin. 
>>>
>>> I haven't tried it, so this is just a brainstorm. What would happen if 
>>> you manually set cmds.ExportModel.__doc__ at the end of 
>>> your initializePlugin(mobject) function? Would it even let you? Would it 
>>> then allow docstrings to work properly? 
>>>
>>>
>>>  
>>>>
>>>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
>>>> Windows 10
>>>>
>>>>  
>>>>
>>>> *From: *Michael Boon
>>>> *Sent: *Wednesday, March 14, 2018 12:59 AM
>>>> *To: *Python Programming for Autodesk Maya
>>>> *Subject: *[Maya-Python] Can Maya plugins do any self-documentation?
>>>>
>>>>  
>>>>
>>>> I have a plugin called ExportModel*. If I do help(cmds.ExportModel ) I 
>>>> get
>>>>
>>>> Help on function ExportModel in module maya.cmds:
>>>>
>>>> ExportModel(*args, **keywords)
>>>>
>>>>  
>>>>
>>>> which is next to useless.
>>>>
>>>> Is there a way I can publish the expected arguments and return values 
>>>> of my plugin so that other scripters can see them inside Maya?
>>>>
>>>> (* Names have been changed to protect the innocent)
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/python_inside_maya/24a69ba7-2dfb-447a-bcba-3a3b71150600%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/24a69ba7-2dfb-447a-bcba-3a3b71150600%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>>  
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/python_inside_maya/5aa8787f.51951c0a.13a94.16ae%40mx.google.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/5aa8787f.51951c0a.13a94.16ae%40mx.google.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/519946dd-0c8b-4107-8f2a-f02a93ee0a5b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/519946dd-0c8b-4107-8f2a-f02a93ee0a5b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/778c97d2-c68f-49ef-b898-ac9514af0449%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to