From ac4580494ab98cdb6317b76d5ca1127dc6754787 Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Mon, 3 Jun 2024 18:36:58 -0600 Subject: [PATCH] Added `aastex.Author.orcid` field. (#3) --- aastex/_aastex.py | 12 +++++++++++- aastex/_tests/test_aastex.py | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/aastex/_aastex.py b/aastex/_aastex.py index b941362..344cd46 100644 --- a/aastex/_aastex.py +++ b/aastex/_aastex.py @@ -79,6 +79,9 @@ class Author(pylatex.base_classes.LatexObject): affiliation: Affiliation """The organization affiliated with the author""" + orcid: None | str = None + """The optional ORCID of the author.""" + email: None | str = None """ The optional email address of the author. @@ -88,8 +91,15 @@ class Author(pylatex.base_classes.LatexObject): """ def dumps(self) -> str: - author = pylatex.Command("author", self.name).dumps() + + author = pylatex.Command( + command="author", + arguments=self.name, + options=NoEscape(self.orcid) if self.orcid is not None else None, + ).dumps() + affilation = self.affiliation.dumps() + result = f"{author}\n{affilation}" if self.email is not None: diff --git a/aastex/_tests/test_aastex.py b/aastex/_tests/test_aastex.py index aa09781..b83b91f 100644 --- a/aastex/_tests/test_aastex.py +++ b/aastex/_tests/test_aastex.py @@ -41,6 +41,7 @@ def test_dumps(self, a: aastex.Affiliation): aastex.Author( name="Jane Doe", affiliation=aastex.Affiliation("Fancy University"), + orcid="0000-0000-0000-0000", email="jane.doe@tmp.com", ), ], @@ -52,6 +53,12 @@ def test_name(self, a: aastex.Author): def test_affiliation(self, a: aastex.Author): assert isinstance(a.affiliation, aastex.Affiliation) + def test_orcid(self, a: aastex.Author): + result = a.orcid + if result is not None: + assert isinstance(result, str) + assert result in a.dumps() + def test_email(self, a: aastex.Author): result = a.email if result is not None: