Skip to content

Introspection: emit doc comments#5782

Open
Tpt wants to merge 2 commits intoPyO3:mainfrom
Tpt:tpt/stub-doc
Open

Introspection: emit doc comments#5782
Tpt wants to merge 2 commits intoPyO3:mainfrom
Tpt:tpt/stub-doc

Conversation

@Tpt
Copy link
Contributor

@Tpt Tpt commented Feb 5, 2026

Notable changes:

  • get_doc() now returns an intermediate structure. The to_cstr_stream function returns the expected cstr
  • get_doc() now returns an option when there is no doc
  • PyMemberDef.doc is now set to NULL if there is no doc instead of the empty string (NULL is allowed by cpython doc)
  • same for PyGetSetDef.doc

/// Escapes a string to be valid JSON. Does not add quotes around it
///
/// Returns the number of written bytes
pub const fn escape_json_string(input: &str, output: &mut [u8]) -> usize {
Copy link
Contributor Author

@Tpt Tpt Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nearly verbatim cut/paste from src/inspect/mod.rs

Still missing is the support of enum variant and constants doc comments

Notable changes:
- get_doc() now returns an intermediate structure. The `to_cstr_stream` returns the expected cstr
- get_doc() returns now an option when there is no doc
- erroring on nul byte is delegated to `cstr!`
- PyMemberDef.doc is now set to NULL if there is no doc instead of the empty string (NULL is allowed by cpython doc)
- same for PyGetSetDef.doc
@Tpt Tpt marked this pull request as ready for review February 5, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant