Skip to content

Commit 9013e7b

Browse files
committed
Add "show" optional parameter to cite method
By default calling ij.py.cite() will print the citation to the console. If set to False the citation string will be returned without calling print().
1 parent c071d1d commit 9013e7b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/imagej/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,14 @@ def argstring(self, args, ij1_style=True):
164164
formatted_args.append(arg)
165165
return " ".join(formatted_args)
166166

167-
def cite(self) -> str:
167+
def cite(self, show: bool = True) -> str:
168168
"""Generate a citation string and package version numbers.
169169
170170
Generate the PyImageJ citation/reference string and fetch
171171
the environments Python and Java versions.
172172
173+
:param show: Print the PyImageJ citation if True, if False
174+
the PyImageJ citation string is returned instead.
173175
:return: A citation and package version numbers
174176
"""
175177
# set PyImageJ reference sub strings
@@ -194,7 +196,10 @@ def cite(self) -> str:
194196
+ python_version
195197
+ java_version
196198
)
197-
return citation
199+
if show:
200+
print(citation)
201+
else:
202+
return citation
198203

199204
def dtype(self, image_or_type):
200205
"""Get the dtype of the input image as a numpy.dtype object.

0 commit comments

Comments
 (0)