Skip to content

Commit

Permalink
Fix doctest job (#437)
Browse files Browse the repository at this point in the history
* Update doctests

* Flags for building documentation

* Run doctests against Julia 1.9

* Use Julia shell in CI

* Rename docs job
  • Loading branch information
omus authored Jun 19, 2023
1 parent 630d506 commit 57d4a99
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 63 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,37 @@ jobs:
TZDATA_VERSION: 2016j # Matches tzdata version used in tests
doctest:
name: Documentation - Julia ${{ matrix.version }}
runs-on: ${{ matrix.os }}
name: Documentation - DocTests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: "1.9"
- uses: julia-actions/julia-buildpkg@latest
- run: |
julia --project=docs -e '
using Pkg
Pkg.instantiate()'
- shell: julia --color=yes --project=docs {0}
run: |
using Pkg
Pkg.instantiate()
- run: julia --project=docs docs/make.jl
env:
RUN_DOCTESTS: true
DOCTESTS: "true"

docs:
name: Documentation
name: Documentation - Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: "1.9"
- uses: julia-actions/julia-buildpkg@latest
- run: |
julia --project=docs -e '
using Pkg
Pkg.instantiate()'
- run: julia --project=docs docs/deploy.jl
- shell: julia --color=yes --project=docs {0}
run: |
using Pkg
Pkg.instantiate()
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
DEPLOY_DOCS: "true"
4 changes: 2 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.9.1"
julia_version = "1.9.0"
manifest_format = "2.0"
project_hash = "04a376dcfe7438944731ff470e030eee876cc2bc"
project_hash = "b0e0fdd6d2084cf873bc7d6040a84520736d76d6"

[[deps.ANSIColoredPrinters]]
git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

Expand Down
5 changes: 0 additions & 5 deletions docs/deploy.jl

This file was deleted.

59 changes: 38 additions & 21 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
using Dates, Documenter, TimeZones

makedocs(
modules=[TimeZones],
format=Documenter.HTML(prettyurls=get(ENV, "CI", nothing) == "true"),
pages=[
"Introduction" => "index.md",
"Types" => "types.md",
"Converting" => "conversions.md",
"Arithmetic" => "arithmetic.md",
"Rounding" => "rounding.md",
"Current Time" => "current.md",
"Frequently Asked Questions" => "faq.md",
"API – Public" => "api-public.md",
"API – Private" => "api-private.md",
],
sitename="TimeZones.jl",
checkdocs=:exports,
linkcheck=true,
strict=true,
# RUN_DOCTESTS=true is set by the doctest CI jobs
doctest=get(ENV, "RUN_DOCTESTS", nothing) == "true",
)
DocMeta.setdocmeta!(TimeZones, :DocTestSetup, :(using TimeZones))

if haskey(ENV, "DOCTESTS") || haskey(ENV, "MAKE_DOCS") || haskey(ENV, "DEPLOY_DOCS")
const DOCTESTS = get(ENV, "DOCTESTS", "false") == "true"
const MAKE_DOCS = get(ENV, "MAKE_DOCS", "false") == "true"
const DEPLOY_DOCS = get(ENV, "DEPLOY_DOCS", "false") == "true"
else
const DOCTESTS = true
const MAKE_DOCS = true
const DEPLOY_DOCS = false
end

if MAKE_DOCS || DEPLOY_DOCS
makedocs(
modules=[TimeZones],
format=Documenter.HTML(prettyurls=get(ENV, "CI", nothing) == "true"),
pages=[
"Introduction" => "index.md",
"Types" => "types.md",
"Converting" => "conversions.md",
"Arithmetic" => "arithmetic.md",
"Rounding" => "rounding.md",
"Current Time" => "current.md",
"Frequently Asked Questions" => "faq.md",
"API – Public" => "api-public.md",
"API – Private" => "api-private.md",
],
sitename="TimeZones.jl",
checkdocs=:exports,
linkcheck=true,
strict=true,
doctest=DOCTESTS,
)

DEPLOY_DOCS && deploydocs(repo="github.com/JuliaTime/TimeZones.jl.git")
elseif DOCTESTS
doctest(TimeZones)
end
6 changes: 0 additions & 6 deletions docs/src/api-private.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# TimeZones Internal API

```@meta
DocTestSetup = quote
using TimeZones
end
```

## TZData

```@docs
Expand Down
6 changes: 0 additions & 6 deletions docs/src/api-public.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# TimeZones Public API

```@meta
DocTestSetup = quote
using TimeZones
end
```

## TimeZone

```@docs
Expand Down
22 changes: 12 additions & 10 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ the less-than (<) and greater-than (>) signs the character set is expanded to in
plus (+) sign, the minus (-) sign, and digits.
# Examples
```jldoctest
```jldoctest; setup = :(using TimeZones: _parsesub_tzabbr)
julia> _parsesub_tzabbr("ABC+1")
("ABC", 4)
julia> _parsesub_tzabbr("<ABC+1>+2")
("ABC+1", 6)
("ABC+1", 8)
```
"""
function _parsesub_tzabbr(
Expand Down Expand Up @@ -182,12 +182,12 @@ between 0 and 24, and the minutes and seconds 00 and 59. This follows specificat
offsets as defined in the tzset(3) man page.
# Example
```jldoctest
```jldoctest; setup = :(using TimeZones: _parsesub_offset)
julia> _parsesub_offset("1:0:0")
(3600, 5)
(3600, 6)
julia> _parsesub_offset("-0:1:2")
(-62, 6)
(-62, 7)
```
"""
function _parsesub_offset(
Expand Down Expand Up @@ -280,23 +280,25 @@ includes an anonymous function which takes the argument `year::Integer` and retu
the last week in which day `d` occurs. Day 0 is a Sunday.
# Example
```jldoctest
```jldoctest; setup = :(using TimeZones: _parsesub_tzdate)
julia> f, i = _parsesub_tzdate("J60");
julia> f.(2019:2020)
2-element Array{Date,1}:
2-element Vector{Date}:
2019-03-01
2020-03-01
julia> f, i = _parsesub_tzdate("60");
2-element Array{Date,1}:
julia> f.(2019:2020)
2-element Vector{Date}:
2019-03-02
2020-03-01
julia> f, i = _parsesub_tzdate("M3.3.0"); # Third Sunday in March
julia> f.(2019:2020)
2-element Array{Date,1}:
2-element Vector{Date}:
2019-03-17
2020-03-15
```
Expand Down Expand Up @@ -449,7 +451,7 @@ end
Parse a direct representation of a time zone as specified by the tzset(3) man page.
# Examples
```jldoctest
```jldoctest; setup = :(using TimeZones: _parsesub_tz)
julia> first(_parsesub_tz("EST+5"))
EST (UTC-5)
Expand Down

0 comments on commit 57d4a99

Please sign in to comment.