From 5a9d46ae968d6869ac162e5c04ab0b5ae36b930c Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Fri, 26 Jan 2024 14:52:18 +0000 Subject: [PATCH] Add CITATION file and prep tests for citing repos --- CITATION.cff | 29 +++++++++++++++++++++++++++ brainglobe/citation/cite.py | 11 +++++++++- brainglobe/citation/repositories.py | 12 +++++++++++ tests/test_unit/citation/test_cite.py | 3 +++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 CITATION.cff create mode 100644 tests/test_unit/citation/test_cite.py diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..80a6231 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,29 @@ +# This CITATION.cff file was generated with cffinit. +# Visit https://bit.ly/cffinit to generate yours today! + +cff-version: 1.2.0 +title: BrainGlobe +message: >- + You can use the brainglobe.cite() function to generate + citations for the BrainGlobe tools you use in your + research. +type: software +authors: + - given-names: BrainGlobe + family-names: Developers + affiliation: 'Sainsbury Wellcome Centre, University College London' + email: hello@brainglobe.info + - given-names: Wiliam Michael + family-names: Graham + email: william.graham@ucl.ac.uk + affiliation: 'Advanced Research Computing, University College London' + orcid: 'https://orcid.org/0000-0003-0058-263X' +repository-code: 'https://github.com/brainglobe/brainglobe-meta' +url: 'https://brainglobe.info/' +abstract: >- + The BrainGlobe Initiative exists to facilitate the + development of interoperable Python-based tools for + computational neuroanatomy. +license: BSD-3-Clause +citation-sentence: >- + 'This project makes use of the BrainGlobe tool-suite, https://brainglobe.info/' diff --git a/brainglobe/citation/cite.py b/brainglobe/citation/cite.py index 2b92eb4..69bcac8 100644 --- a/brainglobe/citation/cite.py +++ b/brainglobe/citation/cite.py @@ -12,6 +12,7 @@ def cite( format: Literal["bibtex", "text"] = "bibtex", outfile: str = None, cite_software: bool = False, + newline_separations: int = 2, ) -> str: """ Provide citation(s) for the BrainGlobe tool(s) that the user has supplied. @@ -34,6 +35,9 @@ def cite( or journal counterparts, where present in repositories. Use if you want to reference the source code of a particular tool, rather than acknowledge use of the tool itself. + newline_separations: int, default = 2 + Number of newline characters to use when separating references, in the + event that multiple tools are to be cited. Returns ------- @@ -68,6 +72,10 @@ def cite( ) citation_type = None + # The repo_reference variable will contain the reference string + repo_reference: str = None + + # Determine citation format in preparation for writing if format == "text": # If the user requested the citation sentence, # provide this by looking up the expected field. @@ -101,7 +109,8 @@ def cite( repo_reference = citation_class(citation_info) - cite_string += f"{repo_reference}\n\n" + # Append the reference to the string we are generating + cite_string += f"{repo_reference}" + "\n" * newline_separations # Upon looping over each of the repositories, we should be ready to dump # the output to the requested location. diff --git a/brainglobe/citation/repositories.py b/brainglobe/citation/repositories.py index c817d5f..024ddd1 100644 --- a/brainglobe/citation/repositories.py +++ b/brainglobe/citation/repositories.py @@ -190,6 +190,18 @@ def unique_repositories_from_tools( ], cff_branch="add-citation-file", ) +brainglobe_meta = Repository( + "brainglobe-meta", + [ + "brainglobe", + "meta-package", + "meta package", + "meta", + "toolsuite", + "tool suite", + ], + cff_branch="add-citation-function", +) def all_citable_repositories() -> List[Repository]: diff --git a/tests/test_unit/citation/test_cite.py b/tests/test_unit/citation/test_cite.py new file mode 100644 index 0000000..e9b2739 --- /dev/null +++ b/tests/test_unit/citation/test_cite.py @@ -0,0 +1,3 @@ +def test_citation_combinations() -> None: + """ """ + pass