Citation#
- class documenteer.citations.Citation(*, title, type=None, doi=None, authors=(), publisher=None, date=None, url=None, version=None, number=None)#
Bases:
objectA bibliographic citation for a work, composable as plain text or BibTeX.
The fields are the DataCite mandatory metadata (creators, title, publisher, publication year, identifier) plus the landing-page URL, which is the metadata a Documenteer site can supply from its own configuration without asking a registration agency.
- Parameters:
title (
str)type (
CitationType|None, default:None)authors (
tuple[PersonAuthor|OrganizationAuthor,...], default:())date (
PartialDate|None, default:None)
Attributes Summary
The work's authors, in the order they should be credited.
The citation key that
to_bibtexuses by default.The publication date, at the precision its source stated.
The work's DOI, normalized to its bare
10.NNNN/suffixform.The DOI as a resolvable
https://doi.orgURL, orNonewhen the work has no DOI.its DOI as a resolvable URL, or its landing page when it has no DOI, or
Nonewhen it has neither.The work's number within its series, such as a technote's
SQR-000handle.The organization that published the work.
The title of the work.
The kind of work being cited.
The work's landing page, when it is not simply the DOI's target.
The release of the work being cited, such as a package's
12.3.0.Methods Summary
to_bibtex(*[, entry_type, key])Compose the citation as a BibTeX entry.
Compose the citation as a plain-text bibliographic reference.
Attributes Documentation
- authors: tuple[PersonAuthor | OrganizationAuthor, ...] = ()#
The work’s authors, in the order they should be credited.
- bibtex_key#
The citation key that
to_bibtexuses by default.The key is the first author, the publication year, and the first word of the title, each reduced to lowercase ASCII alphanumerics — for example
sick2026citations. It is derived only from the citation’s own fields, so the same metadata always yields the same key and a bibliography that is regenerated on every build stays stable.A leading English article is skipped when the title word is chosen, so The Vera C. Rubin Observatory Data Butler is keyed
jenness2022verarather than by thetheit would otherwise share with every other title that opens with one.Citation.versionis deliberately left out of it. The key is what a reader’s\citecommands name, and folding the version in would rename every one of them each time the cited software was released.
- date: PartialDate | None = None#
The publication date, at the precision its source stated.
Only its year appears in a rendered citation; the precision matters to the machine-readable metadata, which publishes the date as schema.org
datePublished(seePartialDate).
- doi: str | None = None#
The work’s DOI, normalized to its bare
10.NNNN/suffixform.A DOI given in any spelling
normalize_doiaccepts is normalized when the citation is constructed; a value that is not a DOI raisesValueErrorthere rather than reaching a rendered page.
- location#
its DOI as a resolvable URL, or its landing page when it has no DOI, or
Nonewhen it has neither.This is the identifier
to_plain_textwrites at the end of the citation, and the URL a rendered citation hyperlinks.- Type:
Where the work is found
- number: str | None = None#
The work’s number within its series, such as a technote’s
SQR-000handle.This is a
BibtexEntryType.techreportfield; every other entry type has nowhere to put it and omits it.
- type: CitationType | None = None#
The kind of work being cited.
A citation that states its type is published under the matching schema.org type, which is what makes a dataset discoverable as one. The type is unset when nothing says what the work is, and a citation composes to the same plain text and BibTeX either way.
- version: str | None = None#
The release of the work being cited, such as a package’s
12.3.0.FORCE11’s software citation principles list the version among the elements a software citation has to carry, because software is the kind of work whose behavior changes between releases: a citation that names only the project says which code was run no more precisely than naming the language would. A dataset has the same need whenever it is released more than once, so the field is not restricted to software — only the entry types that have somewhere to put it are (see
to_bibtex).It is deliberately absent from
bibtex_key, so that a reader’s.bibfile keeps working across releases of the site that composed it.
Methods Documentation
- to_bibtex(*, entry_type=None, key=None)#
Compose the citation as a BibTeX entry.
- Parameters:
entry_type (
BibtexEntryType|None, default:None) – The BibTeX entry type, overriding the one the work’s owntypeimplies. Defaults toNone, which composes the entry as the typeBIBTEX_ENTRY_TYPESmapsCitation.typeonto —@datasetfor a dataset,@techreportfor a report, and@miscfor a work whose type is unstated.key (
str|None, default:None) – The entry’s citation key. Defaults tobibtex_key.
- Returns:
The BibTeX entry, without a trailing newline. Fields appear in a fixed order, so regenerating the entry from unchanged metadata never churns a file that stores it.
- Return type:
Notes
A date stated to the month or finer writes a
monthfield after theyear, as the English month name — the form BibTeX, biblatex, andlsst.biball read. A day never becomes a field of its own, because BibTeX has none to put it in.The publisher is the
institutionfield of aBibtexEntryType.techreportentry and thepublisherfield of every other entry type;Citation.numberis atechreportfield alone, and any other entry omits it.Citation.versionis written only for the entry types biblatex defines aversionfield on —@softwareand@dataset, seeBIBTEX_VERSIONED_TYPES— and is omitted for every other, which has nowhere to put it. No other field varies with the entry type, because the model carries no field — no journal or volume — that only one type has a home for. Theurlfield is the work’s own landing page when it has one, falling back to the DOI URL;doiandurlare written verbatim rather than LaTeX-escaped, matching what DataCite, Crossref, and Zenodo export, since a style’s\urlmacro takes its argument literally.An optional field whose value reduces to nothing once collapsed and escaped is omitted, rather than written as an empty pair of braces. The required
titlefield is always written, so that a blank title shows up as an entry to fix rather than as a silently missing field.
- to_plain_text()#
Compose the citation as a plain-text bibliographic reference.
- Returns:
The citation in DataCite’s recommended display format:
Creators (PublicationYear). Title. Publisher. Identifier, with aversion— when the work states one — qualifying the title. Creators are separated by semicolons because a person’s name itself contains a comma, and the identifier is the DOI URL when the work has a DOI and its landing page otherwise. A segment with no value — including one that is only whitespace — is dropped rather than left as empty punctuation.- Return type:
Notes
A dataset citation credited to an organization composes as:
Vera C. Rubin Observatory (2025). Data Preview 2. Vera C. Rubin Observatory. https://doi.org/10.71929/rubin/2570308