This is an automated email from the ASF dual-hosted git repository.
gengliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 4748d858b44 [SPARK-44820][DOCS] Switch languages consistently across
docs for all code snippets
4748d858b44 is described below
commit 4748d858b4478ea7503b792050d4735eae83b3cd
Author: panbingkun <[email protected]>
AuthorDate: Thu Aug 24 17:48:23 2023 -0700
[SPARK-44820][DOCS] Switch languages consistently across docs for all code
snippets
### What changes were proposed in this pull request?
The pr aims to fix bug for `Switch languages consistently across docs for
all code snippets`.
### Why are the changes needed?
When a user chooses a different language for a code snippet, all code
snippets on that page should switch to the chosen language. This was the
behavior for, for example, Spark 2.0 doc:
https://spark.apache.org/docs/2.0.0/structured-streaming-programming-guide.html
But it was broken for later docs, for example the Spark 3.4.1 doc:
https://spark.apache.org/docs/latest/quick-start.html
We should fix this behavior change and possibly add test cases to prevent
future regressions.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Manually test:
```
cd docs
SKIP_API=1 bundle exec jekyll serve --watch
```
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #42657 from panbingkun/SPARK-44820.
Authored-by: panbingkun <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
---
docs/js/main.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/docs/js/main.js b/docs/js/main.js
index 8426ddc7818..97434146556 100755
--- a/docs/js/main.js
+++ b/docs/js/main.js
@@ -65,12 +65,21 @@ function codeTabs() {
tabBar.append(
'<li class="nav-item"><button class="' +
- active + 'nav-link tab_' + lang + '" data-bs-target="#' + id +
- '" data-bs-toggle="tab">' + buttonLabel + '</button></li>'
+ active + 'nav-link tab_' + lang + '" data-bs-target="#' +
+ id + '" data-tab-lang="tab_' + lang + '" data-bs-toggle="tab">' +
+ buttonLabel + '</button></li>'
);
});
counter++;
});
+ $("ul.nav-tabs button").click(function (e) {
+ // Toggling a tab should switch all tabs corresponding to the same language
+ // while retaining the scroll position
+ e.preventDefault();
+ var scrollOffset = $(this).offset().top - $(document).scrollTop();
+ $("." + $(this).attr('data-tab-lang')).tab('show');
+ $(document).scrollTop($(this).offset().top - scrollOffset);
+ });
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]