Skip to content

Commit e145c44

Browse files
authored
Merge pull request #47 from JuliaAstro/documenter-update
Documenter update and doctests in test suite
2 parents 87e62fd + ccca60b commit e145c44

File tree

7 files changed

+42
-20
lines changed

7 files changed

+42
-20
lines changed

Project.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Cosmology"
22
uuid = "76746363-e552-5dba-9a5a-cef6fa9cc5ab"
3-
version = "1.0.2"
3+
version = "1.0.3"
44

55
[deps]
66
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
@@ -15,6 +15,7 @@ julia = "1"
1515

1616
[extras]
1717
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1819

1920
[targets]
20-
test = ["Test"]
21+
test = ["Test", "Documenter"]

docs/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
44
UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f"
55

66
[compat]
7-
Documenter = "0.24, 0.25, 0.26, 0.27"
7+
Documenter = "0.24, 0.25, 0.26, 0.27, 1"

docs/make.jl

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Documenter
22
using Cosmology
3+
using Documenter.Remotes: GitHub
34

45

56
DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)
@@ -9,13 +10,16 @@ include("pages.jl")
910
makedocs(;
1011
modules = [Cosmology],
1112
authors = "Julia Astro",
12-
repo = "https://github.com/JuliaAstro/Cosmology.jl/blob/{commit}{path}#L{line}",
13+
repo = GitHub("JuliaAstro/Cosmology.jl"),
1314
sitename = "Cosmology.jl",
1415
format = Documenter.HTML(;
1516
prettyurls = get(ENV, "CI", "false") == "true",
1617
canonical = "https://juliaastro.github.io/Cosmology.jl",
17-
assets = String[],),
18-
pages=pages,)
18+
assets = String[],
19+
),
20+
pages=pages,
21+
)
1922

2023
deploydocs(;
21-
repo = "github.com/JuliaAstro/Cosmology.jl",)
24+
repo = "github.com/JuliaAstro/Cosmology.jl",
25+
)

docs/src/api.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
```@meta
2-
DocTestSetup = :(using Cosmology, Unitful, UnitfulAstro)
2+
DocTestSetup = quote
3+
using Cosmology, Unitful, UnitfulAstro
4+
ENV["UNITFUL_FANCY_EXPONENTS"] = false
5+
end
36
```
47

58
# API/Reference
@@ -62,7 +65,7 @@ julia> c = cosmology(OmegaM=0.26)
6265
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)
6366
6467
julia> comoving_volume_element(c, 2.1)
65-
46.74459228888612 Gpc^3
68+
46.74459228888613 Gpc^3
6669
6770
julia> comoving_volume(c, 0.6)
6871
49.3633436631307 Gpc^3
@@ -84,8 +87,8 @@ julia> c = cosmology(OmegaM=0.26)
8487
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)
8588
8689
julia> age(c, 1.2)
87-
5.445600787626434 Gyr
90+
5.4454795007229455 Gyr
8891
8992
julia> lookback_time(u"yr", c, 1.2)
90-
8.761660748088268e9 yr
93+
8.761465604385489e9 yr
9194
```

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://img.shields.io/travis/JuliaAstro/Cosmology.jl.svg?style=flat-square&label=build)](https://travis-ci.org/JuliaAstro/Cosmology.jl)
44
[![Coverage Status](http://img.shields.io/coveralls/JuliaAstro/Cosmology.jl.svg?style=flat-square)](https://coveralls.io/r/JuliaAstro/Cosmology.jl?branch=master)
55

6-
[`Cosmology.jl`](https://github.com/JuliaAstro/Cosmology.jl) provides functions for quick cosmological calculations, written in pure Julia.
6+
[`Cosmology.jl`](https://github.com/JuliaAstro/Cosmology.jl) provides functions for quick cosmological calculations, written in pure Julia.
77

88
## Installation
99

src/Cosmology.jl

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Cosmology
22

3-
using QuadGK, Unitful
3+
using QuadGK
4+
using Unitful
45
import Unitful: km, s, Gyr
56
using UnitfulAstro: Mpc, Gpc
67

@@ -187,7 +188,9 @@ comoving_radial_dist(c::AbstractCosmology, z₁, z₂ = nothing; kws...) = hubbl
187188
"""
188189
comoving_radial_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂)
189190
190-
Comoving radial distance in Mpc at redshift `z₂` as seen by an observer at `z₁`. Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if provided.
191+
Comoving radial distance in Mpc at redshift `z₂` as seen by an observer at `z₁`.
192+
Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if
193+
provided.
191194
"""
192195
comoving_radial_dist
193196

@@ -211,7 +214,9 @@ angular_diameter_dist(c::AbstractCosmology, z₁, z₂; kws...) =
211214
"""
212215
angular_diameter_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂)
213216
214-
Ratio of the proper transverse size in Mpc of an object at redshift `z₂` to its angular size in radians, as seen by an observer at `z₁`. Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if provided.
217+
Ratio of the proper transverse size in Mpc of an object at redshift `z₂` to its
218+
angular size in radians, as seen by an observer at `z₁`. Redshift `z₁` defaults
219+
to 0 if omitted. Will convert to compatible unit `u` if provided.
215220
"""
216221
angular_diameter_dist
217222

@@ -221,7 +226,8 @@ luminosity_dist(c::AbstractCosmology, z; kws...) =
221226
"""
222227
luminosity_dist([u::Unitlike,] c::AbstractCosmology, z)
223228
224-
Bolometric luminosity distance in Mpc at redshift `z`. Will convert to compatible unit `u` if provided.
229+
Bolometric luminosity distance in Mpc at redshift `z`. Will convert to
230+
compatible unit `u` if provided.
225231
"""
226232
luminosity_dist
227233

@@ -266,6 +272,7 @@ comoving_volume_element(c::AbstractCosmology, z; kws...) =
266272
# times
267273

268274
T(c::AbstractCosmology, a0, a1; kws...) = QuadGK.quadgk(x->x / a2E(c, x), a0, a1; kws...)[1]
275+
269276
"""
270277
age([u::Unitlike,] c::AbstractCosmology, z)
271278
@@ -276,14 +283,17 @@ age(c::AbstractCosmology, z; kws...) = hubble_time0(c) * T(c, 0, scale_factor(z)
276283
"""
277284
lookback_time([u::Unitlike,] c::AbstractCosmology, z)
278285
279-
Difference between age at redshift 0 and age at redshift `z` in Gyr. Will convert to compatible unit `u` if provided.
286+
Difference between age at redshift 0 and age at redshift `z` in Gyr.
287+
Will convert to compatible unit `u` if provided.
280288
"""
281289
lookback_time(c::AbstractCosmology, z; kws...) = hubble_time0(c) * T(c, scale_factor(z), 1; kws...)
282290

283291
# Easily select a different unit
284-
for f in (:hubble_dist0, :hubble_dist, :hubble_time0, :hubble_time, :comoving_radial_dist,
285-
:comoving_transverse_dist, :angular_diameter_dist, :luminosity_dist,
286-
:comoving_volume, :comoving_volume_element, :age, :lookback_time)
292+
for f in (:hubble_dist0, :hubble_dist, :hubble_time0, :hubble_time,
293+
:comoving_radial_dist, :comoving_transverse_dist,
294+
:angular_diameter_dist, :luminosity_dist,
295+
:comoving_volume, :comoving_volume_element,
296+
:age, :lookback_time)
287297
@eval $f(u::Unitful.Unitlike, args...; kws...) = uconvert(u, $f(args...; kws...))
288298
end
289299

test/runtests.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using Cosmology
22
using Test, Unitful, UnitfulAstro, QuadGK
3+
using Documenter
4+
5+
DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)
6+
doctest(Cosmology)
37

48
# values from http://icosmos.co.uk/
59

0 commit comments

Comments
 (0)