From 6cf57816446208cdac31d770ca8d6cbc8fd8462a Mon Sep 17 00:00:00 2001 From: Doug Latornell Date: Fri, 31 Jan 2025 13:37:03 -0800 Subject: [PATCH] Update README for wwatch3 figures notebooks Modernized `make_readme.py` script. --- notebooks/figures/wwatch3/README.md | 14 +++--- notebooks/figures/wwatch3/make_readme.py | 56 ++++++++++++++---------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/notebooks/figures/wwatch3/README.md b/notebooks/figures/wwatch3/README.md index 50bb6768..ce622276 100644 --- a/notebooks/figures/wwatch3/README.md +++ b/notebooks/figures/wwatch3/README.md @@ -3,10 +3,10 @@ the results figures generation modules of the SalishSeaCast automation system. The links below are to static renderings of the notebooks via [nbviewer.org](https://nbviewer.org/). -Descriptions under the links below are from the first cell of the notebooks +Descriptions below the links are from the first cell of the notebooks (if that cell contains Markdown or raw text). -* ## [TestWaveHeightPeriod.ipynb](https://nbviewer.org/github/SalishSeaCast/SalishSeaNowcast/blob/main/wwatch3/TestWaveHeightPeriod.ipynb) +* ## [TestWaveHeightPeriod.ipynb](https://nbviewer.org/github/SalishSeaCast/SalishSeaNowcast/blob/main/notebooks/figures/wwatch3/TestWaveHeightPeriod.ipynb) **Test `wave_height_period` Figure Module** @@ -15,19 +15,19 @@ Descriptions under the links below are from the first cell of the notebooks Set-up and function call replicates as nearly as possible what is done in the `nowcast.workers.make_plots` worker. -* ## [DevelopWaveHeightPeriod.ipynb](https://nbviewer.org/github/SalishSeaCast/SalishSeaNowcast/blob/main/wwatch3/DevelopWaveHeightPeriod.ipynb) +* ## [DevelopWaveHeightPeriod.ipynb](https://nbviewer.org/github/SalishSeaCast/SalishSeaNowcast/blob/main/notebooks/figures/wwatch3/DevelopWaveHeightPeriod.ipynb) **Develop `wave_height_period` Figure Module** Development of functions for `nowcast.figures.wwatch3.wave_height_period` web site figure module. -##License +## License -These notebooks and files are copyright 2013 – present -by the SalishSeaCast Project Contributors +These notebooks and files are copyright by the +[SalishSeaCast Project Contributors](https://github.com/SalishSeaCast/docs/blob/main/CONTRIBUTORS.rst) and The University of British Columbia. They are licensed under the Apache License, Version 2.0. https://www.apache.org/licenses/LICENSE-2.0 -Please see the LICENSE file for details of the license. +Please see the LICENSE file in this repository for details of the license. diff --git a/notebooks/figures/wwatch3/make_readme.py b/notebooks/figures/wwatch3/make_readme.py index 97269ecd..d65d830c 100644 --- a/notebooks/figures/wwatch3/make_readme.py +++ b/notebooks/figures/wwatch3/make_readme.py @@ -1,66 +1,74 @@ -# Copyright 2013 – present by the SalishSeaCast Project contributors -# and The University of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. """Jupyter Notebook collection README generator +Copyright by the SalishSeaCast Project contributors and The University of British Columbia. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + When you add a new notebook to this directory, rename a notebook, or change the description of a notebook in its first Markdown cell, please generate a updated `README.md` file with: - python3 -m make_readme + python -m make_readme and commit and push the updated `README.md` to GitHub. """ + +# SPDX-License-Identifier: Apache-2.0 + + import json -import re from pathlib import Path +import re NBVIEWER = "https://nbviewer.org/github" GITHUB_ORG = "SalishSeaCast" REPO_NAME = "SalishSeaNowcast" +DEFAULT_BRANCH_NAME = "main" TITLE_PATTERN = re.compile("#{1,6} ?") def main(): - url = f"{NBVIEWER}/{GITHUB_ORG}/{REPO_NAME}/blob/master/{Path.cwd().name}" + cwd_parts = Path.cwd().parts + repo_path = Path(*cwd_parts[cwd_parts.index(REPO_NAME) + 1 :]) + url = f"{NBVIEWER}/{GITHUB_ORG}/{REPO_NAME}/blob/{DEFAULT_BRANCH_NAME}/{repo_path}" - readme = """\ + readme = f"""\ The Jupyter Notebooks in this directory are for development and testing of the results figures generation modules of the SalishSeaCast automation system. The links below are to static renderings of the notebooks via [nbviewer.org](https://nbviewer.org/). -Descriptions under the links below are from the first cell of the notebooks +Descriptions below the links are from the first cell of the notebooks (if that cell contains Markdown or raw text). """ for fn in Path(".").glob("*.ipynb"): - readme += f"* ## [{fn}]({url}/{fn}) \n \n" + readme += f"* ## [{fn}]({url}/{fn})\n\n" readme += notebook_description(fn) license = f""" -##License +## License -These notebooks and files are copyright 2013 – present -by the SalishSeaCast Project Contributors +These notebooks and files are copyright by the +[SalishSeaCast Project Contributors](https://github.com/SalishSeaCast/docs/blob/main/CONTRIBUTORS.rst) and The University of British Columbia. They are licensed under the Apache License, Version 2.0. https://www.apache.org/licenses/LICENSE-2.0 -Please see the LICENSE file for details of the license. +Please see the LICENSE file in this repository for details of the license. """ + with open("README.md", "wt") as f: f.writelines(readme) f.writelines(license)