Skip to content

Commit cb034ac

Browse files
cong-common: correct the doc for default ctors
1 parent 5c765f1 commit cb034ac

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/cong-common.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ namespace libsemigroups {
7272

7373
fmt::format_to(std::back_inserter(result),
7474
fmt_string,
75-
"detail"_a = extra_doc.detail,
76-
"example"_a = extra_doc.example,
77-
"name"_a = name,
75+
"detail"_a = extra_doc.detail,
76+
"example"_a = extra_doc.example,
77+
"extra_kwargs"_a = extra_doc.extra_kwargs,
78+
"extra_kwargs_doc"_a = extra_doc.extra_kwargs_doc,
79+
"name"_a = name,
7880
"only_document_once"_a
7981
= extra_doc.only_document_once ? only_doc_once : "",
8082
"raises"_a = extra_doc.raises,
@@ -92,11 +94,15 @@ namespace libsemigroups {
9294
doc extra_doc) {
9395
thing.def(py::init<>(),
9496
make_doc(R"pbdoc(
95-
:sig=() -> None:
97+
:sig=(word: type{extra_kwargs}) -> None:
9698
{only_document_once}
9799
98-
Default constructor. This function default constructs an
99-
uninitialised :any:`{name}` instance.
100+
Default constructor.
101+
102+
This function default constructs an uninitialised :any:`{name}` instance.
103+
104+
:Keyword Arguments:
105+
* **word** (*type*) -- the type of words to use, must be either ``str`` or ``list[int]``{extra_kwargs_doc}
100106
101107
{detail}
102108
)pbdoc",

src/cong-common.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ namespace libsemigroups {
3333
// declared below.
3434
struct doc {
3535
std::string_view detail = "";
36+
std::string_view example = "";
37+
std::string_view extra_kwargs = "";
38+
std::string_view extra_kwargs_doc = "";
3639
bool only_document_once = false;
3740
std::string_view raises = "";
3841
std::string_view var = "";
39-
std::string_view example = "";
4042
};
4143

4244
////////////////////////////////////////////////////////////////////////

src/knuth-bendix.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ nested class :any:`KnuthBendix.options`.
7878

7979
////////////////////////////////////////////////////////////////////////
8080

81-
def_construct_default(thing, "KnuthBendix");
81+
def_construct_default(
82+
thing,
83+
"KnuthBendix",
84+
doc{.extra_kwargs = ", rewriter: str", .extra_kwargs_doc = R"pbdoc(
85+
* **rewriter** (*str*) -- the type of rewriter to use, must be either ``"RewriteTrie"`` or ``"RewriteFromLeft"``.)pbdoc"sv});
86+
8287
def_init_default(thing, "KnuthBendix");
8388
def_construct_kind_presentation(thing, "KnuthBendix");
8489
def_init_kind_presentation(thing, "KnuthBendix");
@@ -117,9 +122,9 @@ the current rules in the :py:class:`KnuthBendix` instance.
117122
// Helper functions - specific to KnuthBendix
118123
////////////////////////////////////////////////////////////////////////
119124

120-
// This does not use def_normal_forms in cong-common.hpp because it does
121-
// not return an Iterator object, and hence has its own implementation
122-
// and doc.
125+
// This does not use def_normal_forms in cong-common.hpp because it
126+
// does not return an Iterator object, and hence has its own
127+
// implementation and doc.
123128
m.def(
124129
"knuth_bendix_normal_forms",
125130
[](KnuthBendix_& ci) { return congruence_common::normal_forms(ci); },
@@ -336,7 +341,7 @@ Copy a :any:`NormalFormRange` object.
336341
});
337342
thing.def("next", [](NormalFormRange& nfr) { nfr.next(); });
338343
} // bind_normal_form_range
339-
} // namespace
344+
} // namespace
340345

341346
template <typename Word>
342347
void bind_redundant_rule(py::module& m) {

0 commit comments

Comments
 (0)