From 86bf6089a9c61d0bc0f74b320a2141d3f9b8080d Mon Sep 17 00:00:00 2001 From: Albert Engstfeld Date: Fri, 24 Apr 2026 10:38:26 +0200 Subject: [PATCH 1/4] Fix citation style --- unitpackage/database/echemdb_entry.py | 34 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/unitpackage/database/echemdb_entry.py b/unitpackage/database/echemdb_entry.py index 1a8973ea..5116bb48 100644 --- a/unitpackage/database/echemdb_entry.py +++ b/unitpackage/database/echemdb_entry.py @@ -205,7 +205,7 @@ 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: @@ -214,15 +214,21 @@ def citation(self, backend="text"): 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 @@ -270,12 +276,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. From 7581c06a8ee35cab34a347d8c4ef46f0ae4176aa Mon Sep 17 00:00:00 2001 From: Albert Engstfeld Date: Fri, 24 Apr 2026 10:41:11 +0200 Subject: [PATCH 2/4] fix doocstring description --- unitpackage/database/echemdb_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unitpackage/database/echemdb_entry.py b/unitpackage/database/echemdb_entry.py index 5116bb48..425ccf44 100644 --- a/unitpackage/database/echemdb_entry.py +++ b/unitpackage/database/echemdb_entry.py @@ -209,7 +209,9 @@ 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'. From ac285ede2bbb3d40881deb8a1a18561898277d70 Mon Sep 17 00:00:00 2001 From: Albert Engstfeld Date: Fri, 24 Apr 2026 10:41:49 +0200 Subject: [PATCH 3/4] Fix citation docstring --- doc/news/citation-style.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/news/citation-style.rst diff --git a/doc/news/citation-style.rst b/doc/news/citation-style.rst new file mode 100644 index 00000000..c1b6f6bb --- /dev/null +++ b/doc/news/citation-style.rst @@ -0,0 +1,3 @@ +**Changed:** + +* Changed citation output format for `EchemdbEntry.citation()`, removing url, doi from the output . From aeb7cb3f3bd106239e7096cff0e79a3f8c88825e Mon Sep 17 00:00:00 2001 From: Albert Engstfeld Date: Fri, 24 Apr 2026 16:14:48 +0200 Subject: [PATCH 4/4] Add codata paper to linkchecker exclusiion list --- doc/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index a1d18f9d..f1f6aedb 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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*" ]