简体   繁体   English

Python 代码的自动完成和文档化

[英]Auto-completion & documentation of Python code

Can I use index.d.ts to enable custom code documentation & auto-completion for Python code as we do in JS?我可以像在 JS 中一样使用index.d.ts为 Python 代码启用自定义代码文档和自动完成吗? if so, how?如果是这样,如何? If not, is there any equivalent for Python?如果没有,Python 是否有任何等价物?

Yes, there have been various additions to Python over time that allow you to do so.是的,随着时间的推移,Python 已经有了各种附加功能,允许您这样做。

As mentioned in the comments, https://www.python.org/dev/peps/pep-0526/ and https://www.python.org/dev/peps/pep-0257/ cover this in part.如评论中所述, https://www.python.org/dev/peps/pep-0526/https://www.python.org/dev/peps/pep-0257/部分涵盖了这一点。

See also the documentation on type hints here https://docs.python.org/3/library/typing.html另请参阅此处有关类型提示的文档https://docs.python.org/3/library/typing.html

Note that if you wanted to know how to provide type hints for a very specific example, you should have probably included some sample code that needed the hints, but hopefully the above helps.请注意,如果您想知道如何为非常具体的示例提供类型提示,您可能应该包含一些需要提示的示例代码,但希望以上内容有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM