Skip to content

Commit 9e4d6a2

Browse files
authored
Merge pull request #38 from TeachBooks/apa-style
Apa style
2 parents 4af75a8 + f669b64 commit 9e4d6a2

File tree

16 files changed

+813
-2
lines changed

16 files changed

+813
-2
lines changed

book/_config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ sphinx:
4040
html_show_copyright: false
4141
html_last_updated_fmt: '%B %-d, %Y'
4242
html_static_path: ["images"]
43+
bibtex_default_style: myapastyle
44+
bibtex_reference_style: author_year_round
45+
local_extensions:
46+
apastyle: _ext/
47+
bracket_citation_style: _ext/
4348

4449
bibtex_bibfiles:
4550
- references.bib

book/_ext/apastyle.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# from pybtex.style.formatting.unsrt import Style
3+
from pybtexapastyle.formatting.apa import APAStyle
4+
from pybtexapastyle.labels.apa import LabelStyle as APALabelStyle
5+
from pybtex.plugin import register_plugin
6+
# from pybtex.style.template import names, sentence
7+
8+
class MyAPALabelStyle(APALabelStyle):
9+
def format_label(self, entry):
10+
return APALabelStyle.format_label(self, entry)
11+
12+
class MyAPAStyle(APAStyle):
13+
default_label_style = 'myapa'
14+
15+
def setup(app):
16+
register_plugin('pybtex.style.labels', 'myapa', MyAPALabelStyle)
17+
register_plugin('pybtex.style.formatting', 'myapastyle', MyAPAStyle)

book/_ext/bracket_citation_style.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from dataclasses import dataclass, field
2+
import sphinxcontrib.bibtex.plugin
3+
4+
from sphinxcontrib.bibtex.style.referencing import BracketStyle
5+
from sphinxcontrib.bibtex.style.referencing.author_year import AuthorYearReferenceStyle
6+
7+
8+
def bracket_style() -> BracketStyle:
9+
return BracketStyle(
10+
left='(',
11+
right=')',
12+
)
13+
14+
15+
@dataclass
16+
class MyReferenceStyle(AuthorYearReferenceStyle):
17+
bracket_parenthetical: BracketStyle = field(default_factory=bracket_style)
18+
bracket_textual: BracketStyle = field(default_factory=bracket_style)
19+
bracket_author: BracketStyle = field(default_factory=bracket_style)
20+
bracket_label: BracketStyle = field(default_factory=bracket_style)
21+
bracket_year: BracketStyle = field(default_factory=bracket_style)
22+
23+
24+
def setup(app):
25+
sphinxcontrib.bibtex.plugin.register_plugin(
26+
'sphinxcontrib.bibtex.style.referencing',
27+
'author_year_round', MyReferenceStyle)

book/_ext/pybtexapastyle/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Naeka
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

book/_ext/pybtexapastyle/formatting/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)