Skip to content

Commit 434ac43

Browse files
authored
Merge pull request #418 from bwheelz36/html_docs
SPHINX based html docs
2 parents 698ca60 + ab3c41f commit 434ac43

File tree

12 files changed

+278
-26
lines changed

12 files changed

+278
-26
lines changed

.github/workflows/build_docs.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: build docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-20.04
12+
permissions:
13+
contents: write
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: '3.10'
23+
- name: Install pandoc
24+
run: sudo apt-get install -y pandoc
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install sphinx
29+
pip install nbsphinx
30+
pip install sphinx_rtd_theme
31+
pip install jupyter
32+
- name: Install package
33+
run: |
34+
pip install -e .
35+
- name: build sphinx docs
36+
run: |
37+
cd docsrc
38+
make github
39+
- name: Deploy
40+
uses: peaceiris/actions-gh-pages@v3
41+
if: ${{ github.ref == 'refs/heads/main' }}
42+
with:
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
publish_dir: ./docs

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ venv/
2828
ENV/
2929
env.bak/
3030
venv.bak/
31-
*temp*
31+
*temp*
32+
33+
docs/*
34+
docsrc/.ipynb_checkpoints/*
35+
docsrc/*.ipynb

docsrc/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = ../docs
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
# help:
13+
# @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
github:
18+
@make html
19+
@cp -a ../docs/html/. ../docs
20+
21+
# Catch-all target: route all unknown targets to Sphinx using the new
22+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
23+
%: Makefile
24+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docsrc/code_docs.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Code Documentation
2+
==================
3+
4+
This page shows the documentation generated by sphinx automatically scanning our source code
5+
6+
Bayesian Optimization
7+
---------------------
8+
9+
.. automodule:: bayes_opt.bayesian_optimization
10+
:members:
11+
12+
Acquisition function
13+
--------------------
14+
15+
.. autoclass:: bayes_opt.util.UtilityFunction
16+
:members:
17+
18+
Target Space
19+
------------
20+
21+
.. autoclass:: bayes_opt.target_space.TargetSpace
22+
:members:
23+
24+
Domain reduction
25+
----------------
26+
27+
.. autoclass:: bayes_opt.domain_reduction.SequentialDomainReductionTransformer
28+
:members:
29+
30+
Constraints
31+
-----------
32+
33+
.. autoclass:: bayes_opt.constraint.ConstraintModel
34+
:members:

docsrc/conf.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
import shutil
16+
from glob import glob
17+
from pathlib import Path
18+
# sys.path.insert(0, os.path.abspath('.'))
19+
sys.path.insert(0, os.path.abspath('..'))
20+
21+
# copy the latest example files:
22+
this_file_loc = Path(__file__).parent
23+
notebooks = glob(str(this_file_loc.parent / 'examples' / '*.ipynb'))
24+
for notebook in notebooks:
25+
shutil.copy(notebook, this_file_loc)
26+
27+
28+
# -- Project information -----------------------------------------------------
29+
30+
project = 'Bayesian Optimization'
31+
author = 'Fernando Nogueira'
32+
33+
34+
# -- General configuration ---------------------------------------------------
35+
36+
# Add any Sphinx extension module names here, as strings. They can be
37+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
38+
# ones.
39+
extensions = [
40+
'sphinx.ext.autodoc',
41+
'sphinx.ext.coverage',
42+
'sphinx.ext.githubpages',
43+
'nbsphinx',
44+
'IPython.sphinxext.ipython_console_highlighting',
45+
'sphinx.ext.mathjax']
46+
47+
source_suffix = {
48+
'.rst': 'restructuredtext',
49+
'.md': 'markdown',
50+
}
51+
# Add any paths that contain templates here, relative to this directory.
52+
templates_path = ['_templates']
53+
54+
# List of patterns, relative to source directory, that match files and
55+
# directories to ignore when looking for source files.
56+
# This pattern also affects html_static_path and html_extra_path.
57+
exclude_patterns = []
58+
59+
60+
# -- Options for HTML output -------------------------------------------------
61+
62+
# The theme to use for HTML and HTML Help pages. See the documentation for
63+
# a list of builtin themes.
64+
#
65+
html_theme = 'sphinx_rtd_theme'
66+
67+
# Add any paths that contain custom static files (such as style sheets) here,
68+
# relative to this directory. They are copied after the builtin static files,
69+
# so a file named "default.css" will overwrite the builtin "default.css".
70+
# html_static_path = ['_static']

docsrc/examples.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Examples
2+
========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Examples:
7+
8+
/basic-tour
9+
/advanced-tour
10+
/exploitation_vs_exploration
11+
/visualization
12+
/constraints
13+
/domain_reduction

docsrc/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Bayesian Optimization
2+
=====================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
/examples
9+
/code_docs
10+
11+
Indices and tables
12+
==================
13+
14+
* :ref:`genindex`
15+
* :ref:`modindex`
16+
* :ref:`search`

docsrc/make.bat

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=../docs
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
if "%1" == "github" (
29+
%SPHINXBUILD% -M html %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
robocopy %BUILDDIR%/html ../docs /E > nul
31+
echo.Generated files copied to ../docs
32+
goto end
33+
)
34+
35+
36+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
37+
goto end
38+
39+
40+
:help
41+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
42+
43+
:end
44+
popd

docsrc/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx
2+
nbsphinx
3+
sphinx_rtd_theme

examples/constraints.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"2. Expensive constraints - in other situations, you may not know whether or not a given solution violates your constraints until you have explicitly evaluate the objective function there - which is typically an expensive operation. In such situations, it is desirable to **learn** the constrained regions on the fly in order to avoid unnecessary expensive calls to the objective function. The way to handle these situations is described in **2. Advanced Constrained Optimization**\n",
1515
"\n",
1616
"\n",
17-
"# 1. Simple Constrained Optimization\n",
17+
"## 1. Simple Constrained Optimization\n",
1818
"\n",
1919
"In situations where you know in advance whether or not a given point violates your constraints, you can normally simply code them directly into the objective function. To demonstrate this, let's start with a standard non-constrained optimization:"
2020
]
@@ -161,7 +161,7 @@
161161
"cell_type": "markdown",
162162
"metadata": {},
163163
"source": [
164-
"# 2. Advanced Constrained Optimization"
164+
"## 2. Advanced Constrained Optimization"
165165
]
166166
},
167167
{

0 commit comments

Comments
 (0)