fix: correct normalize() documentation to match implementation

The normalize() method's implementation returns a zero vector when
called on a zero-magnitude vector, rather than raising ValueError as
the documentation claimed. Updated the MCRF_RAISES to MCRF_NOTE to
accurately describe the actual behavior.

Also added test coverage in tools/test_vector_docs.py to verify the
normalize() docstring contains the correct Note section.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-10-30 11:25:43 -04:00
parent 91461d0f87
commit 23d7882b93
2 changed files with 9 additions and 1 deletions

View File

@ -22,7 +22,7 @@ PyMethodDef PyVector::methods[] = {
MCRF_SIG("()", "Vector"),
MCRF_DESC("Return a unit vector in the same direction."),
MCRF_RETURNS("Vector: New normalized vector with magnitude 1.0")
MCRF_RAISES("ValueError", "If vector has zero magnitude")
MCRF_NOTE("For zero vectors (magnitude 0.0), returns a zero vector rather than raising an exception")
)},
{"dot", (PyCFunction)PyVector::dot, METH_O,
MCRF_METHOD(Vector, dot,

View File

@ -15,5 +15,13 @@ assert "dot(other: Vector)" in dot_doc
assert "Args:" in dot_doc
assert "other:" in dot_doc
# Check Vector.normalize docstring
normalize_doc = mcrfpy.Vector.normalize.__doc__
print("normalize doc:", normalize_doc)
assert "normalize()" in normalize_doc
assert "Return a unit vector" in normalize_doc
assert "Returns:" in normalize_doc
assert "Note:" in normalize_doc
print("SUCCESS: All docstrings present and complete")
sys.exit(0)