Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
1b1a560
copy make.jl from st/examples
st-- Jun 16, 2021
7cabf13
add general docs dependencies
st-- Jun 16, 2021
d2cefec
clean up
st-- Jun 16, 2021
60acddb
auto-collect examples as suggested
st-- Jun 16, 2021
1831892
add docs dependencies for notebooks
st-- Jun 16, 2021
a594008
fix direct notebook bug
st-- Jun 16, 2021
271d3d7
add blacklist as pairwise() is broken
st-- Jun 16, 2021
ef894a4
comment out examples as it breaks for non-existing directory (everyth…
st-- Jun 16, 2021
beb4adb
add docs README
st-- Jun 16, 2021
00ccba9
Apply suggestions from code review
st-- Jun 16, 2021
feda9e0
remove duplicate doc entries
st-- Jun 16, 2021
e30169f
Merge branch 'st/examples-base' of github.com:JuliaGaussianProcesses/…
st-- Jun 16, 2021
901b5d0
revert deletion
st-- Jun 16, 2021
a1718a3
separate examples into individual diretories with own Project.toml
st-- Jun 17, 2021
66706c0
handle empty examples directory
st-- Jun 17, 2021
bddbea8
update README for non-unix systems
st-- Jun 17, 2021
c4a36f8
Apply suggestions from code review
st-- Jun 17, 2021
384ac9c
Apply suggestions from code review
st-- Jun 17, 2021
80deae7
revert removed doc
st-- Jun 17, 2021
004d45e
Merge branch 'st/examples-base' of github.com:JuliaGaussianProcesses/…
st-- Jun 17, 2021
cd0bc2b
Apply suggestions from code review
st-- Jun 21, 2021
75db97d
remove unused dependencies from svm example
st-- Jun 21, 2021
8c657bc
fix bug in svm notebook
st-- Jun 21, 2021
7ac29c6
Merge branch 'st/examples-base' of github.com:JuliaGaussianProcesses/…
st-- Jun 21, 2021
001dfc3
Apply suggestions from code review
st-- Jun 21, 2021
a60e230
fix examples scripts compose
st-- Jun 21, 2021
b2faceb
Merge branch 'st/examples-base' of github.com:JuliaGaussianProcesses/…
st-- Jun 21, 2021
14ad37d
fix script output name
st-- Jun 21, 2021
715e0a5
bugfix
st-- Jun 21, 2021
09990f8
include preprocessor for Documenter@setup
st-- Jun 21, 2021
4f34f37
Apply suggestions from code review
st-- Jun 21, 2021
f2db1ea
Correct file_path for environment
theogf Jun 21, 2021
c8298ec
Adding the necessary header for the @setup replacement
theogf Jun 21, 2021
754a8db
correct headers for remaining examples scripts
st-- Jun 22, 2021
8641c78
fix KRR notebook and swap it with SVM in blacklist
st-- Jun 22, 2021
407d6f0
do not execute notebook
st-- Jun 22, 2021
3e452ae
update .gitignore
st-- Jun 22, 2021
262ceef
Update docs/make.jl
st-- Jun 22, 2021
495bf19
update docs and examples README and ignore examples/README in docs/ma…
st-- Jun 23, 2021
34c97fa
fix plotting
st-- Jun 23, 2021
87da659
Update examples/kernel-ridge-regression/script.jl
st-- Jun 23, 2021
e851307
add under-construction warnings to examples
st-- Jun 23, 2021
b3c8aa6
copy over fixes from KRR example
st-- Jun 23, 2021
6fd8175
Apply suggestions from code review
st-- Jun 23, 2021
16ba774
Merge branch 'master' of github.com:JuliaGaussianProcesses/KernelFunc…
st-- Jun 28, 2021
11119c2
Merge remote-tracking branch 'origin' into st/examples-base
st-- Jun 29, 2021
f034c63
commit examples/*/Manifest.toml
st-- Jun 29, 2021
2fa2f1b
fix optional package loading
st-- Jun 29, 2021
6b3238b
doc fixes
st-- Jun 29, 2021
1ea5c6c
explicit Pkg.add of Literate
st-- Jun 29, 2021
241cf62
Apply suggestions from code review
st-- Jun 29, 2021
df1c526
Update examples/README.md
st-- Jun 29, 2021
cac9e7d
update README
st-- Jun 29, 2021
f2d8dcc
Update docs/Project.toml
st-- Jun 29, 2021
d060958
Merge branch 'master' into st/examples-base
st-- Jun 29, 2021
2b1627b
update examples *.toml
st-- Jun 29, 2021
a91edc9
use cleaner f form
st-- Jun 29, 2021
1daf1c3
fix errors
st-- Jun 29, 2021
b262ac0
fix example Manifest.tomls
st-- Jun 29, 2021
4cce78e
Update examples/README.md
st-- Jun 29, 2021
64d5ef7
better error messages?
st-- Jun 29, 2021
bf47391
Merge branch 'st/examples-base' of github.com:JuliaGaussianProcesses/…
st-- Jun 29, 2021
853b437
Revert "better error messages?"
st-- Jun 29, 2021
eff7c11
give responsibility for adding Literate dependency back to examples
st-- Jun 29, 2021
a44d48f
preprocess header in italics
st-- Jun 29, 2021
fa0033b
Apply suggestions from code review
st-- Jun 30, 2021
1fd657d
Update examples/README.md
st-- Jun 30, 2021
735b437
compat for Kronecker in docs
st-- Jun 30, 2021
03a6840
add [compat]
st-- Jun 30, 2021
7aebf83
Apply suggestions from code review
st-- Jun 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/Manifest.toml
/test/Manifest.toml
coverage/
src/update_v0.8.0
.DS_store
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build/
site/
src/examples/
src/examples/
18 changes: 18 additions & 0 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# This file is machine-generated - editing it directly is not advised

[[AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "051c95d6836228d120f5f4b984dd5aba1624f716"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "0.5.0"

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

Expand Down Expand Up @@ -115,6 +121,12 @@ path = ".."
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
version = "0.10.6"

[[Kronecker]]
deps = ["FillArrays", "LinearAlgebra", "NamedDims", "SparseArrays", "StatsBase"]
git-tree-sha1 = "90e082a267982069e624ea0f825d324c86a01b4e"
uuid = "2c470bb0-bcc8-11e8-3dad-c9649493f05e"
version = "0.4.3"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
Expand Down Expand Up @@ -173,6 +185,12 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[NamedDims]]
deps = ["AbstractFFTs", "LinearAlgebra", "Pkg", "Requires", "Statistics"]
git-tree-sha1 = "e91d3ee8ac1514651b6e85686ca31257d17b1eb2"
uuid = "356022a1-0364-5f58-8944-0da4b18d706f"
version = "0.2.33"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
KernelFunctions = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
Kronecker = "2c470bb0-bcc8-11e8-3dad-c9649493f05e"
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"

[compat]
Documenter = "0.27"
KernelFunctions = "0.10"
PDMats = "0.11"
Kronecker = "0.4"
julia = "1.3"
63 changes: 63 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# How to build the docs locally
Copy link
Member Author

Choose a reason for hiding this comment

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

Happy to get improvements to the workflow. :)


If you just want to modify or add an example, you can [build just the example](../examples/README.md) without having to build the full documentation locally.

If you want to build the documentation, navigate to this (docs/) directory and open a Julia REPL.

## Instantiation

First activate the documentation environment:
```julia
julia> ] activate .
```
Alternatively, you can start Julia with `julia --project=.`.

Then install all packages:
```julia
julia> ] instantiate
```
By default, this will use the development version of KernelFunctions in the parent directory.

## Build

To build the documentation, run (after activating the documentation environment)
```julia
julia> include("make.jl")
```
You can speed up the process if you do not execute the examples and comment out the
relevant sections in `docs/make.jl`.

The output is in the `docs/build/` directory and best viewed in a browser.
The documentation uses pretty URLs which can be a hindrance if you browse the documentation locally.
The [Documenter documentation](https://juliadocs.github.io/Documenter.jl/stable/man/guide/#Building-an-Empty-Document) suggests that

> You can run a local web server out of the `docs/build` directory. One way to accomplish
> this is to install the [LiveServer](https://github.com/tlienart/LiveServer.jl) Julia
> package. You can then start the server with `julia -e 'using LiveServer; serve(dir="docs/build")'`.
> Alternatively, if you have Python installed, you can start one with
> `python3 -m http.server --bind localhost` (or `python -m SimpleHTTPServer` with Python 2).

If you make any changes, you can run
```julia
julia> include("make.jl")
```
again to rebuild the documentation.

# How to contribute to the docs

## To add additional docs dependencies

To add additional dependencies, run (after activating the documentation environment)
```julia
julia> ] add NewDependency
```
or, as a shell one-liner:
```shell
julia --project=. -e 'using Pkg; Pkg.add("NewDependency")'
```
and commit the changes to Project.toml and Manifest.toml.


## To add examples

See [../examples](../examples/README.md)
8 changes: 4 additions & 4 deletions docs/literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const OUTDIR = ARGS[2]
# Activate environment
using Pkg: Pkg
Pkg.activate(dirname(SCRIPTJL))
# Note that each example's Project.toml must include Literate as a dependency
Pkg.instantiate()
using Literate: Literate

Expand All @@ -23,14 +24,13 @@ function preprocess(content)
#
#md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/examples/@__NAME__.ipynb)
#md #
# You are seeing the
# *You are seeing the
#md # HTML output generated by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and
#nb # notebook output generated by
# [Literate.jl](https://github.com/fredrikekre/Literate.jl) from the
# [Julia source file](@__REPO_ROOT_URL__/examples/@__NAME__/script.jl).
# The corresponding
#md # notebook can be viewed in [nbviewer](@__NBVIEWER_ROOT_URL__/examples/@__NAME__.ipynb).
#nb # HTML output can be viewed [here](https://juliagaussianprocesses.github.io/KernelFunctions.jl/dev/examples/@__NAME__/).
#md # The corresponding notebook can be viewed in [nbviewer](@__NBVIEWER_ROOT_URL__/examples/@__NAME__.ipynb).*
#nb # The rendered HTML can be viewed [in the docs](https://juliagaussianprocesses.github.io/KernelFunctions.jl/dev/examples/@__NAME__/).*
Copy link
Member Author

Choose a reason for hiding this comment

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

How difficult would it be to change the dev to whichever build it actually is?

Copy link
Member

Choose a reason for hiding this comment

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

Not difficult but a bit annoying it seems. Literate automatically derives the url for the repo and nbviewer when running it with Github actions which are used to replace @__NBVIEWER_ROOT_URL__ and @__REPO_ROOT_URL__ after the custom user-defined replacements. However, we can't use these urls or subparts of them in our preprocessing and there are no similar "magic" variables for the github.io webpage (which seems reasonable somehow since one can use e.g. custom domains and hence it is not clear what the correct url for the webpage should be). So I think one has to copy the logic in https://github.com/fredrikekre/Literate.jl/blob/8d8caac6e651eb02ded5699835384d0f0b139e78/src/Literate.jl#L248-L258 to derive the deploy_folder and use it instead of dev. Maybe one could ask if Literate could add an automatic replacement for @__DEPLOY_FOLDER__, similar to @__REPO_ROOT_URL__.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for looking into this. Would you be willing to write it up as an issue in the Literate.jl repo ?

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thank you @fredrikekre !

#
""",
)
Expand Down
13 changes: 6 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# run examples
### Process examples
const EXAMPLES_SRC = joinpath(@__DIR__, "..", "examples")
const EXAMPLES_OUT = joinpath(@__DIR__, "src", "examples")
const LITERATEJL = joinpath(@__DIR__, "literate.jl")
Expand All @@ -24,10 +24,12 @@ end
# Check that all examples were run successfully
isempty(processes) || success(processes) || error("some examples were not run successfully")

# Build documentation
using KernelFunctions
### Build documentation
using Documenter

using KernelFunctions
using PDMats, Kronecker # we have to load all optional packages to generate the full API documentation

# Print `@debug` statements (https://github.com/JuliaDocs/Documenter.jl/issues/955)
if haskey(ENV, "GITHUB_ACTIONS")
ENV["JULIA_DEBUG"] = "Documenter"
Expand All @@ -39,10 +41,7 @@ DocMeta.setdocmeta!(
:DocTestSetup,
quote
using KernelFunctions
using LinearAlgebra
using Random
using PDMats: PDMats
Comment on lines -42 to -44
Copy link
Member

Choose a reason for hiding this comment

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

Are these not needed anymore for the doctests?

Copy link
Member Author

Choose a reason for hiding this comment

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

clearly not :)

end;
end; # we have to load all packages used (implicitly) within jldoctest blocks in the API docstrings
recursive=true,
)

Expand Down
2 changes: 1 addition & 1 deletion docs/src/create_kernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Here are a few ways depending on how complicated your kernel is:

If your kernel function is of the form `k(x, y) = f(d(x, y))` where `d(x, y)` is a `PreMetric`,
you can construct your custom kernel by defining `kappa` and `metric` for your kernel.
Here is for example how one can define the `SqExponentialKernel` again :
Here is for example how one can define the `SqExponentialKernel` again:

```julia
struct MyKernel <: KernelFunctions.SimpleKernel end
Expand Down
52 changes: 52 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Example notebooks

The examples in this directory are stored in [Literate.jl](https://github.com/fredrikekre/Literate.jl) format.

To run them locally, navigate to the directory with the example that you want to run and
start the Julia REPL and activate the project environment of the example:
```julia
julia> ] activate .
```
Alternatively, you can start Julia with `julia --project=.`. Then install all required
packages with
```julia
julia> ] instantiate
```
Afterwards simply run
```julia
julia> include("script.jl")
```
In particular when editing an example, it can be convenient to (re-)run only some parts of
an example.
Many editors with Julia support such as VSCode, Juno, and Emacs support the evaluation of individual lines or code chunks.

You can convert a notebook to markdown and Jupyter notebook formats, respectively, by executing
```julia
julia> using Literate
julia> Literate.markdown("script.jl", "output_directory")
julia> Literate.notebook("script.jl", "output_directory")
```
(see the [Literate.jl docs](https://fredrikekre.github.io/Literate.jl/v2/) for additional options) or run
```shell
julia docs/literate.jl examples/myexample/script.jl output_directory
```
which also executes the code and generates embedded plots etc. in the same way as in building the KernelFunctions documentation.

## Add a new example

Create a new subdirectory in here, and put your code in a file called `script.jl` so that it will get picked up by the automatic docs build.

Every example uses a separate project environment. Therefore you should also create a new
project environment in the directory of the example that contains all packages required by your script.
Note that the dependencies of your example *must* include the `Literate` package.

From a Julia REPL started in your example script's directory, you can run
```julia
julia> ] activate .
julia> ] add Literate
julia> ] add KernelFunctions
julia> # add any other example-specific dependencies
```
to generate the project files.

Make sure to commit both the `Project.toml` and the `Manifest.toml` file when you want to contribute your example in a pull request.
Loading