From 3bddb7a749824a03e2b1da411aa265a24ce9ed8a Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 21 May 2024 09:56:54 -0400 Subject: [PATCH 1/7] add tutorial gallery to jupyterbook --- .gitignore | 1 + book/_config.yml | 2 + book/_ext/build_gallery.py | 95 ++++++++++++++++++++++++++++++++++++++ book/reference/gallery.yml | 10 ++++ conda/environment.yml | 4 +- 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 book/_ext/build_gallery.py create mode 100644 book/reference/gallery.yml diff --git a/.gitignore b/.gitignore index aeeb83c..b4777b0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ cookiecutter.json /book/_build/html/assets ## Temporary files created by build scripts /team/team.yaml +/book/reference/gallery.txt # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/book/_config.yml b/book/_config.yml index 15e0b5d..8cdb9cf 100644 --- a/book/_config.yml +++ b/book/_config.yml @@ -67,6 +67,8 @@ sphinx: .py: - jupytext.reads - fmt: py:percent + local_extensions: + build_gallery: "_ext" # Add GitHub buttons to your book # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository diff --git a/book/_ext/build_gallery.py b/book/_ext/build_gallery.py new file mode 100644 index 0000000..4e9d645 --- /dev/null +++ b/book/_ext/build_gallery.py @@ -0,0 +1,95 @@ +# from https://github.com/excutablebooks meta/docs/conf.py + +from pathlib import Path +import random +from textwrap import dedent +from urllib.parse import urlparse + +import yaml + +from sphinx.application import Sphinx +from sphinx.util import logging +from sphinx.util.typing import ExtensionMetadata + +LOGGER = logging.getLogger("conf") + +def build_gallery(app: Sphinx): + # Build the gallery file + LOGGER.info("building gallery...") + grid_items = [] + projects = yaml.safe_load((Path(app.srcdir) / "reference/gallery.yml").read_text()) + random.shuffle(projects) + for item in projects: + if not item.get("image"): + item["image"] = "https://jupyterbook.org/_images/logo-square.svg" + + repo_text = "" + star_text = "" + + if item["repository"]: + repo_text = f'{{bdg-link-secondary}}`repo <{item["repository"]}>`' + + try: + url = urlparse(item["repository"]) + if url.netloc == "github.com": + _, org, repo = url.path.rstrip("/").split("/") + star_text = f"[![GitHub Repo stars](https://img.shields.io/github/stars/{org}/{repo}?style=social)]({item['repository']})" + except Exception as error: + pass + + grid_items.append( + f"""\ + `````{{grid-item-card}} {" ".join(item["name"].split())} + :text-align: center + + logo + + +++ + ````{{grid}} 2 2 2 2 + :margin: 0 0 0 0 + :padding: 0 0 0 0 + :gutter: 1 + + ```{{grid-item}} + :child-direction: row + :child-align: start + :class: sd-fs-5 + + {{bdg-link-secondary}}`website <{item["website"]}>` + {repo_text} + ``` + ```{{grid-item}} + :child-direction: row + :child-align: end + + {star_text} + ``` + ```` + ````` + """ + ) + grid_items = "\n".join(grid_items) + +# :column: text-center col-6 col-lg-4 +# :card: +my-2 +# :img-top-cls: w-75 m-auto p-2 +# :body: d-none + + panels = f""" +``````{{grid}} 1 2 3 3 +:gutter: 1 1 2 2 + +{dedent(grid_items)} +`````` + """ + (Path(app.srcdir) / "reference/gallery.txt").write_text(panels) + + +def setup(app: Sphinx) -> ExtensionMetadata: + app.connect('builder-inited', build_gallery) + + return { + 'version': '0.1', + 'parallel_read_safe': True, + 'parallel_write_safe': True, + } \ No newline at end of file diff --git a/book/reference/gallery.yml b/book/reference/gallery.yml new file mode 100644 index 0000000..363d2bd --- /dev/null +++ b/book/reference/gallery.yml @@ -0,0 +1,10 @@ +- name: Data access with earthaccess + website: https://earthaccess.readthedocs.io/en/latest/tutorials/file-access/ + repository: https://github.com/nsidc/earthaccess + image: +- name: Data access with icepyx + website: https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html + repository: https://github.com/icesat2py/icepyx + image: https://icepyx.readthedocs.io/en/latest/_static/icepyx_v2_oval_orig_nobackgr.png + + \ No newline at end of file diff --git a/conda/environment.yml b/conda/environment.yml index b35b149..a7228f0 100644 --- a/conda/environment.yml +++ b/conda/environment.yml @@ -8,14 +8,16 @@ channels: - conda-forge dependencies: - ipyleaflet - - jupyter-book<2 + - jupyter-book - jupyter-resource-usage - jupyterhub-singleuser - jupyterlab - jupytext - pip - python + - sphinx - sphinxcontrib-bibtex + - yaml # For building the Splashpage - cookiecutter # Dependencies of jinja-markdown: From 8db5217264798db56ed1ead892c9d8370bf531a4 Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 21 May 2024 09:57:16 -0400 Subject: [PATCH 2/7] add IS2 resources page draft to JupyterBook --- book/_toc.yml | 1 + book/reference/IS2-resources.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 book/reference/IS2-resources.md diff --git a/book/_toc.yml b/book/_toc.yml index f427aa5..95e65e2 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -32,5 +32,6 @@ parts: chapters: - file: reference/glossary - file: reference/bibliography + - file: reference/IS2-resources - file: reference/questions diff --git a/book/reference/IS2-resources.md b/book/reference/IS2-resources.md new file mode 100644 index 0000000..39c1c9a --- /dev/null +++ b/book/reference/IS2-resources.md @@ -0,0 +1,16 @@ +# ICESat-2 Resources + +A large number of resources exist for helping you get and work with ICESat-2 data. +These range from packages and tutorials created by NSIDC, the DAAC that manages ICESat-2 data, +to community created libraries (such as icepyx and SlideRule) to individual GitHub repositories +created by researchers using ICESat-2 data in their work. + +## Lists of Resources +Both icepyx and NSIDC already have compiled lists of resources for obtaining and working with ICESat-2 data. +We encourage you to check them out, but have not recreated them here so you can always find the latest and greatest. + +## Gallery of Tutorials +The Organizing Team (OT) has compiled this gallery of their favorite tutorials utilizing ICESat-2 data to help you find great example workflows from across disciplines. + +```{include} gallery.txt +``` \ No newline at end of file From 8c8378b9c710fe5346062e6700215c5825a68d6f Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 18 Jun 2024 09:43:49 -0400 Subject: [PATCH 3/7] add sliderule to gallery Co-authored-by: Scott Henderson --- book/_ext/build_gallery.py | 2 +- book/reference/gallery.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/book/_ext/build_gallery.py b/book/_ext/build_gallery.py index 4e9d645..4d6674e 100644 --- a/book/_ext/build_gallery.py +++ b/book/_ext/build_gallery.py @@ -1,4 +1,4 @@ -# from https://github.com/excutablebooks meta/docs/conf.py +# from https://github.com/executablebooks/meta/blob/b627cdf10477e4bdf651bc86043a3fca1cc8d130/docs/conf.py from pathlib import Path import random diff --git a/book/reference/gallery.yml b/book/reference/gallery.yml index 363d2bd..f3674e7 100644 --- a/book/reference/gallery.yml +++ b/book/reference/gallery.yml @@ -6,5 +6,8 @@ website: https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html repository: https://github.com/icesat2py/icepyx image: https://icepyx.readthedocs.io/en/latest/_static/icepyx_v2_oval_orig_nobackgr.png - +- name: Data access with sliderule + website: https://slideruleearth.io/rtd/getting_started/Examples.html + repository: https://github.com/SlideRuleEarth/sliderule + image: https://avatars.githubusercontent.com/u/63428847?s=200&v=4 \ No newline at end of file From a04e52ccd5f016ee4d833c7e8adcdef45f8149ab Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 18 Jun 2024 09:50:41 -0400 Subject: [PATCH 4/7] remove env changes (yaml and sphinx are already dependencies --- conda/environment.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/conda/environment.yml b/conda/environment.yml index a7228f0..843f105 100644 --- a/conda/environment.yml +++ b/conda/environment.yml @@ -15,9 +15,7 @@ dependencies: - jupytext - pip - python - - sphinx - sphinxcontrib-bibtex - - yaml # For building the Splashpage - cookiecutter # Dependencies of jinja-markdown: From 6eed50f7036e3ae48cd6f0c797956d0709164b39 Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 18 Jun 2024 09:57:44 -0400 Subject: [PATCH 5/7] add links to resources page --- book/reference/IS2-resources.md | 4 ++-- book/reference/gallery.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/book/reference/IS2-resources.md b/book/reference/IS2-resources.md index 39c1c9a..c8d8d1e 100644 --- a/book/reference/IS2-resources.md +++ b/book/reference/IS2-resources.md @@ -2,11 +2,11 @@ A large number of resources exist for helping you get and work with ICESat-2 data. These range from packages and tutorials created by NSIDC, the DAAC that manages ICESat-2 data, -to community created libraries (such as icepyx and SlideRule) to individual GitHub repositories +to community created libraries (such as [icepyx](https://icepyx.readthedocs.io/en/latest/) and [SlideRule](https://slideruleearth.io/)) to individual GitHub repositories created by researchers using ICESat-2 data in their work. ## Lists of Resources -Both icepyx and NSIDC already have compiled lists of resources for obtaining and working with ICESat-2 data. +Both [icepyx](https://icepyx.readthedocs.io/en/latest/community/resources.html) and [NSIDC](https://nsidc.org/data/icesat-2/tools) already have compiled lists of resources for obtaining and working with ICESat-2 data. We encourage you to check them out, but have not recreated them here so you can always find the latest and greatest. ## Gallery of Tutorials diff --git a/book/reference/gallery.yml b/book/reference/gallery.yml index f3674e7..5bf940d 100644 --- a/book/reference/gallery.yml +++ b/book/reference/gallery.yml @@ -6,7 +6,7 @@ website: https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html repository: https://github.com/icesat2py/icepyx image: https://icepyx.readthedocs.io/en/latest/_static/icepyx_v2_oval_orig_nobackgr.png -- name: Data access with sliderule +- name: Data access with SlideRule website: https://slideruleearth.io/rtd/getting_started/Examples.html repository: https://github.com/SlideRuleEarth/sliderule image: https://avatars.githubusercontent.com/u/63428847?s=200&v=4 From 870d9be18b30f6e3037f779570dac760aedabcb9 Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 18 Jun 2024 10:16:04 -0400 Subject: [PATCH 6/7] add atl08 tutorial to gallery --- book/reference/IS2-resources.md | 6 +++--- book/reference/gallery.yml | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/book/reference/IS2-resources.md b/book/reference/IS2-resources.md index c8d8d1e..7456aef 100644 --- a/book/reference/IS2-resources.md +++ b/book/reference/IS2-resources.md @@ -2,15 +2,15 @@ A large number of resources exist for helping you get and work with ICESat-2 data. These range from packages and tutorials created by NSIDC, the DAAC that manages ICESat-2 data, -to community created libraries (such as [icepyx](https://icepyx.readthedocs.io/en/latest/) and [SlideRule](https://slideruleearth.io/)) to individual GitHub repositories -created by researchers using ICESat-2 data in their work. +to community created libraries (such as [icepyx](https://icepyx.readthedocs.io/en/latest/) and [SlideRule](https://slideruleearth.io/)), +to individual GitHub repositories created by researchers using ICESat-2 data in their work. ## Lists of Resources Both [icepyx](https://icepyx.readthedocs.io/en/latest/community/resources.html) and [NSIDC](https://nsidc.org/data/icesat-2/tools) already have compiled lists of resources for obtaining and working with ICESat-2 data. We encourage you to check them out, but have not recreated them here so you can always find the latest and greatest. ## Gallery of Tutorials -The Organizing Team (OT) has compiled this gallery of their favorite tutorials utilizing ICESat-2 data to help you find great example workflows from across disciplines. +The Organizing Team (OT) has compiled this gallery of their favorite tutorials and tools for getting and utilizing ICESat-2 data to help you find great example workflows from across disciplines. ```{include} gallery.txt ``` \ No newline at end of file diff --git a/book/reference/gallery.yml b/book/reference/gallery.yml index 5bf940d..f029d06 100644 --- a/book/reference/gallery.yml +++ b/book/reference/gallery.yml @@ -10,4 +10,8 @@ website: https://slideruleearth.io/rtd/getting_started/Examples.html repository: https://github.com/SlideRuleEarth/sliderule image: https://avatars.githubusercontent.com/u/63428847?s=200&v=4 +- name: Download and plot ATL08 + website: https://nasa-openscapes.github.io/2023-ssc/tutorials/data-access/icepyx.html + repository: https://github.com/NASA-Openscapes/2023-ssc + imate: https://raw.githubusercontent.com/NASA-Openscapes/media/main/images/scc/espacio-logo.png \ No newline at end of file From ddf21b58cd950ad000e14d3fc726bca45f3c7dea Mon Sep 17 00:00:00 2001 From: Jessica Scheick Date: Tue, 18 Jun 2024 10:19:28 -0400 Subject: [PATCH 7/7] fix typo --- book/reference/gallery.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/reference/gallery.yml b/book/reference/gallery.yml index f029d06..3fdc723 100644 --- a/book/reference/gallery.yml +++ b/book/reference/gallery.yml @@ -13,5 +13,5 @@ - name: Download and plot ATL08 website: https://nasa-openscapes.github.io/2023-ssc/tutorials/data-access/icepyx.html repository: https://github.com/NASA-Openscapes/2023-ssc - imate: https://raw.githubusercontent.com/NASA-Openscapes/media/main/images/scc/espacio-logo.png + image: https://raw.githubusercontent.com/NASA-Openscapes/media/main/images/scc/espacio-logo.png \ No newline at end of file