Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
# This is because checking results in a timeout.
# Zenodo badge and record URLs are excluded because Zenodo's servers
# block automated link checkers with 403 responses.
# ignore the DOI link to the codata article which regularly times out during link checking.
linkcheck_ignore = [
"https://www.gnu.org/licenses/gpl-3.0.html*",
"https://zenodo.org/badge/*",
"https://zenodo.org/records/*",
"https://doi.org/10.5334/dsj-2025-013*"
]
3 changes: 3 additions & 0 deletions doc/news/citation-style.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Changed:**

* Changed citation output format for `EchemdbEntry.citation()`, removing url, doi from the output .
38 changes: 33 additions & 5 deletions unitpackage/database/echemdb_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,32 @@ def bibliography(self):
bibliography = parse_string(citation, "bibtex")
return bibliography.entries[self.source.citationKey]

def citation(self, backend="text"):
def citation(self, backend="text", include_web_refs=False):
r"""
Return a formatted reference for the entry's bibliography such as:

J. Doe, et al., Journal Name, volume (YEAR) page, "Title"
O. B. Alves et al. Electrochemistry at Ru(0001) in a flowing
CO-saturated electrolyte-reactive and inert adlayer phases.
Physical Chemistry Chemical Physics, 13(13):6010-6021, 2011

Rendering default is plain text 'text', but can be changed to any format
supported by pybtex, such as markdown 'md', 'latex' or 'html'.

Web references (URL/DOI/eprint fields) are suppressed by default because
many consumers already link the whole citation externally.

EXAMPLES::

>>> entry = EchemdbEntry.create_example()
>>> entry.citation(backend='text')
'O. B. Alves et al. Electrochemistry at Ru(0001) in a flowing CO-saturated electrolyte—reactive and inert adlayer phases. Physical Chemistry Chemical Physics, 13(13):6010–6021, 2011.'
'O. B. Alves et al. Electrochemistry at Ru(0001) in a flowing CO-saturated electrolyte—reactive and inert adlayer phases. Physical Chemistry Chemical Physics, 13(13):6010–6021, 2011'
>>> print(entry.citation(backend='md'))
O\. B\. Alves *et al\.*
*Electrochemistry at Ru\(0001\) in a flowing CO\-saturated electrolyte—reactive and inert adlayer phases*\.
*Physical Chemistry Chemical Physics*, 13\(13\):6010–6021, 2011\.
*Physical Chemistry Chemical Physics*, 13\(13\):6010–6021, 2011

>>> "URL:" in entry.citation(backend='text') or "doi:" in entry.citation(backend='text').lower()
False

"""
from pybtex.style.formatting.unsrt import Style
Expand Down Expand Up @@ -270,12 +278,32 @@ def format_title(self, e, which_field, as_sentence=True):
title = tag("i")[field(which_field)]
return sentence[title] if as_sentence else title

return (
def format_web_refs(self, e):
if include_web_refs:
return super().format_web_refs(e)

from pybtex.style.template import sentence

# Suppress URL/DOI/pubmed/eprint block.
# pylint: disable=no-value-for-parameter
return sentence[""]

citation = (
EchemdbStyle(abbreviate_names=True)
.format_entry("unused", self.bibliography)
.text.render_as(backend)
)

citation = citation.rstrip()

if citation.endswith("\\."):
return citation[:-2]

if citation.endswith("."):
return citation[:-1]

return citation

def get_electrode(self, name):
r"""
Returns an electrode with the specified name.
Expand Down