docs: document regular expression function arguments - #1684
docs: document regular expression function arguments#1684stantheman0128 wants to merge 2 commits into
Conversation
regexp_instr documents its parameters in an Args section, the other four regexp functions document none. Adds Args to regexp_like, regexp_match, regexp_replace and regexp_count, reusing the wording regexp_instr already uses for the parameters they share.
ntjohnson1
left a comment
There was a problem hiding this comment.
Nit about not repeating information already captured in doc string since we can test the validity of doc strings but can't test the free text stays up to date. Applies to all the optional call outs.
| Args: | ||
| string: Data to test against the regular expression. | ||
| regex: Regular expression to search for. | ||
| flags: Optional regular expression flags to control regex behavior. |
There was a problem hiding this comment.
| flags: Optional regular expression flags to control regex behavior. | |
| flags: Flags to control regex behavior. |
NIT: Optional is implied by the = None
Per review: the signature already says these are optional, and unlike the docstring itself that free text cannot be tested for staying accurate.
|
Applied to all five: the three plain Worth flagging, since your reasoning has a consequence I did not expect. I can include |
Which issue does this PR close?
Related to #1463.
Rationale for this change
regexp_instrdocuments every parameter it takes in anArgs:section. The fourother
regexp_*functions document none. Someone reading the generated API docs tofind out what
flagsaccepts, or wherestartcounts from, gets an answer for onefunction in the family and nothing for the rest.
This is the same kind of small focused pass as #1527, applied to the regular
expression family.
What changes are included in this PR?
Adds an
Args:section to four functions inpython/datafusion/functions/__init__.py:regexp_likeregexp_matchregexp_replaceregexp_countWhere a parameter also exists on
regexp_instr(regex,start,flags), thewording follows what
regexp_instralready says, so the family reads consistently.The
flagsentry onregexp_replacealso records thegbehavior that the proseabove it and its own example already show.
Nothing else in the file changes. Signatures, type hints, runtime code, and existing
examples are untouched.
Are there any user-facing changes?
Yes, documentation only. The generated API docs now list argument descriptions for
these four functions. Runtime behavior is unchanged.
Validation
Pre-commit, scoped to the changed file:
Ruff on its own, pinned to the version in
.pre-commit-config.yaml:The repository enables
--doctest-modulesoverpython/datafusion, so the examplesin these docstrings run as tests. Against a locally built extension:
Whitespace:
$ git diff --checkLLM-generated code disclosure
These docstring additions were prepared with the assistance of Claude and reviewed
against each function signature before submission.