Skip to content

Commit cd6993f

Browse files
committed
📚 Add sphinxcontrib-bibtex to CONTRIBUTING
1 parent af192b1 commit cd6993f

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,56 @@ where `{width}` and `{height}` are the values already present in the existing `w
6464
<object data="../_static/path/to/chart.svg" type="image/svg+xml"></object>
6565
```
6666

67+
## References and citations
68+
69+
[sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) is installed and configured. This extension creates links between the citations and the reference in the reference list and formats citations in referenced BibTeX files using built-in or [custom styles](https://github.com/FCP-INDI/fcp-indi.github.com/blob/source/docs/_sources/references/style.py). To use this Sphinx extension,
70+
71+
1. Include your citations in a BibTeX file (see the `*.bib` files in [docs/_sources/references](https://github.com/FCP-INDI/fcp-indi.github.com/blob/source/docs/_sources/references) for examples).
72+
2. Using the key (the text between the opening `{` and the first `,` in a BibTeX entry) use the ReStructuredText syntax `` :cite:`key` `` to cite your reference in a ReStructuredText file.
73+
3. Include a `.. bibliography::` directive somewhere on any page that you want to use this extension to format references and create two-way links between the references and citations. Specify the (one) BibTeX file for this reference list any formatting for the reference list in this directive. Both `:cite:` and `.. bibliography::` need to be rendered on the same page for the links to generate.
74+
4. If you will (or might) use more than one `.. bibliography::` directive on a single rendered page (including `.. include::` directives), choose a prefix for the keys and include that prefix in both the `:cite:` role (like `` :cite:`prefix-key` ``) and the bibliography directive (like `:keyprefix: prefix-`).
75+
5. If you want to include a header over a reference list, use the `.. rubric::` directive above its `.. bibliography` directive.
76+
6. If the entry type (e.g., `book`, `article`, `misc`) of any of the entries in your BibTeX file(s) is not included in [docs/_sources/references/style.py](https://github.com/FCP-INDI/fcp-indi.github.com/blob/source/docs/_sources/references/style.py), add a `get_{entry_type}_template` [Pybtex](https://pybtex.org) method to `CPAC_DocsStyle`.
77+
78+
For example, if you have a BibTeX file called `cpac_citation.bib` that contains
79+
80+
```BibTeX
81+
@ARTICLE{cpac2013,
82+
AUTHOR={Craddock, Cameron and Sikka, Sharad and Cheung, Brian and Khanuja, Ranjeet and Ghosh, Satrajit S
83+
and Yan, Chaogan and Li, Qingyang and Lurie, Daniel and Vogelstein, Joshua and Burns, Randal and
84+
Colcombe, Stanley and Mennes, Maarten and Kelly, Clare and Di Martino, Adriana and Castellanos,
85+
Francisco Xavier and Milham, Michael},
86+
TITLE={Towards Automated Analysis of Connectomes: The {Configurable Pipeline for the Analysis of Connectomes (C-PAC)}},
87+
JOURNAL={Frontiers in Neuroinformatics},
88+
YEAR={2013},
89+
NUMBER={42},
90+
URL={http://www.frontiersin.org/neuroinformatics/10.3389/conf.fninf.2013.09.00042/full},
91+
DOI={10.3389/conf.fninf.2013.09.00042},
92+
ISSN={1662-5196}
93+
}
94+
```
95+
96+
If you include
97+
98+
```rst
99+
To cite C-PAC, use :cite:`cite-cpac2013`.
100+
101+
.. rubric Cite C-PAC
102+
103+
.. bibliography:: cpac_citation.bib
104+
:style: cpac_docs_style
105+
:cited:
106+
:keyprefix: cite-
107+
```
108+
109+
The rendered file should look something like
110+
111+
> To cite C-PAC, use <a name="backref1" href="#ref1">[1]</a>.
112+
>
113+
> __Cite C-PAC__
114+
>
115+
> <a name="ref1" href="#backref1">[1]</a> Craddock, C., Sikka, S., Cheung, B., Khanuja, R., Ghosh, S. S., Yan, C., Li, Q., Lurie, D., Vogelstein, J., Burns, R., Colcombe, S., Mennes, M., Kelly, C., Di Martino, A., Castellanos, F. X., and Milham, M. 2013. [Towards automated analysis of connectomes: the Configurable Pipeline for the Analysis of Connectomes (C-PAC).](http://www.frontiersin.org/neuroinformatics/10.3389/conf.fninf.2013.09.00042/full) *Frontiers in neuroinformatics* 42. doi:[10.3389/conf.fninf.2013.09.00042](https://dx.doi.org/10.3389/conf.fninf.2013.09.00042)
116+
67117
## Environment notes
68118
* Because [C-PAC](https://github.com/FCP-INDI/C-PAC.git) and [cpac](https://github.com/FCP-INDI/cpac.git) have conflicting commandline commands, we first run any `cpac` commands in a virtual environment and spoof the `command-output` directive with `code-block` like
69119
```RST

docs/_sources/references/style.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@ def __init__(self, *args, **kwargs):
1616
sorting_style=NoSort
1717
)
1818

19+
def format_doi(self, doi):
20+
return join(sep=':')[
21+
words['doi'],
22+
href[join(sep='/')[
23+
'https://dx.doi.org', doi
24+
], doi]
25+
]
26+
27+
def get_article_template(self, entry):
28+
template = toplevel[optional[
29+
sentence[self.format_names('author')]],
30+
optional[sentence[date]],
31+
optional[
32+
href[
33+
field('url'),
34+
self.format_title(entry, 'title')
35+
] if entry.fields.get('url') else
36+
self.format_title(entry, 'title')
37+
],
38+
sentence[join(sep=' ')[
39+
optional[tag('em')[join(sep=', ')[
40+
self.format_title(entry, 'journal', as_sentence=False),
41+
optional_field('volume')
42+
]]],
43+
optional[join(sep='')[
44+
':' if entry.fields.get('volume') else '',
45+
optional_field("number")
46+
] if entry.fields.get('number') else ''],
47+
]],
48+
optional[join(sep='')[
49+
', pp. ', optional_field('pages')
50+
] if entry.fields.get('pages') else ''],
51+
optional[self.format_doi(optional_field('doi'))],
52+
sentence[optional_field('note')],
53+
]
54+
return template
55+
1956
def get_book_template(self, entry):
2057
template = toplevel[optional[
2158
sentence[self.format_names('author')]],

0 commit comments

Comments
 (0)