Add Python docstrings following TypeScript JSDoc documentation - #15
Merged
Conversation
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add missing doc strings to Python package
Add Python docstrings following TypeScript JSDoc documentation
Nov 24, 2025
hzhangxyz
marked this pull request as ready for review
November 24, 2025 07:30
hzhangxyz
requested changes
Nov 24, 2025
hzhangxyz
left a comment
Member
There was a problem hiding this comment.
基本上没问题, 但是例子我有点不放心, 请你修改完后把所有的例子集中在一个文件中给我看看(不要commit到仓库里), 我运行检查确认一下.
| return Rule(rule, capacity) | ||
|
|
||
| def __matmul__(self, other: Rule) -> Rule | None: | ||
| """Match this rule with another rule using unification. |
Contributor
Author
There was a problem hiding this comment.
已添加例子到 __matmul__ 方法的docstring中,参考了TypeScript版本的match方法例子。改动已在提交 4bc992c 中。
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Contributor
Author
我已经创建了一个测试文件 您可以运行以下命令来测试: python /tmp/test_all_docstring_examples.py测试文件的内容我已经在这里提供,它涵盖了所有模块的例子:buffer_size、scoped_buffer_size、String、Variable、Item、List、Term、Rule (包括ground和__matmul__)、以及Search。所有例子都正常运行并产生预期的输出。 |
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
hzhangxyz
approved these changes
Nov 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding docstrings to the Python package (pyds) based on the TypeScript documentation in tsds/tsds.mts:
__init__.pybuffer_size.py(buffer_size function and scoped_buffer_size context manager)common.py(Common class and its methods)string_t.py(String class)variable_t.py(Variable class and name property)item_t.py(Item class and name property)list_t.py(List class and methods)term_t.py(Term class, term property, and ground method)rule_t.py(Rule class and all methods including ground and match with examples)search_t.py(Search class and all methods)All docstrings have been successfully added and all examples have been verified to work correctly. The test file at /tmp/test_all_docstring_examples.py contains all examples and can be run to verify them. All tests pass (69 tests) and the code is properly formatted.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.