You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ze...@apache.org on 2021/11/20 10:47:24 UTC
[spark] branch branch-3.2 updated: [SPARK-37390][PYTHON][DOCS] Add default value to getattr(app, add_javascript)
This is an automated email from the ASF dual-hosted git repository.
zero323 pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.2 by this push:
new 51eef12 [SPARK-37390][PYTHON][DOCS] Add default value to getattr(app, add_javascript)
51eef12 is described below
commit 51eef12b623b1481bc97d48a53b1fc6a763cb6f6
Author: zero323 <ms...@gmail.com>
AuthorDate: Sat Nov 20 11:45:27 2021 +0100
[SPARK-37390][PYTHON][DOCS] Add default value to getattr(app, add_javascript)
### What changes were proposed in this pull request?
This PR adds `default` (`None`) value to `getattr(app, add_javascript)`.
### Why are the changes needed?
Current logic fails on `getattr(app, "add_javascript")` when executed with Sphinx 4.x. The problem can be illustrated with a simple snippet.
```python
>>> class Sphinx:
... def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None: ...
...
>>> app = Sphinx()
>>> getattr(app, "add_js_file", getattr(app, "add_javascript"))
Traceback (most recent call last):
File "<ipython-input-11-442ab6dfc933>", line 1, in <module>
getattr(app, "add_js_file", getattr(app, "add_javascript"))
AttributeError: 'Sphinx' object has no attribute 'add_javascript'
```
After this PR is merged we'll fallback to `getattr(app, "add_js_file")`:
```python
>>> getattr(app, "add_js_file", getattr(app, "add_javascript", None))
<bound method Sphinx.add_js_file of <__main__.Sphinx object at 0x7f444456abe0>>
```
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Manual docs build.
Closes #34669 from zero323/SPARK-37390.
Authored-by: zero323 <ms...@gmail.com>
Signed-off-by: zero323 <ms...@gmail.com>
(cherry picked from commit b9e9167f589db372f0416425cdf35b48a6216b50)
Signed-off-by: zero323 <ms...@gmail.com>
---
python/docs/source/conf.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/docs/source/conf.py b/python/docs/source/conf.py
index 5cf164d..e1bc400 100644
--- a/python/docs/source/conf.py
+++ b/python/docs/source/conf.py
@@ -398,7 +398,7 @@ epub_exclude_files = ['search.html']
#epub_use_index = True
def setup(app):
# The app.add_javascript() is deprecated.
- getattr(app, "add_js_file", getattr(app, "add_javascript"))('copybutton.js')
+ getattr(app, "add_js_file", getattr(app, "add_javascript", None))('copybutton.js')
# Skip sample endpoint link (not expected to resolve)
linkcheck_ignore = [r'https://kinesis.us-east-1.amazonaws.com']
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org