Skip to content

Commit

Permalink
fix bibtex references
Browse files Browse the repository at this point in the history
  • Loading branch information
d70-t committed Dec 13, 2023
1 parent 9c97b38 commit bfc5671
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 1 deletion.
8 changes: 8 additions & 0 deletions orcestra_book/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions orcestra_book/_ext/apastyle.py
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions orcestra_book/_ext/bracket_citation_style.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions orcestra_book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ chapters:
# - file: publications
# - file: conferences
#- file: news
- file: references
15 changes: 15 additions & 0 deletions orcestra_book/references.bib
Original file line number Diff line number Diff line change
@@ -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}
}
3 changes: 3 additions & 0 deletions orcestra_book/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# References
```{bibliography}
```
2 changes: 1 addition & 1 deletion orcestra_book/science.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ requests
aiohttp
zarr>=2.8.3
healpy
pybtex-apa-style

0 comments on commit bfc5671

Please sign in to comment.