Skip to content

Commit 26e848c

Browse files
Runner: better doc for state
1 parent 778ec72 commit 26e848c

4 files changed

Lines changed: 85 additions & 42 deletions

File tree

docs/source/main-algorithms/core-classes/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ pages.
2424
reporter
2525
report-guard
2626
runner
27+
runner.state

docs/source/main-algorithms/core-classes/runner.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Contents
3333
Runner.running_for
3434
Runner.running_until
3535
Runner.started
36-
Runner.state
3736
Runner.stopped
3837
Runner.stopped_by_predicate
3938
Runner.success
@@ -43,5 +42,7 @@ Full API
4342
--------
4443

4544
.. autoclass:: Runner
46-
:class-doc-from: init
45+
:no-doc:
4746
:members:
47+
:exclude-members: state
48+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
..
2+
Copyright (c) 2025 Joseph Edwards
3+
4+
Distributed under the terms of the GPL license version 3.
5+
6+
The full license is in the file LICENSE, distributed with this software.
7+
8+
The Runner.state class
9+
======================
10+
11+
This page defines the :any:`Runner.state` enum.
12+
13+
.. autoclass:: libsemigroups_pybind11::Runner.state
14+
:class-doc-from: class
15+
:members:
16+
:exclude-members: name

src/runner.cpp

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -257,46 +257,71 @@ a derived class with a possibly long running :any:`run`. These common tasks
257257
This class inherits from :any:`Reporter`.
258258
)pbdoc");
259259

260-
py::enum_<Runner::state> state(m, "Runner.state", R"pbdoc(
261-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
262-
has been called since construction or the last call to :any:`init`.
263-
)pbdoc");
264-
state
265-
.value("never_run", Runner::state::never_run, R"pbdoc(
266-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
267-
has been called since construction or the last call to :any:`init`.
268-
)pbdoc")
269-
.value("running_to_finish", Runner::state::running_to_finish, R"pbdoc(
270-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
271-
has been called since construction or the last call to :any:`init`.
272-
)pbdoc")
273-
.value("running_for", Runner::state::running_for, R"pbdoc(
274-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
275-
has been called since construction or the last call to :any:`init`.
276-
)pbdoc")
277-
.value("running_until", Runner::state::running_until, R"pbdoc(
278-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
279-
has been called since construction or the last call to :any:`init`.
280-
)pbdoc")
281-
.value("timed_out", Runner::state::timed_out, R"pbdoc(
282-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
283-
has been called since construction or the last call to :any:`init`.
284-
)pbdoc")
285-
.value("stopped_by_predicate",
286-
Runner::state::stopped_by_predicate,
287-
R"pbdoc(
288-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
289-
has been called since construction or the last call to :any:`init`.
290-
)pbdoc")
291-
.value("not_running", Runner::state::not_running, R"pbdoc(
292-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
293-
has been called since construction or the last call to :any:`init`.
294-
)pbdoc")
295-
.value("dead", Runner::state::dead, R"pbdoc(
296-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
297-
has been called since construction or the last call to :any:`init`.
260+
py::options options;
261+
options.disable_enum_members_docstring();
262+
py::enum_<Runner::state> state(thing, "state", R"pbdoc(
263+
The values in this enum are used to indicate the state of a runner.
264+
265+
The valid values are:
266+
267+
.. py:attribute:: state.never_run
268+
:value: <state.never_run: 0>
269+
270+
Indicates that none of :any:`Runner.run`, :any:`Runner.run_for`, or
271+
:any:`Runner.run_until` has been called since construction or the last call
272+
to :any:`Runner.init`.
273+
274+
.. py:attribute:: state.running_to_finish
275+
:value: <state.running_to_finish: 1>
276+
277+
Indicates that the Runner is currently running to the finish (via
278+
:any:`Runner.run`).
279+
280+
.. py:attribute:: state.running_for
281+
:value: <state.running_for: 2>
282+
283+
Indicates that the Runner is currently running for a specific amount of time
284+
(via :any:`Runner.run_for`).
285+
286+
.. py:attribute:: state.running_until
287+
:value: <state.running_until: 3>
288+
289+
Indicates that the Runner is currently running until some condition is met
290+
(via :any:`Runner.run_until`).
291+
292+
.. py:attribute:: state.timed_out
293+
:value: <state.timed_out: 4>
294+
295+
Indicates that the Runner was run via :any:`Runner.run_for` for a specific
296+
amount of time and that time has elapsed.
297+
298+
.. py:attribute:: state.stopped_by_predicate
299+
:value: <state.stopped_by_predicate: 6>
300+
301+
Indicates that the Runner was run via :any:`Runner.run_until` until the
302+
condition specified by the argument to :any:`Runner.run_until` was met.
303+
304+
.. py:attribute:: state.not_running
305+
:value: <state.not_running: 7>
306+
307+
Indicates that the Runner is not in any of the previous states and is not
308+
currently running. This can occur when, for example, :any:`Runner.run`
309+
throws an exception.
310+
311+
.. py:attribute:: state.dead
312+
:value: <state.dead: 8>
313+
314+
Indicates that the Runner was killed (by another thread).
298315
)pbdoc");
299-
thing.attr("state") = state;
316+
state.value("never_run", Runner::state::never_run)
317+
.value("running_to_finish", Runner::state::running_to_finish)
318+
.value("running_for", Runner::state::running_for)
319+
.value("running_until", Runner::state::running_until)
320+
.value("timed_out", Runner::state::timed_out)
321+
.value("stopped_by_predicate", Runner::state::stopped_by_predicate)
322+
.value("not_running", Runner::state::not_running)
323+
.value("dead", Runner::state::dead);
324+
300325
thing.def(
301326
"init",
302327
[](Runner& r) -> Runner& { return r.init(); },
@@ -336,7 +361,7 @@ any derived class of :any:`Runner`.
336361
337362
.. seealso:: :any:`run_for`)pbdoc");
338363
thing.def("run_until",
339-
(void (Runner::*)(std::function<bool()>&)) &Runner::run_until,
364+
(void(Runner::*)(std::function<bool()>&)) & Runner::run_until,
340365
py::arg("func"),
341366
R"pbdoc(
342367
Run until a nullary predicate returns true or finished.

0 commit comments

Comments
 (0)