-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: implement ReadTheDocs documentation (#58)
- Loading branch information
Showing
12 changed files
with
312 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
docs/source/generated | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build: | ||
image: latest | ||
python: | ||
version: 3.8 | ||
pip_install: true | ||
install: | ||
- requirements: docs/requirements.txt | ||
extra_requirements: | ||
- docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Pins sphinx version, probably won't need updating for a while | ||
sphinx>=3.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:mod:`{{module}}`.{{objname}} | ||
{{ underline }}============== | ||
|
||
.. currentmodule:: {{ module }} | ||
|
||
.. autoclass:: {{ objname }} | ||
:members: | ||
|
||
.. raw:: html | ||
|
||
<div class="clearer"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
API | ||
=== | ||
|
||
.. autosummary:: | ||
:template: class.rst | ||
:toctree: generated/ | ||
|
||
scikeras.wrappers.KerasClassifier | ||
scikeras.wrappers.KerasRegressor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
import os | ||
import sys | ||
|
||
|
||
sys.path.insert(0, os.path.abspath("..")) | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
from scikeras import __version__ | ||
|
||
|
||
project = "SciKeras" | ||
copyright = "2020, SciKeras Developers" | ||
author = "SciKeras Developers" | ||
release = __version__ | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# on_rtd is whether we are on readthedocs.org, this line of code grabbed | ||
# from docs.readthedocs.org | ||
on_rtd = os.environ.get("READTHEDOCS", None) == "True" | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.napoleon", | ||
"sphinx.ext.linkcode", | ||
"sphinx.ext.autosummary", | ||
"sphinx.ext.autosectionlabel", | ||
"sphinx.ext.intersphinx", | ||
] | ||
autosummary_generate = True | ||
autodoc_default_options = { | ||
"members": True, | ||
"member-order": "alphabetical", | ||
"special-members": "__init__", | ||
"undoc-members": True, | ||
"exclude-members": "__weakref__", | ||
"inherited-members": True, | ||
} | ||
intersphinx_mapping = { | ||
"sklearn": ("https://scikit-learn.org/stable/", None), | ||
"numpy": ("https://numpy.org/doc/stable/", None), | ||
"python": ("https://docs.python.org/3", None), | ||
} | ||
|
||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ["_templates"] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = [] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = "sphinx" | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = "default" | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_context = { | ||
"display_github": True, | ||
"github_user": "adriangb", | ||
"github_repo": "scikeras", | ||
"github_version": "master", | ||
"conf_py_path": "/source/", | ||
} | ||
|
||
if not on_rtd: # only import and set the theme if we're building docs locally | ||
import sphinx_rtd_theme | ||
|
||
html_theme = "sphinx_rtd_theme" | ||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] | ||
|
||
# -- GitHub source code link ---------------------------------------------- | ||
|
||
# Functionality to build github source URI, taken from sklearn. | ||
|
||
import inspect | ||
import subprocess | ||
|
||
from functools import partial | ||
from operator import attrgetter | ||
|
||
|
||
REVISION_CMD = "git rev-parse --short HEAD" | ||
|
||
|
||
def _get_git_revision(): | ||
try: | ||
revision = subprocess.check_output(REVISION_CMD.split()).strip() | ||
except (subprocess.CalledProcessError, OSError): | ||
print("Failed to execute git to get revision") | ||
return None | ||
return revision.decode("utf-8") | ||
|
||
|
||
def _linkcode_resolve(domain, info, package, url_fmt, revision): | ||
"""Determine a link to online source for a class/method/function | ||
This is called by sphinx.ext.linkcode | ||
An example with a long-untouched module that everyone has | ||
>>> _linkcode_resolve('py', {'module': 'tty', | ||
... 'fullname': 'setraw'}, | ||
... package='tty', | ||
... url_fmt='http://hg.python.org/cpython/file/' | ||
... '{revision}/Lib/{package}/{path}#L{lineno}', | ||
... revision='xxxx') | ||
'http://hg.python.org/cpython/file/xxxx/Lib/tty/tty.py#L18' | ||
""" | ||
|
||
if revision is None: | ||
return | ||
if domain not in ("py", "pyx"): | ||
return | ||
if not info.get("module") or not info.get("fullname"): | ||
return | ||
|
||
class_name = info["fullname"].split(".")[0] | ||
if type(class_name) != str: | ||
# Python 2 only | ||
class_name = class_name.encode("utf-8") | ||
module = __import__(info["module"], fromlist=[class_name]) | ||
obj = attrgetter(info["fullname"])(module) | ||
|
||
try: | ||
fn = inspect.getsourcefile(obj) | ||
except Exception: | ||
fn = None | ||
if not fn: | ||
try: | ||
fn = inspect.getsourcefile(sys.modules[obj.__module__]) | ||
except Exception: | ||
fn = None | ||
if not fn: | ||
return | ||
|
||
fn = os.path.relpath( | ||
fn, start=os.path.dirname(__import__(package).__file__) | ||
) | ||
try: | ||
lineno = inspect.getsourcelines(obj)[1] | ||
except Exception: | ||
lineno = "" | ||
return url_fmt.format( | ||
revision=revision, package=package, path=fn, lineno=lineno | ||
) | ||
|
||
|
||
def project_linkcode_resolve(domain, info): | ||
global _linkcode_git_revision | ||
return _linkcode_resolve( | ||
domain, | ||
info, | ||
package="scikeras", | ||
revision=_linkcode_git_revision, | ||
url_fmt="https://github.com/adriangb/scikeras/" | ||
"blob/{revision}/" | ||
"{package}/{path}#L{lineno}", | ||
) | ||
|
||
|
||
_linkcode_git_revision = _get_git_revision() | ||
|
||
# The following is used by sphinx.ext.linkcode to provide links to github | ||
linkcode_resolve = project_linkcode_resolve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. SciKeras documentation master file, created by | ||
sphinx-quickstart on Sat Aug 15 16:47:22 2020. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to SciKeras's documentation! | ||
==================================== | ||
|
||
SciKeras provides a Scikit-Learn style API for Keras. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
api | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters