Skip to content

Commit

Permalink
Change to custom style
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 28, 2023
1 parent 40b7470 commit 5953e77
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
44 changes: 44 additions & 0 deletions docs/citation_style.jl
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion docs/make_work.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5953e77

Please sign in to comment.