From 5953e77abd1f101dd946aededa17dde9147ee7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 28 Jul 2023 15:50:10 +0200 Subject: [PATCH] Change to custom style --- docs/citation_style.jl | 44 ++++++++++++++++++++++++++++++++++++++++++ docs/make_work.jl | 4 +++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docs/citation_style.jl diff --git a/docs/citation_style.jl b/docs/citation_style.jl new file mode 100644 index 000000000000..4ded31ed5700 --- /dev/null +++ b/docs/citation_style.jl @@ -0,0 +1,44 @@ +# +# This file is included by docs/make_work.jl to define the custom citation style `oscar_style`. +# +# It is heavily based upon +# https://juliadocs.org/DocumenterCitations.jl/v1.0.0/gallery/#Custom-style:-Citation-key-labels +# + +import DocumenterCitations + +# we use some (undocumented) internal helper functions for formatting... +using DocumenterCitations: format_names, tex2unicode, italicize_md_et_al + +const oscar_style = :oscar + +# The long reference string in the bibliography +function DocumenterCitations.format_bibliography_reference(::Val{oscar_style}, entry) + return DocumenterCitations.format_bibliography_reference(:numeric, entry) +end + +# The label in the bibliography +function DocumenterCitations.format_bibliography_label(::Val{oscar_style}, entry, citations) + return "[$(entry.id)]" +end + +# The order of entries in the bibliography +DocumenterCitations.bib_sorting(::Val{oscar_style}) = :nyt # name, year, title + +# The type of html tag to use for the bibliography +DocumenterCitations.bib_html_list_style(::Val{oscar_style}) = :dl + +function DocumenterCitations.format_citation( + ::Val{oscar_style}, entry, citations; note, cite_cmd, capitalize, starred +) + link_text = isnothing(note) ? "[$(entry.id)]" : "[$(entry.id), $note]" + if cite_cmd == :citet + et_al = starred ? 0 : 1 # 0: no "et al."; 1: "et al." after 1st author + names = tex2unicode( + format_names(entry; names=:lastonly, and=true, et_al, et_al_text="*et al.*") + ) + capitalize && (names = uppercasefirst(names)) + link_text = italicize_md_et_al("$names $link_text") + end + return link_text +end diff --git a/docs/make_work.jl b/docs/make_work.jl index aa577907dd55..18c605247fc9 100644 --- a/docs/make_work.jl +++ b/docs/make_work.jl @@ -6,6 +6,8 @@ module BuildDoc using Documenter, DocumenterCitations +include("citation_style.jl") + # Overwrite printing to make the header not full of redundant nonsense # Turns # Hecke.Order - Method @@ -133,7 +135,7 @@ function doit( # Load the bibliography bib = CitationBibliography( - joinpath(Oscar.oscardir, "docs", "oscar_references.bib"); style=:alpha + joinpath(Oscar.oscardir, "docs", "oscar_references.bib"); style=oscar_style ) # Copy documentation from Hecke, Nemo, AnstratAlgebra