citation style to handle dates, starting on ld fragments

This commit is contained in:
sneakers-the-rat 2023-06-08 15:04:57 -07:00
parent b957dae24a
commit 90d6edeb10
6 changed files with 117 additions and 3 deletions

View file

@ -1 +1,8 @@
# Linked Data Fragments
## References
- Homepage: https://linkeddatafragments.org/
- Papers:
- {cite}`verborghTriplePatternFragments2016`

View file

@ -61,4 +61,83 @@ napoleon_attr_annotations = True
# bibtex
bibtex_bibfiles = ['p2p_ld_docs.bib']
bibtex_reference_style = 'author_year'
bibtex_reference_style = 'author_year'
bibtex_default_style = 'bbibtex'
## Formatting to handle dates that are in the `date` field rather than `year`
import re
import pybtex.plugin
from pybtex.richtext import Symbol, Text
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.formatting import toplevel
from pybtex.style.template import (
field, first_of, href, join, names, optional, optional_field, sentence,
tag, together, words
)
def dashify(text):
dash_re = re.compile(r'-+')
return Text(Symbol('ndash')).join(text.split(dash_re))
date = first_of [
field('date'),
words [optional_field('month'), field('year')]
]
pages = field('pages', apply_func=dashify)
class BetterBibTeXStyle(UnsrtStyle):
def get_article_template(self, e):
volume_and_pages = first_of [
# volume and pages, with optional issue number
optional [
join [
field('volume'),
optional['(', field('number'),')'],
':', pages
],
],
# pages only
words ['pages', pages],
]
template = toplevel [
self.format_names('author'),
self.format_title(e, 'title'),
sentence [
tag('em') [first_of [
field('journaltitle'),
field('journal')
]],
optional[ volume_and_pages ],
date],
sentence [ optional_field('note') ],
self.format_web_refs(e),
]
return template
# ----------------
# Handle when dates are in `date` and not `year`
# fuck it just monkey patch it
from sphinxcontrib.bibtex.style.template import node
from typing import Dict
from sphinxcontrib.bibtex.style.template import first_of as first_of_
from sphinxcontrib.bibtex.style.template import optional as optional_
from sphinxcontrib.bibtex.style.template import field as field_
from sphinxcontrib.bibtex.style import template as template_module
def split_year(date:str) -> str:
return date.split('-')[0]
@node
def year(children, data: Dict[str, Any]) -> "BaseText":
assert not children
return first_of_[optional_[field_('year')], optional_[field_('date', apply_func=split_year)], 'n.d.'].format_data(data)
template_module.year = year
pybtex.plugin.register_plugin('pybtex.style.formatting', 'bbibtex', BetterBibTeXStyle)

View file

@ -3,9 +3,14 @@
All of this is very work in progress :) plz do not rely on any of the descriptions or statements here, as they are all effectively provisional.
This site describes the implementation of the p2p linked data protocol in {cite}`saundersDecentralizedInfrastructureNeuro2022`
## Document Status
**23-06-08** - Populating the [Comparison](comparison) section first to refresh myself on other projects, and starting to sketch diagrammatically in [Sketchpad](sketchpad). The rest of the pages are just stubs to keep track of ideas before fleshing them out.
```{toctree}
:caption: Introduction
:hidden:
overview
comparison/index
@ -16,6 +21,7 @@ out_of_scope
```{toctree}
:caption: Protocol
:numbered:
:hidden:
definitions
protocol
@ -32,6 +38,7 @@ evolvability
```{toctree}
:caption: Ecosystem
:hidden:
triplets
translation
@ -39,12 +46,14 @@ translation
```{toctree}
:caption: Drafting
:hidden:
sketchpad
```
```{toctree}
:caption: Meta
:hidden:
genindex
references

View file

@ -25,3 +25,22 @@
keywords = {archived,Computer Science - General Literature,E.2,H.4.3,H.5.3,K.2,K.4.1,K.4.3,K.6.4},
file = {/Users/jonny/Dropbox/papers/zotero/S/SaundersJ/saunders_2022_decentralized_infrastructure_for_(neuro)science.pdf}
}
@article{verborghTriplePatternFragments2016,
title = {Triple {{Pattern Fragments}}: {{A}} Low-Cost Knowledge Graph Interface for the {{Web}}},
shorttitle = {Triple {{Pattern Fragments}}},
author = {Verborgh, Ruben and Vander Sande, Miel and Hartig, Olaf and Van Herwegen, Joachim and De Vocht, Laurens and De Meester, Ben and Haesendonck, Gerald and Colpaert, Pieter},
date = {2016-03},
journaltitle = {Journal of Web Semantics},
shortjournal = {Journal of Web Semantics},
volume = {37--38},
pages = {184--206},
issn = {15708268},
doi = {10.1016/j.websem.2016.03.003},
url = {https://linkinghub.elsevier.com/retrieve/pii/S1570826816000214},
urldate = {2023-06-08},
archive = {https://web.archive.org/web/20230608191748/https://www.sciencedirect.com/science/article/abs/pii/S1570826816000214?via\%3Dihub},
langid = {english},
keywords = {archived},
file = {/Users/jonny/Dropbox/papers/zotero/V/VerborghR/verborgh_2016_triple_pattern_fragments.pdf}
}

View file

@ -2,4 +2,4 @@
```{bibliography}
```
```

View file

@ -6,7 +6,7 @@ Dummy change to check that we don't invalidate the rust cache on CI.
Just a stub to check if mermaid works
```mermaid
```{mermaid}
erDiagram
IDENTITY {
string hash