Skip to content

Commit

Permalink
Update README for wwatch3 figures notebooks
Browse files Browse the repository at this point in the history
Modernized `make_readme.py` script.
  • Loading branch information
douglatornell committed Jan 31, 2025
1 parent c6df707 commit 6cf5781
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
14 changes: 7 additions & 7 deletions notebooks/figures/wwatch3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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.
56 changes: 32 additions & 24 deletions notebooks/figures/wwatch3/make_readme.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 6cf5781

Please sign in to comment.