theodox / mGui

Python module for cleaner maya GUI layout syntax
MIT License
123 stars 23 forks source link

helpers ought to auto-generate documentation #4

Open theodox opened 10 years ago

theodox commented 10 years ago

right now it just says 'auto-generated', but if we copy all of the flags into help it might make it easier to work with.

bob-white commented 7 years ago

Were you thinking something along these lines?

class Button(Control):
    """
    Wrapper class for cmds.button
    =============================

    Read Only:
    ----------
    - isObscured
    - popupMenuArray
    - numberOfPopupMenus

    Editable:
    ---------
    - actionIsSubstitute
    - actOnPress
    - align
    - label2
    - recomputeSize
    - annotation
    - backgroundColor
    - defineTemplate
    - docTag
    - enable
    - enableBackground
    - exists
    - fullPathName
    - height
    - manage
    - noBackground
    - numberOfPopupMenus
    - parent
    - popupMenuArray
    - preventOverride
    - useTemplate
    - visible
    - visibleChangeCommand
    - width

    Callbacks:
    ----------
    - command
    - dragCallback
    - dropCallback
    - visibleChangeCommand
    """
    CMD = cmds.button
    _ATTRIBS = ['actionIsSubstitute', 'actOnPress', 'align', 'label', 'recomputeSize']
    _CALLBACKS = ['command']
bob-white commented 7 years ago

Or would we want to go one step further and try to add the command documentation?

class Button(Control):
    """
    Wrapper class for cmds.button
    =============================

    Read Only:
    ----------
    - isObscured
        Return whether the control can actually be seen by the user. The control will be obscured if its state is invisible, if it is blocked (entirely or partially) by some other control, if it or a parent layout is unmanaged, or if the control's window is invisible or iconified.
    - popupMenuArray
        Return the names of all the popup menus attached to this control.
    - numberOfPopupMenus
        Return the number of popup menus attached to this control.

    Editable:
    ---------
    - actionIsSubstitute
        This flag is obsolete and should no longer be used.
    - actOnPress
        If true then the command specified by the command flag will be executed when a mouse button is pressed. If false then that command will be executed after the mouse button is released. The default value is false.
    - align
        This flag is obsolete and should no longer be used. The button label will always be center-aligned.
    - label
        The label text. The default label is the name of the control.
    - recomputeSize
        If true then the control will recompute it's size to just fit the size of the label. If false then the control size will remain fixed as you change the size of the label. The default value of this flag is true.
    - annotation
        Annotate the control with an extra string value.
    - backgroundColor
        The background color of the control. The arguments correspond to the red, green, and blue color components. Each component ranges in value from 0.0 to 1.0. 
        When setting backgroundColor, the background is automatically enabled, unless enableBackground is also specified with a false value.
    - defineTemplate
        Puts a command in a mode where any other flags and args are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template.
    - docTag
        Add a documentation flag to the control. The documentation flag has a directory structure like hierarchy. Eg. -dt render/multiLister/createNode/material
    - enable
        The enable state of the control. By default, this flag is set to true and the control is enabled. Specify false and the control will appear dimmed or greyed-out indicating it is disabled.
    - enableBackground
        Enables the background color of the control.
    - exists
        Returns true|false depending upon whether the specified object exists. Other flags are ignored.
    - fullPathName
        Return the full path name of the widget, which includes all the parents
    - height
        The height of the control. The control will attempt to be this size if it is not overruled by parent layout conditions.
    - manage
        Manage state of the control. An unmanaged control is not visible, nor does it take up any screen real estate. All controls are created managed by default.
    - noBackground
        Clear/reset the control's background. Passing true means the background should not be drawn at all, false means the background should be drawn. The state of this flag is inherited by children of this control.
    - parent
        The parent layout for this control.
    - preventOverride
        If true, this flag disallows overriding the control's attribute via the control's right mouse button menu.
    - useTemplate
        Force the command to use a command template other than the current one.
    - visible
        The visible state of the control. A control is created visible by default. Note that a control's actual appearance is also dependent on the visible state of its parent layout(s).
    - width
        The width of the control. The control will attempt to be this size if it is not overruled by parent layout conditions.

    Callbacks:
    ----------
    - command
        Command executed when the control is pressed.
    - dragCallback
    - dropCallback
    - visibleChangeCommand
        Command that gets executed when visible state of the control changes.

    """
    CMD = cmds.button
    _ATTRIBS = ['actionIsSubstitute', 'actOnPress', 'align', 'label', 'recomputeSize']
    _CALLBACKS = ['command']
bob-white commented 7 years ago

That second option would require a bit more work, as we'd need to parse and reformat the existing documentation. We'd probably also need to come up with some way of denoting which version of Maya we scraped this info from, as new flags have appeared recently in services packs, and not just in major version updates.

theodox commented 7 years ago

I was thinking of something that scraped the docs, but it might have to be limited to flag: the length of the whole thing would be so long that you'd only be able to use it in the listener if this is a typical example.

On Thu, Nov 24, 2016 at 10:39 AM, bob-white notifications@github.com wrote:

That second option would require a bit more work, as we'd need to parse and reformat the existing documentation. We'd probably also need to come up with some way of denoting which version of Maya we scraped this info from, as new flags have appeared recently in services packs, and not just in major version updates.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/theodox/mGui/issues/4#issuecomment-262830431, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3mGNlpQP4HAQ04p58HY5WjPW8blvG2ks5rBdnJgaJpZM4Bt7-t .

theodox commented 7 years ago

maybe the best thing to do is to add a static help() method that just calls the help command on an objects widget? If you're looking at code you have all of the fields (though not their types). Even the maya help doesn't say what things do.. Maybe it's not worth pursuing...