Skip to content

Commit a9b59c9

Browse files
Doc: Fix nitpicky warnings
1 parent b5e7972 commit a9b59c9

21 files changed

Lines changed: 236 additions & 176 deletions

docs/source/_ext/libsemigroups_pybind11_extensions.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def check_string_replacements(app, env):
440440
logger.info(f"Please correct this in {__file__}")
441441

442442

443+
# TODO: Check this actually works as expected.
443444
def document_class(app, what, name, obj, options, lines):
444445
"""Document a class using its __init__ function
445446
@@ -450,7 +451,18 @@ def document_class(app, what, name, obj, options, lines):
450451
if what != "class":
451452
return
452453
try:
453-
if options["class-doc-from"] == "init":
454+
if options["class-doc-from"] != "init":
455+
return
456+
457+
init_doc = obj.__init__.__doc__
458+
459+
if (
460+
not init_doc
461+
or "Initialize self. See help(type(self)) for accurate signature."
462+
in init_doc
463+
):
464+
lines[:] = []
465+
else:
454466
lines[:] = [f".. autofunction:: {name}.__init__\n"]
455467
except KeyError:
456468
return

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Full API
4242
--------
4343

4444
.. autoclass:: Runner
45-
:no-doc:
4645
:class-doc-from: init
4746
:members:
4847
:exclude-members: state

docs/source/main-algorithms/knuth-bendix/helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ submodule ``libsemigroups_pybind11.knuth_bendix``.
1414

1515
.. seealso::
1616

17-
:py:class:`overlap`
17+
:any:`KnuthBendix.options`
1818

1919
Contents
2020
--------

docs/source/main-algorithms/schreier-sims/class.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ Full API
5151
:class-doc-from: init
5252
:members:
5353
:exclude-members:
54-
current_state, dead, finished, internal_generating_pairs,
54+
current_state, dead, internal_generating_pairs,
5555
kill, last_report, report, report_every, report_prefix,
56-
report_why_we_stopped, reset_last_report, reset_start_time, run, run_for,
56+
report_why_we_stopped, reset_last_report, reset_start_time, run_for,
5757
run_until, running, running_for, running_until, start_time, started, state,
5858
stopped, stopped_by_predicate, success, timed_out

src/action.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -523,18 +523,30 @@ This function returns the point obtained by applying the action defined by
523523
} // namespace
524524

525525
void init_action(py::module& m) {
526-
py::enum_<side>(
527-
m,
528-
"side",
529-
R"pbdoc(This value indicates that the action in an :any:`Action` instance should be a left action.)pbdoc")
530-
.value(
531-
"left",
532-
side::left,
533-
R"pbdoc(This value indicates that the action in an :any:`Action` instance should be a left action.)pbdoc")
534-
.value(
535-
"right",
536-
side::right,
537-
R"pbdoc(This value indicates that the action in an :any:`Action` instance should be a right action.)pbdoc");
526+
py::options options;
527+
options.disable_enum_members_docstring();
528+
py::enum_<side>(m,
529+
"side",
530+
R"pbdoc(
531+
The values in this enum can be used to indicate that the action in an
532+
:any:`Action` instance should be a left action.
533+
534+
The valid values are:
535+
536+
.. py:attribute:: side.left
537+
:value: <side.left: 0>
538+
539+
Value indicating that the action in an :any:`Action` instance should be a
540+
left action.
541+
542+
.. py:attribute:: side.right
543+
:value: <side.left: 1>
544+
545+
Value indicating that the action in an :any:`Action` instance should be a
546+
right action.
547+
)pbdoc")
548+
.value("left", side::left)
549+
.value("right", side::right);
538550

539551
// One call to bind is required per list of types
540552

src/bmat8.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ be ``0``. This does not affect the results of any calculations.
4949
There are numerous functions for computing things about :any:`BMat8` objects in
5050
the submodule ``bmat8``.
5151
52-
.. toctree::
53-
:maxdepth: 1
54-
55-
bmat8-helpers
56-
5752
.. doctest::
5853
5954
>>> from libsemigroups_pybind11 import BMat8

src/forest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Returns the label of the edge from a node to its parent.
162162
:param i:
163163
the node whose label is sought.
164164
:type i:
165-
init
165+
int
166166
167167
:returns:
168168
The label of the edge from the parent of *i* to *i*.

src/froidure-pin-base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ use :any:`current_rules` instead.
762762
:returns:
763763
An iterator yielding rules.
764764
:rtype:
765-
Iterator[tuple[list[int],list[int]]]:
765+
Iterator[tuple[list[int],list[int]]]
766766
)pbdoc");
767767
}
768768
} // init_froidure_pin_base

src/froidure-pin.cpp

Lines changed: 87 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,66 @@ element of *fp* and ``False`` otherwise.
346346
return froidure_pin::factorisation(fpb, pos);
347347
},
348348
py::arg("fpb"),
349-
py::arg("pos"));
349+
py::arg("pos"),
350+
R"pbdoc(
351+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
352+
:only-document-once:
353+
354+
Returns a word containing a factorisation (in the generators) of an
355+
element.
356+
357+
This function returns a word in the generators that equals the given element
358+
*x*. The key difference between this function and :any:`minimal_factorisation`,
359+
is that the resulting factorisation may not be minimal.
360+
361+
:param fp: the :any:`FroidurePin` instance.
362+
:type fp: FroidurePin
363+
364+
:param x: a possible element, or index of element, to factorise.
365+
:type x: Element | int
366+
367+
:returns: Returns a word in the generators which evaluates to *x*.
368+
:rtype: list[int]
369+
370+
:raises LibsemigroupsError:
371+
if *x* is an ``Element`` and *x* does not belong to *fp*.
372+
373+
:raises LibsemigroupsError:
374+
if *x* is an :any:`int` and *x* is greater than or equal to :any:`FroidurePin.size`.
375+
376+
)pbdoc");
350377

351-
// Documented in the Element overload.
352378
m.def(
353379
"froidure_pin_minimal_factorisation",
354380
[](FroidurePin_& fp, size_t i) {
355381
return froidure_pin::minimal_factorisation(fp, i);
356382
},
357383
py::arg("fp"),
358-
py::arg("i"));
384+
py::arg("i"),
385+
R"pbdoc(
386+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
387+
:only-document-once:
388+
Returns a word containing a minimal factorisation (in the generators)
389+
of an element.
390+
391+
This function returns the short-lex minimum word (if any) in the generators
392+
that evaluates to *x*.
393+
394+
:param fp: the :any:`FroidurePin` instance.
395+
:type fp: FroidurePin
396+
397+
:param x: a possible element, or index of element, to factorise.
398+
:type x: Element | int
399+
400+
:returns: A word in the generators that evaluates to *x*.
401+
:rtype: list[int]
402+
403+
:raises LibsemigroupsError:
404+
if *x* is an ``Element`` and *x* does not belong to *fp*.
405+
406+
:raises LibsemigroupsError:
407+
if *x* is an :any:`int` and *x* is greater than or equal to :any:`FroidurePin.size`.
408+
)pbdoc");
359409

360410
m.def(
361411
"froidure_pin_position",
@@ -875,6 +925,7 @@ if *x* is not an element.
875925
// Helper functions
876926
////////////////////////////////////////////////////////////////////////
877927

928+
// Documented in the size_t overload.
878929
m.def(
879930
"froidure_pin_factorisation",
880931
[](FroidurePin_& fp, Element const& x) {
@@ -884,29 +935,6 @@ if *x* is not an element.
884935
py::arg("x"),
885936
R"pbdoc(
886937
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
887-
:only-document-once:
888-
889-
Returns a word containing a factorisation (in the generators) of an
890-
element.
891-
892-
This function returns a word in the generators that equals the given element
893-
*x*. The key difference between this function and :any:`minimal_factorisation`,
894-
is that the resulting factorisation may not be minimal.
895-
896-
:param fp: the :any:`FroidurePin` instance.
897-
:type fp: FroidurePin
898-
899-
:param x: a possible element, or index of element, to factorise.
900-
:type x: Element | int
901-
902-
:returns: Returns a word in the generators which evaluates to *x*.
903-
:rtype: list[int]
904-
905-
:raises LibsemigroupsError:
906-
if *x* is an ``Element`` and *x* does not belong to *fp*.
907-
908-
:raises LibsemigroupsError:
909-
if *x* is an :any:`int` and *x* is greater than or equal to :any:`FroidurePin.size`.
910938
)pbdoc");
911939

912940
m.def(
@@ -918,28 +946,6 @@ is that the resulting factorisation may not be minimal.
918946
py::arg("x"),
919947
R"pbdoc(
920948
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
921-
:only-document-once:
922-
923-
Returns a word containing a minimal factorisation (in the generators)
924-
of an element.
925-
926-
This function returns the short-lex minimum word (if any) in the generators
927-
that evaluates to *x*.
928-
929-
:param fp: the :any:`FroidurePin` instance.
930-
:type fp: FroidurePin
931-
932-
:param x: a possible element, or index of element, to factorise.
933-
:type x: Element | int
934-
935-
:returns: A word in the generators that evaluates to *x*.
936-
:rtype: list[int]
937-
938-
:raises LibsemigroupsError:
939-
if *x* is an ``Element`` and *x* does not belong to *fp*.
940-
941-
:raises LibsemigroupsError:
942-
if *x* is an :any:`int` and *x* is greater than or equal to :any:`FroidurePin.size`.
943949
)pbdoc");
944950

945951
m.def(
@@ -1219,34 +1225,49 @@ This function returns the element of *fp* obtained by evaluating *w*.
12191225
// Helpers
12201226
////////////////////////////////////////////////////////////////////////
12211227

1222-
m.def("froidure_pin_factorisation",
1223-
[](FroidurePin_& fp, ElementStateful<FroidurePin_> const& x) {
1224-
return froidure_pin::factorisation(fp, to_element(x));
1225-
});
1228+
m.def(
1229+
"froidure_pin_factorisation",
1230+
[](FroidurePin_& fp, ElementStateful<FroidurePin_> const& x) {
1231+
return froidure_pin::factorisation(fp, to_element(x));
1232+
},
1233+
R"pbdoc(
1234+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
1235+
)pbdoc");
12261236

1227-
m.def("froidure_pin_factorisation",
1228-
[](FroidurePin_& fp, Word const& x) {
1229-
return froidure_pin::factorisation(fp, to_element(fp, x));
1230-
});
1237+
m.def(
1238+
"froidure_pin_factorisation",
1239+
[](FroidurePin_& fp, Word const& x) {
1240+
return froidure_pin::factorisation(fp, to_element(fp, x));
1241+
},
1242+
R"pbdoc(
1243+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
1244+
)pbdoc");
12311245

1232-
m.def("froidure_pin_minimal_factorisation",
1233-
[](FroidurePin_& fp, ElementStateful<FroidurePin_> const& x) {
1234-
return froidure_pin::minimal_factorisation(fp, to_element(x));
1235-
});
1246+
m.def(
1247+
"froidure_pin_minimal_factorisation",
1248+
[](FroidurePin_& fp, ElementStateful<FroidurePin_> const& x) {
1249+
return froidure_pin::minimal_factorisation(fp, to_element(x));
1250+
},
1251+
R"pbdoc(
1252+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
1253+
)pbdoc");
12361254

1237-
m.def("froidure_pin_minimal_factorisation",
1238-
[](FroidurePin_& fp, Word const& x) {
1239-
return froidure_pin::minimal_factorisation(fp,
1240-
to_element(fp, x));
1241-
});
1255+
m.def(
1256+
"froidure_pin_minimal_factorisation",
1257+
[](FroidurePin_& fp, Word const& x) {
1258+
return froidure_pin::minimal_factorisation(fp, to_element(fp, x));
1259+
},
1260+
R"pbdoc(
1261+
:sig=(fp: FroidurePin, x: Element | int) -> list[int]:
1262+
)pbdoc");
12421263

12431264
m.def("froidure_pin_to_element",
12441265
[](FroidurePin_& fp, word_type const& w) {
12451266
return from_element(fp, froidure_pin::to_element(fp, w));
12461267
});
12471268
}
12481269
} // bind_froidure_pin_stateful
1249-
} // namespace
1270+
} // namespace
12501271

12511272
void init_froidure_pin(py::module& m) {
12521273
// TODO(0) uncomment bind_froidure_pin<HPCombiTransf<16>>(m, "Transf16");

src/knuth-bendix-impl.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ namespace libsemigroups {
6464
py::class_<typename KnuthBendixImpl<Rewriter>::options> options(thing,
6565
"options",
6666
R"pbdoc(
67-
This class containing various options that can be used to control the
67+
This class contains various options that can be used to control the
6868
behaviour of Knuth-Bendix.)pbdoc");
6969

70+
py::options enum_options;
71+
enum_options.disable_enum_members_docstring();
7072
py::enum_<typename KnuthBendixImpl<Rewriter>::options::overlap>(options,
7173
"overlap",
7274
R"pbdoc(
@@ -78,17 +80,29 @@ The values in this enum determine how a :any:`KnuthBendix`
7880
instance measures the length :math:`d(AB, BC)` of the overlap of
7981
two words :math:`AB` and :math:`BC`.
8082
83+
The valid values are:
84+
85+
.. py:attribute:: overlap.ABC
86+
:value: <overlap.ABC: 0>
87+
88+
:math:`d(AB, BC) = |A| + |B| + |C|`
89+
90+
.. py:attribute:: overlap.AB_BC
91+
:value: <overlap.AB_BC: 1>
92+
93+
:math:`d(AB, BC) = |AB| + |BC|`
94+
95+
.. py:attribute:: overlap.MAX_AB_BC
96+
:value: <overlap.MAX_AB_BC: 2>
97+
98+
:math:`d(AB, BC) = max(|AB|, |BC|)`
99+
81100
.. seealso:: :any:`KnuthBendix.overlap_policy`
82101
)pbdoc")
83-
.value("ABC",
84-
KnuthBendixImpl<Rewriter>::options::overlap::ABC,
85-
R"pbdoc(:math:`d(AB, BC) = |A| + |B| + |C|`)pbdoc")
86-
.value("AB_BC",
87-
KnuthBendixImpl<Rewriter>::options::overlap::AB_BC,
88-
R"pbdoc(:math:`d(AB, BC) = |AB| + |BC|`)pbdoc")
102+
.value("ABC", KnuthBendixImpl<Rewriter>::options::overlap::ABC)
103+
.value("AB_BC", KnuthBendixImpl<Rewriter>::options::overlap::AB_BC)
89104
.value("MAX_AB_BC",
90-
KnuthBendixImpl<Rewriter>::options::overlap::MAX_AB_BC,
91-
R"pbdoc(:math:`d(AB, BC) = max(|AB|, |BC|)`)pbdoc");
105+
KnuthBendixImpl<Rewriter>::options::overlap::MAX_AB_BC);
92106

93107
thing.def("__repr__", [](KnuthBendixImpl<Rewriter>& self) {
94108
return to_human_readable_repr(self);

0 commit comments

Comments
 (0)