Hướng dẫn python class attribute docstring - chuỗi thuộc tính lớp python
Recently I wanted to reuse doc-sting of class attributes to make some user-friendly self-description but could not find a way to access a doc-string of the attribute of the class. Show Consider example:
Accessing doc-sting of an attribute of the class give a docstring of the annotated type. Is it even possible at all, preferably without extra libarries or imports? Các tài liệu theo phong cách Napoleon như chúng được mô tả trong các tài liệu Sphinx (xem lớp Nội dung chính
Và nếu bạn không muốn hành vi này, bạn phải nói rõ ràng cho Sphinx rằng tài liệu xây dựng và tài liệu lớp không giống nhau. Có nghĩa là, bạn chỉ có thể dán thông tin cấu trúc của bạn vào phần thân của tài liệu lớp. Trong trường hợp bạn xây dựng tài liệu từ các tài liệu của mình, đây là những hạt có thể đạt được: 1) Tối thiểu trần:
2) Tham số trình xây dựng bổ sung Mô tả:
3) Mô tả thuộc tính bổ sung:
Các mô tả tham số và thuộc tính tất nhiên cũng có thể được kết hợp, nhưng vì các dữ liệu nên được ánh xạ thẳng về phía trước, tôi không thấy lý do để làm như vậy. Theo tôi, 1) sẽ làm cho các dữ liệu nhỏ hoặc đơn giản - nó đã bao gồm chữ ký của hàm tạo với các loại tương ứng của chúng, rất nhiều cho một DataClass. Nếu bạn muốn nói thêm về mỗi thuộc tính, 3) sẽ phục vụ tốt nhất.1) would do for small or simple dataclasses -- it already includes the constructor signature with their respective types, which is plenty for a dataclass. If you want to say more about each attribute, 3) would serve best. 1) would do for small or simple dataclasses -- it already includes the constructor signature with their respective types, which is plenty for a dataclass. If you want to say more about each attribute, 3) would serve best. 1) would do for small or simple dataclasses -- it already includes the constructor signature with their respective types, which is plenty for a dataclass. If you want to say more about each attribute, 3) would serve best. 1) would do for small or simple dataclasses -- it already includes the constructor signature with their respective types, which is plenty for a dataclass. If you want to say more about each attribute, 3) would serve best. Số phát hành38401 Được tạo ra vào năm 2019-10-08 00:24 bởi John Parejko2, đã thay đổi lần cuối năm 2022-04-11 14:59 bởi Quản trị viên. Vấn đề giờ đã kết thúc.2019-10-08 00:24 by John Parejko2, last changed 2022-04-11 14:59 by admin. This issue is now closed.2019-10-08 00:24 by John Parejko2, last changed 2022-04-11 14:59 by admin. This issue is now closed.2019-10-08 00:24 by John Parejko2, last changed 2022-04-11 14:59 by admin. This issue is now closed.2019-10-08 00:24 by John Parejko2, last changed 2022-04-11 14:59 by admin. This issue is now closed.
GitHub: 82582messages: + msg405772GitHub: 82582 messages: + msg405772you should have proper docstrings for the __init__ method. 2021-12-29 & NBSP; 12: 47: 39messages: + msg3545072021-12-29 & NBSP; 12: 47: 39 messages: + msg354507a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. Nosy: + EGEBESMESSAGES: + MSG409304EGEBES stage: resolvedjust after initialization. In other words, it is called after the object receives values for its fields, such as name , continent , population , and official_lang . __ init __ có một tài liệu?GitHub: 82582 messages: + msg409304 A brief description of the module and its purpose. A list of any classes, exception, functions, and any other objects exported by the module. |