Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for pyface.action and pyface.tasks.action submodules #843

Merged
merged 3 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyface/action/action_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ActionEvent(HasTraits):
def __init__(self, **traits):
""" Creates a new action event.

Note: Every keyword argument becoames a public attribute of the event.
Note: Every keyword argument becomes a public attribute of the event.
"""
# Base-class constructor.
super(ActionEvent, self).__init__(**traits)
Expand Down
57 changes: 57 additions & 0 deletions pyface/action/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,63 @@
# Thanks for using Enthought open source!


"""

API for the ``pyface.action`` subpackage.

Actions
-------

- :class:`~.Action`
- :class:`~.FieldAction`
- :class:`~.GUIApplicationAction`
- :class:`~.ListeningAction`
- :class:`~.TraitsUIWidgetAction`
- :class:`~.WindowAction`

Action Controller
-----------------

- :class:`~.ActionController`

Action Event
------------

- :class:`~.ActionEvent`

Action Managers
---------------

- :class:`~.ActionManager`
- ``MenuManager``
- ``MenuBarManager``
- ``StatusBarManager``
- ``ToolBarManager``
- ``ToolPaletteManager``, only for the Wx toolkit.

Action Manager Items
--------------------

- :class:`~.ActionManagerItem`
- :class:`~.ActionItem`

Layout support
--------------

- :class:`~.Group`
- :class:`~.Separator`

Useful Application and Window actions
-------------------------------------

- :class:`~.AboutAction`
- :class:`~.CloseActiveWindowAction`
- :class:`~.CreateWindowAction`
- :class:`~.ExitAction`
- :class:`~.CloseWindowAction`

"""

from .action import Action
from .action_controller import ActionController
from .action_event import ActionEvent
Expand Down
2 changes: 1 addition & 1 deletion pyface/action/field_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class FieldAction(Action):
""" A widget action containing an IField

When the value in the field is changed, the `on_peform` method is called
When the value in the field is changed, the `on_perform` method is called
with the new value as the argument.
"""

Expand Down
6 changes: 5 additions & 1 deletion pyface/action/menu_bar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#
# Thanks for using Enthought open source!

""" A menu bar manager realizes itself in errr, a menu bar control. """
""" A toolkit-specific menu bar manager that realizes itself in a menu bar
control.

- :attr:`~.MenuBarManager`
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When building the docs, these "- :attr:~.MenuBarManager" lines just show up as

  • MenuBarManager

Without any link. Not a suggested change now, but maybe as a future improvement, for toolkit specific things we could link to both implementations somehow? e.g. one link to docs for https://github.com/enthought/pyface/blob/master/pyface/ui/qt4/action/menu_bar_manager.py and another for wx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without any link.

There is already an issue: #755
Note that Qt and Wx implementations don't necessarily have exactly the same definition. Cherry-picking the ones I know:
The enum definition for DataViewWidget looks like this in Qt:

#: What can be selected. Qt supports additional selection types.
selection_type = Enum("row", "column", "item")
#: How selections are modified. Qt supports turning off selections.
selection_mode = Enum("extended", "none", "single")

But it looks like this in Wx:

#: What can be selected.
selection_type = Enum("row")
#: How selections are modified.
selection_mode = Enum("extended", "single")

We can't merge the two into one without having to pick one over another.
Another hard problem is the dependency on the toolkit while generating the doc. Some mocking (in doc config) may be needed, but that is not necessarily trivial either.



# Import the toolkit specific version.
Expand Down
5 changes: 4 additions & 1 deletion pyface/action/menu_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#
# Thanks for using Enthought open source!

""" A menu manager realizes itself in a menu control. """
""" A toolkit-specific menu manager that realizes itself in a menu control.

- :attr:`~.MenuManager`
"""


# Import the toolkit specific version.
Expand Down
6 changes: 5 additions & 1 deletion pyface/action/status_bar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#
# Thanks for using Enthought open source!

""" A status bar manager realizes itself in a status bar control. """
""" A toolkit-specific status bar manager that realizes itself in a status bar
control.

- :attr:`~.StatusBarManager`
"""


# Import the toolkit specific version.
Expand Down
6 changes: 5 additions & 1 deletion pyface/action/tool_bar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#
# Thanks for using Enthought open source!

""" A tool bar manager realizes itself in a tool bar control. """
""" A toolkit-specific tool bar manager that realizes itself in a tool bar
control.

- :attr:`~.ToolBarManager`
"""


# Import the toolkit specific version.
Expand Down
6 changes: 5 additions & 1 deletion pyface/action/tool_palette_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#
# Thanks for using Enthought open source!

""" A tool bar manager realizes itself in a tool palette control. """
""" A toolkit-specific tool bar manager that realizes itself in a tool palette
control.

- :attr:`~.ToolPaletteManager`
"""


# Import the toolkit specific version.
Expand Down
51 changes: 51 additions & 0 deletions pyface/tasks/action/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,57 @@
#
# Thanks for using Enthought open source!

"""

API for the ``pyface.tasks.action`` subpackage.

ActionSchemas and aliases
-------------------------

- :class:`~.ActionSchema`
- :class:`~.GroupSchema`
- :class:`~.MenuSchema`
- :class:`~.MenuBarSchema`
- :class:`~.ToolBarSchema`
- :attr:`~.SGroup`
- :attr:`~.SMenu`
- :attr:`~.SMenuBar`
- :attr:`~.SToolBar`

Schema Addition
---------------

- :class:`~.SchemaAddition`

Tasks-specific Action Controller
--------------------------------

- :class:`~.TaskActionController`

Tasks-specific Action Manager factory
-------------------------------------

- :class:`~.TaskActionManagerBuilder`

Tasks-specific Actions
----------------------

- :class:`~.CentralPaneAction`
- :class:`~.DockPaneAction`
- :class:`~.EditorAction`
- :class:`~.TaskAction`
- :class:`~.TaskWindowAction`
- :class:`~.TasksApplicationAction`

Useful Tasks Actions and Groups
-------------------------------

- :class:`~.DockPaneToggleGroup`
- :class:`~.TaskToggleGroup`
- :class:`~.TaskWindowToggleGroup`
- :class:`~.CreateTaskWindowAction`

"""

from .dock_pane_toggle_group import DockPaneToggleGroup
from .schema import (
Expand Down
5 changes: 4 additions & 1 deletion pyface/tasks/action/listening_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
# Backward compatibility import

""" This module exists purely for backwards compatibility.
Please use :class:`pyface.action.listening_action.ListeningAction` instead.
"""

from pyface.action.listening_action import ListeningAction
38 changes: 19 additions & 19 deletions pyface/tasks/action/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class Schema(HasTraits):
""" The abstract base class for all Tasks action schemas.
"""

# The schema's identifier (unique within its parent schema).
#: The schema's identifier (unique within its parent schema).
id = Str()

def _id_default(self):
return get_unique_id(self)

# The list of sub-items in the schema. These items can be other
# (non-top-level) schema or concrete instances from the Pyface API.
#: The list of sub-items in the schema. These items can be other
#: (non-top-level) schema or concrete instances from the Pyface API.
items = List(SubSchema)

def __init__(self, *items, **traits):
Expand Down Expand Up @@ -103,10 +103,10 @@ class GroupSchema(Schema):
""" A schema for a Pyface Group.
"""

# A factory for instantiating a pyface Group.
#: A factory for instantiating a pyface Group.
group_factory = Callable(Group)

# Does the group require a separator when it is visualized?
#: Does the group require a separator when it is visualized?
separator = Bool(True)

def create(self, children):
Expand All @@ -118,16 +118,16 @@ class MenuSchema(Schema):
""" A schema for a Pyface MenuManager.
"""

# The menu's user visible name.
#: The menu's user visible name.
name = Str()

# Does the menu require a separator before the menu item?
#: Does the menu require a separator before the menu item?
separator = Bool(False)

# The default action for tool button when shown in a toolbar (Qt only)
#: The default action for tool button when shown in a toolbar (Qt only)
action = Instance(Action)

# A factory for instantiating a pyface MenuManager.
#: A factory for instantiating a pyface MenuManager.
menu_manager_factory = Callable(MenuManager)

def create(self, children):
Expand All @@ -141,10 +141,10 @@ class MenuBarSchema(Schema):
""" A schema for a Pyface MenuBarManager.
"""

# Assign a default ID for menu bar schemas.
#: Assign a default ID for menu bar schemas.
id = "MenuBar"

# A factory for instantiating a pyface MenuBarManager.
#: A factory for instantiating a pyface MenuBarManager.
menu_bar_manager_factory = Callable(MenuBarManager)

def create(self, children):
Expand All @@ -156,26 +156,26 @@ class ToolBarSchema(Schema):
""" A schema for a Pyface ToolBarManager.
"""

# Assign a default ID for tool bar schemas.
#: Assign a default ID for tool bar schemas.
id = "ToolBar"

# The tool bar's user visible name. Note that this name may not be used on
# all platforms.
#: The tool bar's user visible name. Note that this name may not be used on
#: all platforms.
name = Str("Tool Bar")

# The size of tool images (width, height).
#: The size of tool images (width, height).
image_size = Tuple((16, 16))

# The orientation of the toolbar.
#: The orientation of the toolbar.
orientation = Enum("horizontal", "vertical")

# Should we display the horizontal divider?
#: Should we display the horizontal divider?
show_divider = Bool(True)

# Should we display the name of each tool bar tool under its image?
#: Should we display the name of each tool bar tool under its image?
show_tool_names = Bool(True)

# A factory for instantiating a pyface ToolBarManager
#: A factory for instantiating a pyface ToolBarManager
tool_bar_manager_factory = Callable(ToolBarManager)

def create(self, children):
Expand Down
55 changes: 28 additions & 27 deletions pyface/tasks/action/schema_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,42 @@ class SchemaAddition(HasTraits):
""" An addition to an existing menu bar or tool bar schema.
"""

# The schema addition's identifier. This optional, but if left unspecified,
# other schema additions will be unable to refer to this one.
#: The schema addition's identifier. This optional, but if left
#: unspecified, other schema additions will be unable to refer to this one.
id = Str()

# A callable to create the item. Should have the following signature:
# callable() -> Action | ActionItem | Group | MenuManager |
# GroupSchema | MenuSchema
# If the result is a schema, it will itself admit of extension by other
# additions. If not, the result will be fixed.
#: A callable to create the item. Should have the following signature:
#: callable() -> Action | ActionItem | Group | MenuManager |
#: GroupSchema | MenuSchema
#:
#: If the result is a schema, it will itself admit of extension by other
#: additions. If not, the result will be fixed.
factory = Callable

# A forward-slash-separated path through the action hierarchy to the menu
# to add the action, group or menu to. For example:
# - To add an item to the menu bar: ``path = "MenuBar"``
# - To add an item to the tool bar: ``path = "ToolBar"``
# - To add an item to a sub-menu: ``path = "MenuBar/File/New"``
#: A forward-slash-separated path through the action hierarchy to the menu
#: to add the action, group or menu to. For example:
#: - To add an item to the menu bar: ``path = "MenuBar"``
#: - To add an item to the tool bar: ``path = "ToolBar"``
#: - To add an item to a sub-menu: ``path = "MenuBar/File/New"``
path = Str()

# The item appears after the item with this ID.
# - for groups, this is the ID of another group.
# - for menus and actions, this is the ID of another menu or action.
#: The item appears after the item with this ID.
#: - for groups, this is the ID of another group.
#: - for menus and actions, this is the ID of another menu or action.
after = Str()

# The action appears before the item with this ID.
# - for groups, this is the ID of another group.
# - for menus and actions, this is the ID of another menu or action.
#: The action appears before the item with this ID.
#: - for groups, this is the ID of another group.
#: - for menus and actions, this is the ID of another menu or action.
before = Str()

# The action appears at the absolute specified position first or last.
# This is useful for example to keep the File menu the first menu in a
# menubar, the help menu the last etc.
# If multiple actions in a schema have absolute_position 'first', they
# will appear in the same order specified; unless 'before' and 'after'
# traits are set to sort these multiple items.
# This trait takes precedence over 'after' and 'before', and values of
# those traits that are not compatible with the absolute_position are
# ignored.
#: The action appears at the absolute specified position first or last.
#: This is useful for example to keep the File menu the first menu in a
#: menubar, the help menu the last etc.
#: If multiple actions in a schema have absolute_position 'first', they
#: will appear in the same order specified; unless 'before' and 'after'
#: traits are set to sort these multiple items.
#: This trait takes precedence over 'after' and 'before', and values of
#: those traits that are not compatible with the absolute_position are
#: ignored.
absolute_position = Enum(None, "first", "last")
Loading