normalize_doi#

documenteer.citations.normalize_doi(value)#

Normalize a DOI into its bare form, 10.NNNN/suffix.

Parameters:

value (str) – A DOI, either in its bare form or expressed as a doi.org URL or with a doi: prefix. Whitespace around the DOI, and between a prefix and the DOI, is ignored.

Returns:

The bare DOI.

Return type:

str

Raises:

ValueError – Raised if the value is not a syntactically-valid DOI.

Notes

This is a reimplementation of normalize_doi in the technote package (technote.metadata.doi, also re-exported from technote.sources.tomlsettings), which validates a technote’s [technote] doi field. Documenteer repeats it so that user guides, documenteer technote sync-cff, and the technote linter — none of which goes through technote’s TOML model, and the last two of which run without the technote extra installed — normalize DOIs the same way a technote build does. tests/test_citations.py asserts the two agree whenever technote is installed.