forked from tardis-sn/tardis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.rst in post-release (tardis-sn#2037)
* Fix docs badge * Add license badge * First attempt of creating credits.rst and README.rst via templates * Working version * Restore old README.rst * Update post-release workflow * Change .gitignore * Various fixes
- Loading branch information
Showing
6 changed files
with
163 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"""Script for updating `credits.rst` and `README.rst` between releases, | ||
requires the `rst-include` package""" | ||
|
||
import pathlib | ||
import re | ||
import textwrap | ||
import warnings | ||
|
||
import requests | ||
from rst_include import rst_include | ||
|
||
|
||
def generate_zenodo(): | ||
"""Generates `zenodo.rst` file with BibTeX citation | ||
Adapted from: https://astrodata.nyc/posts/2021-04-23-zenodo-sphinx/""" | ||
|
||
CONCEPT_DOI = "592480" # See: https://help.zenodo.org/#versioning | ||
zenodo_path = pathlib.Path("docs/resources/zenodo.rst") | ||
|
||
try: | ||
headers = {"accept": "application/x-bibtex"} | ||
response = requests.get( | ||
f"https://zenodo.org/api/records/{CONCEPT_DOI}", headers=headers | ||
) | ||
response.encoding = "utf-8" | ||
citation = re.findall("@software{(.*)\,", response.text) | ||
zenodo_record = ( | ||
f".. |ZENODO| replace:: {citation[0]}\n\n" | ||
".. code-block:: bibtex\n\n" | ||
+ textwrap.indent(response.text, " " * 4) | ||
) | ||
|
||
except Exception as e: | ||
warnings.warn( | ||
"Failed to retrieve Zenodo record for TARDIS: " f"{str(e)}" | ||
) | ||
|
||
not_found_msg = """ | ||
Couldn"t retrieve the TARDIS software citation from Zenodo. Get it | ||
directly from `this link <https://zenodo.org/record/{CONCEPT_DOI}>`_ . | ||
""" | ||
|
||
zenodo_record = ( | ||
".. |ZENODO| replace:: <TARDIS SOFTWARE CITATION HERE> \n\n" | ||
".. warning:: \n\n" + textwrap.indent(not_found_msg, " " * 4) | ||
) | ||
|
||
with open(zenodo_path, "w") as f: | ||
f.write(zenodo_record) | ||
|
||
print(zenodo_record) | ||
|
||
|
||
def main(): | ||
generate_zenodo() | ||
|
||
rst_include.include( | ||
source="docs/resources/credits_template.rst", | ||
target="docs/resources/credits.rst", | ||
quiet=False, | ||
inplace=False, | ||
source_encoding="utf-8", | ||
target_encoding="utf-8", | ||
) | ||
|
||
rst_include.include( | ||
source="README_TEMPLATE.rst", | ||
target="README.rst", | ||
quiet=False, | ||
inplace=False, | ||
source_encoding="utf-8", | ||
target_encoding="utf-8", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
====== | ||
TARDIS | ||
====== | ||
|
||
.. image:: https://img.shields.io/badge/Donate-to%20TARDIS-brightgreen.svg | ||
:target: https://numfocus.salsalabs.org/donate-to-tardis/index.html | ||
|
||
.. image:: https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A | ||
:target: http://numfocus.org | ||
|
||
.. image:: https://badges.gitter.im/Join%20Chat.svg | ||
:target: https://gitter.im/tardis-sn/tardis | ||
|
||
.. image:: https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc | ||
:target: https://open.vscode.dev/tardis-sn/tardis | ||
| | ||
TARDIS is a tool that creates synthetic observations (*spectra*) for exploding | ||
stars (*supernovae*). | ||
|
||
.. image:: https://codecov.io/gh/tardis-sn/tardis/branch/master/graph/badge.svg | ||
:target: https://codecov.io/gh/tardis-sn/tardis | ||
|
||
.. image:: https://img.shields.io/endpoint?url=https://jsonbin.org/tardis-bot/tardis/badges/docstr-cov | ||
:target: https://github.com/tardis-sn/tardis/actions/workflows/docstr-cov.yml?query=branch%3Amaster | ||
|
||
.. image:: https://github.com/tardis-sn/tardis/actions/workflows/tests.yml/badge.svg | ||
:target: https://github.com/tardis-sn/tardis/actions/workflows/tests.yml | ||
|
||
.. image:: https://github.com/tardis-sn/tardis/actions/workflows/build-docs.yml/badge.svg | ||
:target: https://tardis-sn.github.io/tardis/index.html | ||
|
||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg | ||
:target: https://github.com/psf/black | ||
| | ||
|
||
.. include:: docs/resources/credits.rst | ||
|
||
|
||
******* | ||
License | ||
******* | ||
|
||
.. image:: https://img.shields.io/conda/l/conda-forge/tardis-sn | ||
:target: https://github.com/tardis-sn/tardis/blob/master/licenses/LICENSE.rst | ||
|
||
.. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat | ||
:target: http://www.astropy.org | ||
| | ||
This project is Copyright (c) TARDIS Collaboration and licensed under | ||
the terms of the BSD 3-Clause license. This package is based upon | ||
the `Astropy package template <https://github.com/astropy/package-template>`_ | ||
which is licensed under the BSD 3-clause license. See the licenses folder for | ||
more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters