Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx docs #54

Merged
merged 4 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*.egg-info
*.DS_Store
__pycache__
_build
.ipynb_checkpoints
*_checkpoints
*.DS_Store
*.egg-info
build/
dist/
docs/_build/
69 changes: 69 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# CONTRIBUTING

This repository is under active development by a small number of contributors at the moment. Once the code and API has settled a bit we will open up and welcome contributions. But not yet.

## Setup for local development

1. Create a new environment using Python >=3.8, for example 3.10

```
conda create --name CausalPy python=3.10
```

2. Activate environment:

```
conda activate CausalPy
```

3. Install the package in editable mode

```
pip install -e .
```

4. Install development dependencies

```
pip install -r requirements-dev.txt
pip install -r requirements-docs.txt
```

5. You may also need to run this to get pre-commit checks working

```
pre-commit install
```

6. Note: You may have to run the following command to make Jupyter Lab aware of the `CausalPy` environment.

```
python -m ipykernel install --user --name CausalPy
```

## Building the documentation locally

Ensure the right packages (in `requirements-docs.txt`) are available in the environment. See the steps above.

A local build of the docs is achieved by:

```bash
cd docs
make html
```

Sometimes not all changes are recognised. In that case run:

```bash
make clean && make html
```

Docs are built in `docs/_build`, but these docs are _not_ committed to the GitHub repository due to `.gitignore`.

## New releases [work in progress]

1. Bump the release version in `causalpy/version.py`. This is automatically read by `setup.py` and `docs/config.py`.
2. Update on pypi.org. In the root directory:
- `python setup.py sdist`
- update to pypi.org with `twine upload dist/*`
3. _??? Do I have to do anything to update the docs on [`readthedocs`](https://readthedocs.org)???_
56 changes: 10 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ Another distinctive feature of this package is the ability to use different mode

## Installation

[coming soon]
To get the latest release:
```bash
pip install CausalPy
```

Alternatively, if you want the very latest version of the package you can install from GitHub:

```bash
pip install git+https://github.com/pymc-labs/CausalPy.git
```

## Roadmap

Expand Down Expand Up @@ -113,57 +122,12 @@ Here are some general resources about causal inference:
* Huntington-Klein, N. (2021). [The effect: An introduction to research design and causality](https://theeffectbook.net). Chapman and Hall/CRC.
* Reichardt, C. S. (2019). Quasi-experimentation: A guide to design and analysis. Guilford Publications.

## Contributions

This repository is under active development by a small number of contributors at the moment. Once the code and API has settled a bit we will open up and welcome contributions. But not yet.

## License

[Apache License 2.0](LICENSE)

---

## Local development

1. Create a new environment using Python >=3.8, for example 3.10

```
conda create --name CausalPy python=3.10
```

2. Activate environment:

```
conda activate CausalPy
```

3. Install the package in editable mode

```
pip install -e .
```

4. Install development dependencies

```
pip install -r requirements-dev.txt
pip install -r requirements-docs.txt
```

5. You may also need to run this to get pre-commit checks working

```
pre-commit install
```

6. Note: You may have to run the following command to make Jupyter Lab aware of the `CausalPy` environment.

```
python -m ipykernel install --user --name CausalPy
```

---

## Support

<img src="img/pymc-labs-log.png" align="right" width="50%" />
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
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 = .
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)
9 changes: 9 additions & 0 deletions docs/api_plot_utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.plot_utils`
==========================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.plot_utils
:members:
:undoc-members:
9 changes: 9 additions & 0 deletions docs/api_pymc_experiments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.pymc_experiments`
================================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.pymc_experiments
:members:
:undoc-members:
9 changes: 9 additions & 0 deletions docs/api_pymc_models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.pymc_models`
===========================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.pymc_models
:members:
:undoc-members:
9 changes: 9 additions & 0 deletions docs/api_skl_experiments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.skl_experiments`
===============================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.skl_experiments
:members:
:undoc-members:
9 changes: 9 additions & 0 deletions docs/api_skl_models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`causalpy.skl_models`
==========================

.. toctree::
:maxdepth: 1

.. automodule:: causalpy.skl_models
:members:
:undoc-members:
76 changes: 76 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, 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("../mypackage"))


# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "CausalPy"
copyright = "2022, Benjamin T. Vincent"
author = "Benjamin T. Vincent"

from causalpy.version import __version__

release = __version__
print(f"{release=}")


# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.mathjax",
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"nbsphinx",
"myst_parser",
]

source_suffix = [".rst", ".md"]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# MyST options for working with markdown files. Info about extensions here https://myst-parser.readthedocs.io/en/latest/syntax/optional.html?highlight=math#admonition-directives
myst_enable_extensions = ["dollarmath", "amsmath", "colon_fence", "linkify"]

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
# TODO: version seems not to be displayed despite setting this to True
html_theme_options = {
"display_version": True,
}

# -- Options for autodoc ----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#configuration

# Automatically extract typehints when specified and place them in
# descriptions of the relevant function/method.
autodoc_typehints = "description"

# Don't show class signature with the class' name.
autodoc_class_signature = "separated"

# Add "Edit on Github" link. Replaces "view page source" ----------------------
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "pymc-labs", # Username
"github_repo": "CausalPy", # Repo name
"github_version": "master", # Version
"conf_py_path": "/docs/", # Path in the checkout to the docs root
}
41 changes: 41 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. CausalPy documentation master file, created by
sphinx-quickstart on Mon Nov 14 18:28:13 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

CausalPy - Causal inference in quasi-experimental settings
==========================================================

A Python package focussing on causal inference in quasi-experimental settings. The package allows for sophisticated Bayesian model fitting methods to be used in addition to traditional OLS.

.. toctree::
:maxdepth: 2
:caption: Contents:

Documentation outline
=====================

.. toctree::
:caption: Examples
:titlesonly:

notebooks/skl_demos.ipynb
notebooks/pymc_demos.ipynb

.. toctree::
:caption: API Reference
:titlesonly:

api_skl_experiments
api_skl_models
api_pymc_experiments
api_pymc_models
api_plot_utils


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
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=.
set BUILDDIR=_build

%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.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading