Skip to content

Commit a77e247

Browse files
authored
Build and publish API docs (#101)
* Add docs * Add CI to build docs * Fix wrong heading
1 parent b9cd48b commit a77e247

File tree

9 files changed

+155
-5
lines changed

9 files changed

+155
-5
lines changed

.github/workflows/Docs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
pull_request:
9+
branches:
10+
- main
11+
12+
concurrency:
13+
# Skip intermediate builds: always.
14+
# Cancel intermediate builds: only if it is a pull request build.
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
17+
18+
permissions:
19+
contents: write
20+
pull-requests: read
21+
statuses: write
22+
23+
jobs:
24+
docs:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: julia-actions/setup-julia@latest
29+
with:
30+
version: '1'
31+
- name: Install dependencies
32+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
33+
- name: Build and deploy
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
36+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
37+
JULIA_DEBUG: Documenter # Print `@debug` statements (https://github.com/JuliaDocs/Documenter.jl/issues/955)
38+
run: julia --project=docs/ docs/make.jl

.github/workflows/DocsNav.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Add Navbar
2+
3+
on:
4+
page_build: # Triggers the workflow on push events to gh-pages branch
5+
workflow_dispatch: # Allows manual triggering
6+
schedule:
7+
- cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC)
8+
9+
jobs:
10+
add-navbar:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout gh-pages
16+
uses: actions/checkout@v4
17+
with:
18+
ref: gh-pages
19+
fetch-depth: 0
20+
21+
- name: Download insert_navbar.sh
22+
run: |
23+
curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh
24+
chmod +x insert_navbar.sh
25+
26+
- name: Update Navbar
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
git config user.name github-actions[bot]
31+
git config user.email github-actions[bot]@users.noreply.github.com
32+
33+
# Define the URL of the navbar to be used
34+
NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/TuringNavbar.html"
35+
36+
# Update all HTML files in the current directory (gh-pages root)
37+
./insert_navbar.sh . $NAVBAR_URL
38+
39+
# Remove the insert_navbar.sh file
40+
rm insert_navbar.sh
41+
42+
# Check if there are any changes
43+
if [[ -n $(git status -s) ]]; then
44+
git add .
45+
git commit -m "Added navbar and removed insert_navbar.sh"
46+
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
47+
else
48+
echo "No changes to commit"
49+
fi

.github/workflows/TagBot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ jobs:
1212
- uses: JuliaRegistries/TagBot@v1
1313
with:
1414
token: ${{ secrets.GITHUB_TOKEN }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ docs/site/
2424
Manifest.toml
2525

2626
# vs code environment
27-
.vscode
27+
.vscode
28+
29+
.DS_Store

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Documenter
2+
using AbstractPPL
3+
4+
# Doctest setup
5+
DocMeta.setdocmeta!(AbstractPPL, :DocTestSetup, :(using AbstractPPL); recursive=true)
6+
7+
makedocs(;
8+
sitename="AbstractPPL",
9+
modules=[AbstractPPL],
10+
pages=[
11+
"Home" => "index.md",
12+
"API" => "api.md",
13+
],
14+
checkdocs=:exports,
15+
doctest=false,
16+
)
17+
18+
deploydocs(; repo="github.com/TuringLang/AbstractPPL.jl.git", push_preview=true)

docs/src/api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# API
2+
3+
## VarNames
4+
5+
```@docs
6+
VarName
7+
getsym
8+
getoptic
9+
inspace
10+
subsumes
11+
subsumedby
12+
vsym
13+
@varname
14+
@vsym
15+
```
16+
17+
## Abstract model functions
18+
19+
```@docs
20+
AbstractProbabilisticProgram
21+
condition
22+
decondition
23+
logdensityof
24+
AbstractContext
25+
evaluate!!
26+
```
27+
28+
## Abstract traces
29+
30+
```@docs
31+
AbstractModelTrace
32+
```

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# AbstractPPL.jl
2+
3+
A lightweight package containing interfaces and associated APIs for modelling languages for probabilistic programming.

src/varname.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Base.Symbol(vn::VarName) = Symbol(string(vn)) # simplified symbol
211211
inspace(vn::Union{VarName, Symbol}, space::Tuple)
212212
213213
Check whether `vn`'s variable symbol is in `space`. The empty tuple counts as the "universal space"
214-
containing all variables. Subsumption (see [`subsume`](@ref)) is respected.
214+
containing all variables. Subsumption (see [`subsumes`](@ref)) is respected.
215215
216216
## Examples
217217
@@ -322,6 +322,11 @@ subsumes(
322322
) = subsumes_indices(t, u)
323323

324324

325+
"""
326+
subsumedby(t, u)
327+
328+
True if `t` is subsumed by `u`, i.e., if `subsumes(u, t)` is true.
329+
"""
325330
subsumedby(t, u) = subsumes(u, t)
326331
uncomparable(t, u) = t u && u t
327332
const = subsumes
@@ -513,7 +518,7 @@ julia> y = zeros(10, 10);
513518
julia> @varname(y[:], true)
514519
y[:]
515520
516-
julia> # The underlying value is conretized, though:
521+
julia> # The underlying value is concretized, though:
517522
AbstractPPL.getoptic(AbstractPPL.concretize(@varname(y[:]), y)).indices[1]
518523
ConcretizedSlice(Base.OneTo(100))
519524
```
@@ -525,11 +530,11 @@ concretize(vn::VarName, x) = VarName(vn, concretize(getoptic(vn), x))
525530
526531
A macro that returns an instance of [`VarName`](@ref) given a symbol or indexing expression `expr`.
527532
528-
If `concretize` is `true`, the resulting expression will be wrapped in a [`concretize`](@ref) call.
533+
If `concretize` is `true`, the resulting expression will be wrapped in a `concretize()` call.
529534
530535
Note that expressions involving dynamic indexing, i.e. `begin` and/or `end`, will always need to be
531536
concretized as `VarName` only supports non-dynamic indexing as determined by
532-
[`is_static_index`](@ref). See examples below.
537+
`is_static_optic`. See examples below.
533538
534539
## Examples
535540

0 commit comments

Comments
 (0)