Skip to content

Commit

Permalink
Bibliographies (UniMath#1058)
Browse files Browse the repository at this point in the history
Adds citation support using a biblatex file and
[pybtex](https://pybtex.org/), reactors most current citations to use
it, and adds a small guide to explain how to use it.

Resolves UniMath#957.
  • Loading branch information
fredrik-bakke committed Mar 14, 2024
1 parent afe7813 commit 5a2bf0d
Show file tree
Hide file tree
Showing 78 changed files with 1,098 additions and 290 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,22 @@ jobs:
crate: mdbook-linkcheck
version: '0.7.7'

# Install Python and friends for website generation only where needed
- uses: actions/setup-python@v4
with:
python-version: '3.8'
check-latest: true
cache: 'pip'

- run: python3 -m pip install -r master/scripts/requirements.txt

- uses: actions/cache/restore@v3
with:
key: pre-website-${{ github.run_id }}
path: master/docs

# Tell mdbook to use only the linkcheck backend
- name: Check website links
- name: Check website links and bibtex references
env:
MDBOOK_OUTPUT: '{"linkcheck":{}}'
run: |
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@

"[python]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "ms-python.python"
"editor.defaultFormatter": null,
"editor.formatOnSave": false,
"editor.formatOnType": false,
"editor.formatOnPaste": false
}
}
41 changes: 41 additions & 0 deletions CITING-SOURCES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Citing sources

All of the references and sources of the agda-unimath library are managed in a
[BibLaTeX](https://www.ctan.org/pkg/biblatex) file `references.bib`, and we have
a custom set of macros to work with them.

The macros are as follows:

<!--
We have inserted an invisible whitespace character between the first and second
opening curly braces in the below examples to block the citation preprocessor
from detecting them as macros.
-->

- `{­{#cite referenceXYZ}}` will insert a citation to the reference labeled
`referenceXYZ` (which must be defined in the `references.bib` file) at the
current location, and add that reference to the current page's bibliography.
- `{­{#reference referenceXYZ}}` will add the reference labeled `referenceXYZ`
to the current page's bibliography without inserting a citation.
- `{­{#bibliography}}` is a marker for where the bibliography of the current
page should be inserted. If no such marker is found and the bibliography is
inhabited, it will be inserted at the bottom of the page in a new section
titled `References`.

Note that entries in the BibLaTeX file are expected to have all of the
apropriate fields defined according to their type. For instance, `@book`s _must_
have a defined field for `publisher` and `year`. If this information is not
available, please define them as empty fields. E.g. `publisher = {},`.

If you are unsure about how to structure your BibLaTeX entry, it may be useful
to know that the references are checked by the `linkcheck` GitHub workflow, so
when you post your pull request to `agda-unimath` you can refer to the CI for
possible issues.

**Note:** If the citation label of your reference is not being generated
properly, we support a custom `citeas` field that can be used to overwrite it.
For instance, _Homotopy Type Theory: Univalent Foundations of Mathematics_
should be cited as {{#cite UF13}}, and to make it so we have set
`citeas = {UF13}` for its BibLaTeX entry. Keep in mind that if the citation
label is not being generated properly, then it is likely that the author list is
not being parsed properly either.
4 changes: 2 additions & 2 deletions HOWTO-INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ In order to contribute to the `agda-unimath` library you will additionally need:
1. `git`
2. `make`
3. `python` version 3.8 or newer
4. The python libraries `pre-commit`, `requests` and `tomli`. Those can be
installed by running
4. The python libraries `pre-commit`, `pybtex`, `requests` and `tomli`. Those
can be installed by running
```shell
python3 -m pip install -r scripts/requirements.txt
```
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ TIME ?= time
METAFILES := \
ART.md \
CITE-THIS-LIBRARY.md \
CITING-SOURCES.md \
CODINGSTYLE.md \
CONTRIBUTING.md \
CONTRIBUTORS.md \
Expand All @@ -49,7 +50,7 @@ METAFILES := \
STATEMENT-OF-INCLUSION.md \
SUMMARY.md \
TEMPLATE.lagda.md \
USERS.md \
USERS.md

.PHONY: agdaFiles
agdaFiles:
Expand Down
6 changes: 0 additions & 6 deletions TEMPLATE.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,3 @@ concept-subconcept = ...

- An instructive example of a file with the expected structure is
[`order-theory.galois-connections`](https://raw.githubusercontent.com/UniMath/agda-unimath/master/src/order-theory/galois-connections.lagda.md).

## References

1. Univalent Foundations Project, _Homotopy Type Theory – Univalent Foundations
of Mathematics_ (2013) ([website](https://homotopytypetheory.org/book/),
[arXiv:1308.0729](https://arxiv.org/abs/1308.0729))
9 changes: 9 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ output-file = "docs/concept_index.json"
mathswitch-template = "https://mathswitch.xyz/concept/Wd/{wikidata_id}"
wikidata-template = "https://www.wikidata.org/entity/{wikidata_id}"

[preprocessor.citations]
command = "python3 ./scripts/preprocessor_citations.py"
bibtex_file = "references.bib"
citation_style = "alpha"
citation_label_style = "custom_alpha"
error_on_unmatched_keys = true
before = [ "git-metadata" ]

[output.linkcheck]
follow-web-links = false

Expand All @@ -62,6 +70,7 @@ additional-css = [
"website/css/Agda.css",
"website/css/Agda-highlight.css",
"website/css/agda-logo.css",
"website/css/bibliography.css",
"theme/catppuccin.css",
"theme/catppuccin-admonish.css",
"theme/pagetoc.css",
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
python = pkgs.python38.withPackages (p: with p; [
# Keep in sync with scripts/requirements.txt
# pre-commit <- not installed as a Python package but as a binary below
pybtex
requests
tomli
]);
Expand Down
606 changes: 606 additions & 0 deletions references.bib

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/generate_main_index_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def generate_index(root_path, header):
- [File template](TEMPLATE.lagda.md)
- [The library coding style](CODINGSTYLE.md)
- [Guidelines for mixfix operators](MIXFIX-OPERATORS.md)
- [Citing sources](CITING-SOURCES.md)
- [Citing the library](CITE-THIS-LIBRARY.md)
- [Library contents](SUMMARY.md)
- [Art](ART.md)
Expand Down
Loading

0 comments on commit 5a2bf0d

Please sign in to comment.