Skip to content

Commit f98664b

Browse files
committed
Initial commit of doc files.
1 parent dc358fc commit f98664b

8 files changed

Lines changed: 231 additions & 1 deletion

File tree

‎README.rst‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,70 @@ To run a specific test:
9090
(project_env) pytest tests/test_fftconvolve.py::test_fft
9191
9292
93+
Documentation
94+
=============
95+
96+
Will be using `Sphinx <https://www.sphinx-doc.org/en/master/>`__ to generate documentation.
97+
98+
#. Write docstrings when coding. Great if already started!
99+
100+
First time only steps
101+
#. (Recommended) create a lightweight virtual environment for building the documentation. Can save a lot of time when building docs remotely, as we'll show with ReadTheDocs
102+
103+
.. code:: bash
104+
105+
# create new environment, press enter to accept
106+
conda create -n docs_env python=3.9
107+
108+
# activate environment
109+
conda activate docs_env
110+
111+
# install requirements
112+
(docs_env) pip install -e .
113+
(docs_env) cd docs
114+
(docs_env) pip install -r requirements.txt
115+
116+
#. Use ``sphinx-quickstart`` (first-time only!). Do separate source and build. Enter project details through terminal.
117+
118+
Otherwise
119+
120+
#. Fill in index and create other files. Edit conf, like adding mock docs.
121+
#. Build docs with e.g. ``make html``.
122+
#. open ``docs/build/html/index.html`` in browser.
123+
#. host on `ReadTheDocs <https://readthedocs.org/>`__ or GitHub pages.
124+
125+
126+
Some documentation tips
127+
-----------------------
128+
129+
- take a look at our conf.py which we've modified from the generated one
130+
- ex: changing theme to RTD
131+
- intersphinx mapping to connect to other docs
132+
- mock imports
133+
134+
.. code:: bash
135+
136+
# create new environment, press enter to accept
137+
conda create -n docs_env python=3.9
138+
139+
# activate environment
140+
conda activate docs_env
141+
142+
# install requirements
143+
(docs_env) pip install -r docs/requirements.txt
144+
145+
#. Will be using `Sphinx <https://www.sphinx-doc.org/en/master/>`__ to generate documentation. This requires
146+
147+
.. code:: bash
148+
149+
# build docs
150+
(docs_env) python setup.py build_sphinx
151+
152+
153+
154+
#. Use `Sphinx <https://www.sphinx-doc.org/en/master/>`__ to generate documentation.
155+
156+
93157
Releasing new version and deploying to PyPi
94158
===========================================
95159

‎docs/Makefile‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 = source
9+
BUILDDIR = build
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+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

‎docs/make.bat‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

‎docs/requirements.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx==4.0.1
2+
sphinx_rtd_theme==0.4.3
3+
docutils==0.16 # >0.17 doesn't render bullets

‎docs/source/conf.py‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
import datetime
18+
import sys
19+
from unittest import mock
20+
import os
21+
22+
sys.path.insert(0, os.path.abspath(os.path.join("..", "..")))
23+
24+
MOCK_MODULES = ["matplotlib", "matplotlib.pyplot", "numpy", ""]
25+
for mod_name in MOCK_MODULES:
26+
sys.modules[mod_name] = mock.Mock()
27+
28+
29+
# -- Project information -----------------------------------------------------
30+
31+
project = "pydevtips"
32+
copyright = f"{datetime.date.today().year}, Eric Bezzam"
33+
author = "Eric Bezzam"
34+
35+
36+
# -- General configuration ---------------------------------------------------
37+
38+
# Add any Sphinx extension module names here, as strings. They can be
39+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
40+
# ones.
41+
extensions = [
42+
"sphinx_rtd_theme",
43+
"sphinx.ext.intersphinx",
44+
"sphinx.ext.autosummary",
45+
"sphinx.ext.autodoc",
46+
]
47+
48+
intersphinx_mapping = {
49+
"python": ("https://docs.python.org/3/", None),
50+
"NumPy [latest]": ("https://docs.scipy.org/doc/numpy/", None),
51+
"matplotlib": ("http://matplotlib.sourceforge.net/", None),
52+
}
53+
intersphinx_disabled_domains = ["std"]
54+
55+
# Add any paths that contain templates here, relative to this directory.
56+
templates_path = ["_templates"]
57+
58+
# List of patterns, relative to source directory, that match files and
59+
# directories to ignore when looking for source files.
60+
# This pattern also affects html_static_path and html_extra_path.
61+
exclude_patterns = []
62+
63+
64+
# -- Options for HTML output -------------------------------------------------
65+
66+
# The theme to use for HTML and HTML Help pages. See the documentation for
67+
# a list of builtin themes.
68+
#
69+
html_theme = "sphinx_rtd_theme"
70+
71+
# Add any paths that contain custom static files (such as style sheets) here,
72+
# relative to this directory. They are copied after the builtin static files,
73+
# so a file named "default.css" will overwrite the builtin "default.css".
74+
html_static_path = ["_static"]

‎docs/source/fftconvolve.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FFT Convolve
2+
============
3+
4+
.. automodule:: pydevtips.fftconvolve
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

‎docs/source/index.rst‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. pydevtips documentation master file, created by
2+
sphinx-quickstart on Fri Jan 13 17:55:12 2023.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
:caption: Contents:
9+
10+
.. include:: ../../README.rst
11+
12+
13+
Contents
14+
--------
15+
16+
.. toctree::
17+
:caption: Code
18+
19+
fftconvolve
20+
21+
22+
Indices and tables
23+
==================
24+
25+
* :ref:`genindex`
26+
* :ref:`modindex`
27+
* :ref:`search`

‎pydevtips/fftconvolve.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from abc import abstractmethod
33

44

5-
class FFTConvolveBase(object):
5+
class FFTConvolveBase:
66
"""Base class for FFT convolve."""
77

88
def __init__(self, filter, length) -> None:

0 commit comments

Comments
 (0)