-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from mansenfranzen/support_sphinx_4.3#62
Support sphinx 4.3#62
- Loading branch information
Showing
13 changed files
with
193 additions
and
56 deletions.
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""This module contains compatibility functions to abstract away implementation | ||
differences between different sphinx versions. | ||
""" | ||
|
||
from typing import Tuple | ||
|
||
import sphinx | ||
from sphinx.addnodes import desc_sig_punctuation, desc_annotation, pending_xref | ||
|
||
|
||
def desc_annotation_default_value(value: str): | ||
"""Provides compatibility abstraction for `desc_annotation` for default | ||
values for sphinx version smaller and greater equal sphinx 4.3. | ||
""" | ||
|
||
if sphinx.version_info >= (4, 3): | ||
from sphinx.addnodes import desc_sig_space | ||
return (desc_sig_space, | ||
[desc_sig_punctuation, "="], | ||
desc_sig_space, | ||
value) | ||
else: | ||
return [desc_annotation, f" = {value}"] | ||
|
||
|
||
def desc_annotation_type_annotation(type_str: str) -> Tuple: | ||
"""Provides compatibility abstraction for `desc_annotation` for type | ||
annotation for sphinx version smaller and greater equal sphinx 4.3. | ||
""" | ||
|
||
if sphinx.version_info >= (4, 3): | ||
from sphinx.addnodes import desc_sig_space | ||
return ([desc_sig_punctuation, ":"], | ||
desc_sig_space, | ||
[pending_xref, type_str]) | ||
else: | ||
return (": ", [pending_xref, type_str]) | ||
|
||
|
||
def desc_annotation_directive_prefix(prefix: str): | ||
"""Provides compatibility abstraction for `desc_annotation` for directive | ||
prefix for sphinx version smaller and greater equal sphinx 4.3. | ||
""" | ||
|
||
if sphinx.version_info >= (4, 3): | ||
from sphinx.addnodes import desc_sig_space | ||
return (prefix, desc_sig_space) | ||
return prefix + " " |
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
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.