A proof of concept micropackage for trait based declaration of citation details.
Author oxinabox
5 Stars
Updated Last
2 Years Ago
Started In
January 2019


Retrieving citations

To find the citation for a thing, e.g. function, type, or module. use the cite(thing) command.

Declaring citations


To declare a citation for a function attach it as a trait on the type of the function. This is done

function thing()

Citations.cite(::typeof(thing) = "2001, Jane Doe, Considerations of a Thing"

Or you can use the helper macro @declare_citation:

@declare_citation thing,  "2001, Jane Doe, Considerations of a Thing"

Module (e.g. package)

To declare a citation for a module, declare a cite trait for the modules eval function.

Citation.cite(::typeof(MyModule.eval)) = "2019, Author, Package"

Or use the @declare_citation macro, with only one argument.

@declare_citation "2019, Author, Package"

Using Citations.jl in your packages

Suppose you are Jane Doe, the maintainer of SomeCoolPackage.jl and you want your users to be able to cite your package as well as your two functions, awesomefunction1 and awesomefunction2. You can import Citations.jl into your package and export citation methods as follows

module SomeCoolPackage

using Citations 

awesomefunction1(x) = "do cool stuff"
awesomefunction2(x) = "do other cool stuff"

@declare_citation "2019, Jane Doe, SomeCoolPackage.jl"
Citations.cite(::typeof(awesomefunction1)) = "2019, Jane Doe, awesomefunction1, SomeCoolPackage.jl"
Citations.cite(::typeof(awesomefunction2)) = "2019, Jane Doe, awesomefunction2, SomeCoolPackage.jl"

export cite, awesomefunction1, awesomefunction2


Your users can then easily generate citation info at the REPL

julia> using SomeCoolPackage

julia> cite(SomeCoolPackage)
"2019, Jane Doe, SomeCoolPackage.jl"

julia> cite(awesomefunction1)
"2019, Jane Doe, awesomefunction1, SomeCoolPackage.jl"

julia> cite(awesomefunction2)
"2019, Jane Doe, awesomefunction2, SomeCoolPackage.jl"