Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor docstring generation code #2904

Merged
merged 1 commit into from
Jan 27, 2023
Merged

refactor docstring generation code #2904

merged 1 commit into from
Jan 27, 2023

Conversation

davidhewitt
Copy link
Member

@davidhewitt davidhewitt commented Jan 24, 2023

As a first step towards #2866 this is a tweak to the macro code which generates Python docstrings. This PR refactors the behaviour so that instead of always creating a concat! expression to generate a nul-terminated string, this will only happen if a Rust 1.54+ macro doc is present (e.g. #[doc = include_str!(...)]).

The default case now just collects all the #[doc] attributes into a single string.

This should make it easier to factor out the text_signature formatting, and avoids wasting compile time invoking the concat! macro when not necessary.

@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Jan 24, 2023
pyo3-macros-backend/src/utils.rs Outdated Show resolved Hide resolved
pyo3-macros-backend/src/utils.rs Outdated Show resolved Hide resolved
@davidhewitt
Copy link
Member Author

bors r=mejrs

@bors
Copy link
Contributor

bors bot commented Jan 27, 2023

Build succeeded:

@bors bors bot merged commit 083dd5f into PyO3:main Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants