diff --git a/orcestra_book/_config.yml b/orcestra_book/_config.yml index 757533a7..dc92782c 100644 --- a/orcestra_book/_config.yml +++ b/orcestra_book/_config.yml @@ -25,6 +25,14 @@ repository: path_to_book: orcestra_book # Optional path to your book, relative to the repository root branch: main # Which branch of the repository should be used when creating links (optional) +sphinx: + local_extensions: + apastyle: _ext/ + bracket_citation_style: _ext/ + config: + bibtex_default_style: myapastyle + bibtex_reference_style: author_year_round + # Add GitHub buttons to your book # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository html: diff --git a/orcestra_book/_ext/apastyle.py b/orcestra_book/_ext/apastyle.py new file mode 100644 index 00000000..9b820491 --- /dev/null +++ b/orcestra_book/_ext/apastyle.py @@ -0,0 +1,16 @@ +from pybtex.style.formatting.unsrt import Style +from formatting.apa import APAStyle +from labels.apa import LabelStyle as APALabelStyle +from pybtex.plugin import register_plugin +from pybtex.style.template import names, sentence + +class MyAPALabelStyle(APALabelStyle): + def format_label(self, entry): + return APALabelStyle.format_label(self, entry) + +class MyAPAStyle(Style): + default_label_style = 'myapa' + +def setup(app): + register_plugin('pybtex.style.labels', 'myapa', MyAPALabelStyle) + register_plugin('pybtex.style.formatting', 'myapastyle', MyAPAStyle) diff --git a/orcestra_book/_ext/bracket_citation_style.py b/orcestra_book/_ext/bracket_citation_style.py new file mode 100644 index 00000000..03015acd --- /dev/null +++ b/orcestra_book/_ext/bracket_citation_style.py @@ -0,0 +1,28 @@ +from dataclasses import dataclass, field +import sphinxcontrib.bibtex.plugin + +from sphinxcontrib.bibtex.style.referencing import BracketStyle +from sphinxcontrib.bibtex.style.referencing.author_year \ + import AuthorYearReferenceStyle + + +def bracket_style() -> BracketStyle: + return BracketStyle( + left='(', + right=')', + ) + + +@dataclass +class MyReferenceStyle(AuthorYearReferenceStyle): + bracket_parenthetical: BracketStyle = field(default_factory=bracket_style) + bracket_textual: BracketStyle = field(default_factory=bracket_style) + bracket_author: BracketStyle = field(default_factory=bracket_style) + bracket_label: BracketStyle = field(default_factory=bracket_style) + bracket_year: BracketStyle = field(default_factory=bracket_style) + + +def setup(app): + sphinxcontrib.bibtex.plugin.register_plugin( + 'sphinxcontrib.bibtex.style.referencing', + 'author_year_round', MyReferenceStyle) diff --git a/orcestra_book/_toc.yml b/orcestra_book/_toc.yml index 8e56adf7..c9de380b 100644 --- a/orcestra_book/_toc.yml +++ b/orcestra_book/_toc.yml @@ -31,3 +31,4 @@ chapters: # - file: publications # - file: conferences #- file: news +- file: references diff --git a/orcestra_book/references.bib b/orcestra_book/references.bib index ec380ec4..0bf49256 100644 --- a/orcestra_book/references.bib +++ b/orcestra_book/references.bib @@ -1,3 +1,18 @@ --- --- +@article{Frank_1983, + title={The Structure and Energetics of the East Atlantic Intertropical Convergence Zone}, + volume={40}, + ISSN={1520-0469}, + url={http://dx.doi.org/10.1175/1520-0469(1983)040<1916:TSAEOT>2.0.CO;2}, + DOI={10.1175/1520-0469(1983)040<1916:tsaeot>2.0.co;2}, + number={8}, + journal={Journal of the Atmospheric Sciences}, + publisher={American Meteorological Society}, + author={Frank, + William M.}, + year={1983}, + month=aug, + pages={1916–1929} +} diff --git a/orcestra_book/references.md b/orcestra_book/references.md new file mode 100644 index 00000000..ad708f3b --- /dev/null +++ b/orcestra_book/references.md @@ -0,0 +1,3 @@ +# References +```{bibliography} +``` diff --git a/orcestra_book/science.md b/orcestra_book/science.md index 14d216c2..ec4f6f63 100644 --- a/orcestra_book/science.md +++ b/orcestra_book/science.md @@ -15,7 +15,7 @@ Due to this central role, the ITCZ has, of course, already been studied intensel Snapshots from VIIRS (NOAA-20) from the 1st of July 2021 until the 15th of July 2021 in the East Atlantic (26°W to 20°W, 0° to 14°N). ``` -Such deviations from the mean picture of the ITCZ have already been observed during the GATE campaign about 50 years ago and is nicely stated in a paper by Frank (1983): +Such deviations from the mean picture of the ITCZ have already been observed during the GATE campaign about 50 years ago and is nicely stated in a paper by {cite:t}`Frank_1983`: > With the introduction of meteorological satellites two decades ago, it became clear that long east-west oriented lindes of maximum cloudiness occur in the mean. However, the lines of maximum mean cloudiness consist only of preferred locations for a variety of complex convective phenomena. At any given time and place along the zonal band containing the ITCZ, there may be deep convective clouds organized into a number of mesoscale patterns or no clouds at all. diff --git a/requirements.txt b/requirements.txt index 8141b40e..b6c280e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,5 @@ requests aiohttp zarr>=2.8.3 healpy +pybtex-apa-style +docutils==0.17.1 # see https://github.com/executablebooks/jupyter-book/issues/1997