Title: Implement `__doc__` to except signature · Issue #2907 · RustPython/RustPython · GitHub
Open Graph Title: Implement `__doc__` to except signature · Issue #2907 · RustPython/RustPython
X Title: Implement `__doc__` to except signature · Issue #2907 · RustPython/RustPython
Description: This is nice! It does introduce an issue though, __doc__ now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons _PyType_DocWithoutSignature). Originally posted...
Open Graph Description: This is nice! It does introduce an issue though, __doc__ now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons _PyType...
X Description: This is nice! It does introduce an issue though, __doc__ now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons _Py...
Opengraph URL: https://github.com/RustPython/RustPython/issues/2907
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement `__doc__` to except signature","articleBody":"> This is nice! It does introduce an issue though, `__doc__` now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons `_PyType_DocWithoutSignature`).\r\n>\r\n> _Originally posted by @DimitrisJim in https://github.com/RustPython/RustPython/issues/2904#issuecomment-900752179_\r\n\r\n# Overview\r\n\r\nDocumentations of methods, types in CPython can have format like below:\r\n\r\n```\r\n\u003cSIGNATURE>\r\n--\r\n\r\n\u003cDOCUMENT>\r\n```\r\n\r\nAnd CPython's `__doc__` property strips the signature through `_PyType_DocWithoutSignature`. Then, when you call `\u003c?>.__doc__`, you will see only `\u003cDOCUMENT>`. But RustPython hasn't implemented it so it should be implemented.\r\n\r\n# Example\r\n\r\nLet's see the case of `object` type.\r\n\r\nThe full doc is:\r\n\r\n```c\r\nPyDoc_STRVAR(object_doc,\r\n\"object()\\n--\\n\\n\"\r\n\"The base class of the class hierarchy.\\n\\n\"\r\n\"When called, it accepts no arguments and returns a new featureless\\n\"\r\n\"instance that has no instance attributes and cannot be given any.\\n\");\r\n```\r\n\r\nAs human-familiar:\r\n\r\n```\r\nobject()\r\n--\r\n\r\nThe base class of the class hierarchy.\r\n\r\nWhen called, it accepts no arguments and returns a new featureless\r\nInstance that has no instance attributes and cannot be given any.\r\n\r\n```\r\n\r\nAnd when call `print(object.__doc__)` in CPython 3.8.0, you will see:\r\n\r\n```\r\nThe base class of the class hierarchy.\r\n\r\nWhen called, it accepts no arguments and returns a new featureless\r\ninstance that has no instance attributes and cannot be given any.\r\n\r\n```\r\n\r\n# References\r\n\r\n- `_PyType_DocWithoutSignature` implementation: https://github.com/python/cpython/blob/fa919fdf2583bdfead1df00e842f24f30b2a34bf/Objects/typeobject.c#L158-L169","author":{"url":"https://github.com/moreal","@type":"Person","name":"moreal"},"datePublished":"2021-08-18T12:20:28Z","url":"https://github.com/RustPython/RustPython/issues/2907"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:919a9ff5-aed3-623f-31a3-d49ef9d39b0e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D240:3D97C8:3860035:4AEF360:6B0214B4 |
| html-safe-nonce | f779f18d92a6c89ce7dbaff80589907a0ac84c1ef67e3e790da3c2c5b3270fbe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjQwOjNEOTdDODozODYwMDM1OjRBRUYzNjA6NkIwMjE0QjQiLCJ2aXNpdG9yX2lkIjoiNzUxNDk2MzQ4NTczMDY3Mzg0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cfde077f8d69ed17f58eb6b645748e71ab386d9f1cf5e242db0096208a700ed8 |
| hovercard-subject-tag | issue:973605632 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/2907/issue_layout |
| twitter:image | https://opengraph.githubassets.com/543f2e6aac36853c6c913dd9160fff9f7202f51d491c0e37aca386532781bc78/RustPython/RustPython/issues/2907 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/543f2e6aac36853c6c913dd9160fff9f7202f51d491c0e37aca386532781bc78/RustPython/RustPython/issues/2907 |
| og:image:alt | This is nice! It does introduce an issue though, __doc__ now contains that text signature in its contents, you'll need to tweak doc to ignore the signature at the start (similar to CPythons _PyType... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | moreal |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width