Skip to content

Commit

Permalink
Added sorting flags which are now supported by Bibliography.jl (#39)
Browse files Browse the repository at this point in the history
* Added sorting flags which are now supported by Bibliography.jl

* Changed to use argument keyword and adapted to coding style.

Co-authored-by: LazyScholar <[email protected]>
  • Loading branch information
LazyScholar and LazyScholar authored Jun 19, 2021
1 parent 9c44935 commit 8606536
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
18 changes: 9 additions & 9 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BibInternal]]
git-tree-sha1 = "3cdd672174e3bae099195cf949f21c1a9ded98e5"
git-tree-sha1 = "cf9e376a6cbac1dd70ee491bc64de29c3ea8ff86"
uuid = "2027ae74-3657-4b95-ae00-e2f7d55c3e64"
version = "0.2.9"
version = "0.2.10"

[[BibParser]]
deps = ["BibInternal", "DataStructures"]
Expand All @@ -16,9 +16,9 @@ version = "0.1.14"

[[Bibliography]]
deps = ["BibInternal", "BibParser", "DataStructures"]
git-tree-sha1 = "c3d1de7c7eaa693a7cce11b20ec6f896a4b8e44a"
git-tree-sha1 = "8190dc076a020c92a7a78a069244ff6cd08e86ac"
uuid = "f1be7e48-bf82-45af-a471-ae754a193061"
version = "0.2.8"
version = "0.2.9"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
Expand Down Expand Up @@ -52,15 +52,15 @@ version = "0.8.5"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "5acbebf1be22db43589bc5aa1bb5fcc378b17780"
git-tree-sha1 = "621850838b3e74dd6dd047b5432d2e976877104e"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.27.0"
version = "0.27.2"

[[IOCapture]]
deps = ["Logging"]
git-tree-sha1 = "1868e4e7ad2f93d8de0904d89368c527b46aa6a1"
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.1"
version = "0.2.2"

[[InteractiveUtils]]
deps = ["Markdown"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DocumenterCitations"
uuid = "daee34ce-89f3-4625-b898-19384cb65244"
version = "0.2.3"
version = "0.2.4"

[deps]
Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Documenter
using DocumenterCitations

bib = CitationBibliography(joinpath(@__DIR__, "example.bib"))
bib = CitationBibliography(joinpath(@__DIR__, "example.bib"), sorting = :nyt)

makedocs(
bib,
Expand Down
10 changes: 10 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ bib = CitationBibliography("some_references.bib")
makedocs(bib, ...)
```

## How to get a sorted References list

In order to get a sorted references list you can pass a additional `sorting` argument to `CitationBibliography()`.

```julia
bib = CitationBibliography("some_references.bib", sorting = :nyt)
```

The currently supported sorting orders and their behaviours are managed by [`Bibliography.sorting_rules`](https://humans-of-julia.github.io/Bibliography.jl/stable/#Bibliography.sorting_rules).

## How to cite references in your documentation

You can now use citations anywhere in your docs!
Expand Down
6 changes: 5 additions & 1 deletion src/DocumenterCitations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export CitationBibliography
struct CitationBibliography <: Documenter.Plugin
bib::Dict
end
function CitationBibliography(filename::AbstractString="")
function CitationBibliography(filename::AbstractString = "";
sorting::Symbol = :none)
filename == "" && return CitationBibliography(Dict())
bf = import_bibtex(filename)
if sorting != :none
sort_bibliography!(bf, sorting)
end
return CitationBibliography(bf)
end

Expand Down

2 comments on commit 8606536

@LazyScholar
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/39201

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.4 -m "<description of version>" 8606536a10cd2c6328fd91cf0d4de180dad3b3a8
git push origin v0.2.4

Please sign in to comment.