Commits

Stefan Scherfke committed 8909eee

Fined-tuned the API reference for simpy.core.

Comments (0)

Files changed (2)

docs/api_reference/simpy.core.rst

 
 .. automodule:: simpy.core
 
+.. data:: PENDING = object()
+
+    Unique object to identify pending values of events.
+
 .. autofunction:: peek
 .. autofunction:: step
 .. autofunction:: simulate
+.. autofunction:: all_events
+.. autofunction:: any_event
 
 .. autoclass:: Environment
-    :members:
+
+    .. autoattribute:: active_process
+    .. autoattribute:: now
+    .. automethod:: exit
 
     .. method:: event(self)
 
 
         Convenience method. Also returns a new instance of :class:`Process`.
 
+
+.. autoclass:: Event(env, value=PENDING, name=None)
+
+    .. attribute:: callbacks
+
+        List of functions that are called when the event is processed.
+
+    .. attribute:: env
+
+        The :class:`Environment` the event lives in.
+
+    .. attribute:: name
+
+        Optional name for this event. Used for :class:`str` / :func:`repr` if
+        not ``None``.
+
+    .. autoattribute:: triggered
+    .. autoattribute:: processed
+    .. autoattribute:: value
+    .. automethod:: succeed
+    .. automethod:: fail
+
+
 .. autoclass:: Process
-   :members: callbacks, env, is_alive, target, interrupt
+
+    .. attribute:: callbacks
+
+        List of functions that are called when the event is processed.
+
+    .. attribute:: env
+
+        The :class:`Environment` the event lives in.
+
+    .. attribute:: name
+
+        Optional name for this event. Used for :class:`str` / :func:`repr` if
+        not ``None``.
+
+    .. autoattribute:: target
+    .. autoattribute:: is_alive
+    .. automethod:: interrupt
+
+
+.. autoclass:: Timeout
+
+    .. attribute:: callbacks
+
+        List of functions that are called when the event is processed.
+
+    .. attribute:: env
+
+        The :class:`Environment` the event lives in.
+
+    .. attribute:: name
+
+        Optional name for this event. Used for :class:`str` / :func:`repr` if
+        not ``None``.
+
+
+.. autoclass:: Condition
+
+    .. attribute:: callbacks
+
+        List of functions that are called when the event is processed.
+
+    .. attribute:: env
+
+        The :class:`Environment` the event lives in.
+
+    .. attribute:: name
+
+        Optional name for this event. Used for :class:`str` / :func:`repr` if
+        not ``None``.
+
+
+.. autoclass:: Initialize
+
+    .. attribute:: callbacks
+
+        List of functions that are called when the event is processed.
+
+    .. attribute:: env
+
+        The :class:`Environment` the event lives in.
+
+
+.. autoclass:: Scheduler
+    :members:
+
+    .. attribute:: queue
+
+        A list with all currently scheduled events.
+
+.. autoclass:: EmptySchedule
 
 .. autoclass:: Interrupt
    :members: cause
-
-.. autoclass:: Event
-    :members:
-
-.. autoclass:: Timeout
-   :members:
-
-.. autoclass:: Condition
-   :members: callbacks, env
-
-.. autofunction:: all_events
-.. autofunction:: any_event
         self.env = env
         """The :class:`Environment` the event lives in."""
         self.name = name
-        """Optional name for this event. Used in :meth:`__str__()` if
-        not ``None``."""
+        """Optional name for this event. Used for :class:`str` / :func:`repr`
+        if not ``None``."""
         self._value = value
 
     def __repr__(self):
         # NOTE: The following initialization code is inlined from
         # Event.__init__() for performance reasons.
         self.callbacks = []
-        """List of functions that are called when the event is
-        processed."""
         self.env = env
-        """The :class:`Environment` the timeout lives in."""
         self.name = name
-        """Optional name for this event. Used in :meth:`__str__()` if
-        not ``None``."""
         self._delay = delay
         self.ok = True
         self._value = value
 
 class Initialize(Event):
     """Initializes a process."""
-
     def __init__(self, env, process):
         self.env = env
         self.ok = True
         # NOTE: The following initialization code is inlined from
         # Event.__init__() for performance reasons.
         self.callbacks = []
-        """List of functions that are called when the event is
-        processed."""
         self.env = env
-        """The :class:`Environment` the process lives in."""
         self.name = name
-        """Optional name for this event. Used in :meth:`__str__()` if
-        not ``None``."""
         self._generator = generator
         self._value = PENDING
 
 
 
 class EmptySchedule(Exception):
-    """Thrown by a :class:`Scheduler` if its :attr:`Scheduler.queue` is
+    """Thrown by a :class:`Scheduler` if its :attr:`~Scheduler.queue` is
     empty."""
     pass
 
             raise event._value
 
 
-def stop_simulate(event):
-    raise EmptySchedule()
-
-
 def simulate(env, until=None):
     """Simulate the environment until the given criterion *until* is met.
 
         until._value = None
         env.schedule(at - env.now, HIGH_PRIORITY, until)
 
-    until.callbacks.append(stop_simulate)
+    until.callbacks.append(_stop_simulate)
 
     try:
         while True:
 
 def _describe_frame(frame):
     """Prints filename, linenumber and function name of a stackframe."""
-
     filename, name = frame.f_code.co_filename, frame.f_code.co_name
     lineno = frame.f_lineno
 
                 break
 
     return '  File "%s", line %d, in %s\n    %s\n' % (filename, lineno, name,
-            line.strip())
+                                                      line.strip())
+
+
+def _stop_simulate(event):
+    """Used as callback in :func:`simulate()` to stop the simulation when the
+    *until* event occured."""
+    raise EmptySchedule()