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.
Compose the citation as the two halves a linked rendering needs: the reference up to where the work is located, and that location itself.
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
A surface that hyperlinks the identifier reads the same reference pre-split from
to_plain_text_partsinstead, rather than slicing this text.
- to_plain_text_parts()#
Compose the citation as the two halves a linked rendering needs: the reference up to where the work is located, and that location itself.
- Return type:
- Returns:
lead (str) – The citation up to its trailing location, ending in the single space that separates the two. It is the whole reference when the work has no location, and empty when the citation is nothing but one.
location (str or None) – Where the work is found — see
location— orNonewhen the citation has neither a DOI nor a landing page to name.
Notes
Joining the halves reproduces
to_plain_textexactly: that method is written in terms of this one, so the invariant holds structurally rather than by two implementations agreeing.The split exists because a displayed citation ends in a hyperlink to the work, and a surface that writes the lead as text and the location as a link must not compose either half itself. Every such surface reads the split from here — the guide’s footer and citation card through
GuideCitation.to_html_context, and the technote’s article footer through itsTechnoteCitation.plain_text_lead— which is what keeps them from disagreeing about where the text ends and the link begins.