-
Notifications
You must be signed in to change notification settings - Fork 12
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
Process docstring cli testing #215
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2367a83
extensions: add functions for direct usage for cli and testing
jnikula 9801fbb
test: use extensions for parser test process docstring calls
jnikula da2a686
cli: add --process-docstring for extension based docstring processing
jnikula f6b73d3
test: handle process docstring in cli tests
jnikula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright (c) 2023, Jani Nikula <[email protected]> | ||
# Licensed under the terms of BSD 2-Clause, see LICENSE for details. | ||
|
||
from sphinx.ext.napoleon import _process_docstring | ||
from sphinx.ext import napoleon | ||
|
||
def _process_docstring_proxy(app, lines, transform, options): | ||
if transform != app.config.hawkmoth_napoleon_transform: | ||
|
@@ -12,7 +12,14 @@ def _process_docstring_proxy(app, lines, transform, options): | |
# directly, but the alternative is duplicating all it does, which is also | ||
# ugly. | ||
|
||
return _process_docstring(app, None, None, None, options, lines) | ||
return napoleon._process_docstring(app, None, None, None, options, lines) | ||
|
||
def process_docstring(lines): | ||
"""Simple interface for CLI and testing.""" | ||
comment = '\n'.join(lines) | ||
config = napoleon.Config(napoleon_use_rtype=False) | ||
comment = str(napoleon.docstring.GoogleDocstring(comment, config)) | ||
lines[:] = comment.splitlines()[:] | ||
|
||
def setup(app): | ||
app.setup_extension('sphinx.ext.napoleon') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider raising
DeprecationWarning
🤷♂️There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: we may also want to institutionalize a deprecation policy so we have a regular, well advertised schedule for dropping things. We have an important user now and everything <.<
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the deprecation has been haphazard so far. If it's release based, I guess it'll have to be major releases. And we're not even at 1.0. 😁