Skip to content

Commit c08efe2

Browse files
Joseph-Edwardsjames-d-mitchell
authored andcommitted
Runner: better doc for state
1 parent f3d53ff commit c08efe2

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
@@ -282,46 +282,71 @@ This class inherits from :any:`Reporter`.
282282
.. [#sortof] Sort of, please see the note above.
283283
)pbdoc");
284284

285-
py::enum_<Runner::state> state(m, "Runner.state", R"pbdoc(
286-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
287-
has been called since construction or the last call to :any:`init`.
288-
)pbdoc");
289-
state
290-
.value("never_run", Runner::state::never_run, R"pbdoc(
291-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
292-
has been called since construction or the last call to :any:`init`.
293-
)pbdoc")
294-
.value("running_to_finish", Runner::state::running_to_finish, R"pbdoc(
295-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
296-
has been called since construction or the last call to :any:`init`.
297-
)pbdoc")
298-
.value("running_for", Runner::state::running_for, R"pbdoc(
299-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
300-
has been called since construction or the last call to :any:`init`.
301-
)pbdoc")
302-
.value("running_until", Runner::state::running_until, R"pbdoc(
303-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
304-
has been called since construction or the last call to :any:`init`.
305-
)pbdoc")
306-
.value("timed_out", Runner::state::timed_out, R"pbdoc(
307-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
308-
has been called since construction or the last call to :any:`init`.
309-
)pbdoc")
310-
.value("stopped_by_predicate",
311-
Runner::state::stopped_by_predicate,
312-
R"pbdoc(
313-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
314-
has been called since construction or the last call to :any:`init`.
315-
)pbdoc")
316-
.value("not_running", Runner::state::not_running, R"pbdoc(
317-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
318-
has been called since construction or the last call to :any:`init`.
319-
)pbdoc")
320-
.value("dead", Runner::state::dead, R"pbdoc(
321-
Indicates that none of :any:`run`, :any:`run_for`, or :any:`run_until`
322-
has been called since construction or the last call to :any:`init`.
285+
py::options options;
286+
options.disable_enum_members_docstring();
287+
py::enum_<Runner::state> state(thing, "state", R"pbdoc(
288+
The values in this enum are used to indicate the state of a runner.
289+
290+
The valid values are:
291+
292+
.. py:attribute:: state.never_run
293+
:value: <state.never_run: 0>
294+
295+
Indicates that none of :any:`Runner.run`, :any:`Runner.run_for`, or
296+
:any:`Runner.run_until` has been called since construction or the last call
297+
to :any:`Runner.init`.
298+
299+
.. py:attribute:: state.running_to_finish
300+
:value: <state.running_to_finish: 1>
301+
302+
Indicates that the Runner is currently running to the finish (via
303+
:any:`Runner.run`).
304+
305+
.. py:attribute:: state.running_for
306+
:value: <state.running_for: 2>
307+
308+
Indicates that the Runner is currently running for a specific amount of time
309+
(via :any:`Runner.run_for`).
310+
311+
.. py:attribute:: state.running_until
312+
:value: <state.running_until: 3>
313+
314+
Indicates that the Runner is currently running until some condition is met
315+
(via :any:`Runner.run_until`).
316+
317+
.. py:attribute:: state.timed_out
318+
:value: <state.timed_out: 4>
319+
320+
Indicates that the Runner was run via :any:`Runner.run_for` for a specific
321+
amount of time and that time has elapsed.
322+
323+
.. py:attribute:: state.stopped_by_predicate
324+
:value: <state.stopped_by_predicate: 6>
325+
326+
Indicates that the Runner was run via :any:`Runner.run_until` until the
327+
condition specified by the argument to :any:`Runner.run_until` was met.
328+
329+
.. py:attribute:: state.not_running
330+
:value: <state.not_running: 7>
331+
332+
Indicates that the Runner is not in any of the previous states and is not
333+
currently running. This can occur when, for example, :any:`Runner.run`
334+
throws an exception.
335+
336+
.. py:attribute:: state.dead
337+
:value: <state.dead: 8>
338+
339+
Indicates that the Runner was killed (by another thread).
323340
)pbdoc");
324-
thing.attr("state") = state;
341+
state.value("never_run", Runner::state::never_run)
342+
.value("running_to_finish", Runner::state::running_to_finish)
343+
.value("running_for", Runner::state::running_for)
344+
.value("running_until", Runner::state::running_until)
345+
.value("timed_out", Runner::state::timed_out)
346+
.value("stopped_by_predicate", Runner::state::stopped_by_predicate)
347+
.value("not_running", Runner::state::not_running)
348+
.value("dead", Runner::state::dead);
349+
325350
thing.def(
326351
"init",
327352
[](Runner& r) -> Runner& { return r.init(); },
@@ -361,7 +386,7 @@ any derived class of :any:`Runner`.
361386

362387
.. seealso:: :any:`run_for`)pbdoc");
363388
thing.def("run_until",
364-
(void (Runner::*)(std::function<bool()>&)) &Runner::run_until,
389+
(void(Runner::*)(std::function<bool()>&)) & Runner::run_until,
365390
py::arg("func"),
366391
R"pbdoc(
367392
Run until a nullary predicate returns true or finished.

0 commit comments

Comments
 (0)