Skip to content

Commit a11bb44

Browse files
Add Sphinx documentation. (spotify#1)
* Add Sphinx documentation. * Fix linting errors. * Fix coverage test. * Remove template and static directories from conf.py.
1 parent ebaa1f4 commit a11bb44

20 files changed

+787
-90
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/__pycache__
22
**/.git
33
**/playground
4+
**/build

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ python:
33
- "3.6"
44
cache: pip
55
install:
6-
- pip install -r test-requirements.txt
6+
- pip install -r requirements/test.txt -r requirements/docs.txt
77
- pip install -e .
88
script:
9-
- pylint pythonflow
10-
- py.test --cov pythonflow --cov-fail-under=100 --cov-report=term-missing
9+
- make tests
10+
- make docs

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM python:3
22
MAINTAINER Till Hoffmann <till@spotify.com>
33

44
# Install requirements
5-
COPY test-requirements.txt test-requirements.txt
6-
RUN pip install -r test-requirements.txt
5+
COPY requirements requirements
6+
RUN pip install -r requirements/docs.txt -r requirements/test.txt
77

88
# Install the package
99
COPY . pythonflow

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include version.json

Makefile

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
.PHONY: docker_image tests nbserver bash
1+
.PHONY: docker_image docker_nbserver tests lint_tests code_tests docs
22

3-
docker_image : test-requirements.txt
3+
docker_image : requirements/*.txt
44
docker build -t pythonflow .
55

6-
tests : docker_image
7-
docker run --rm pythonflow pylint pythonflow
8-
docker run --rm pythonflow py.test --cov --cov-fail-under=100 --cov-report=term-missing
9-
10-
README.md : docker_image README.ipynb
11-
docker run --rm -v "$$PWD":/pythonflow pythonflow jupyter nbconvert README.ipynb --execute --to markdown
12-
13-
nbserver : docker_image
6+
docker_nbserver : docker_image
147
docker run --rm -v "$$PWD":/pythonflow -p 9000:8888 pythonflow jupyter notebook --allow-root --ip=0.0.0.0 --no-browser
158

16-
bash :
9+
docker_bash : docker_image
1710
docker run --rm -v "$$PWD":/pythonflow -it pythonflow bash
11+
12+
tests : lint_tests code_tests
13+
14+
lint_tests :
15+
pylint pythonflow
16+
17+
code_tests :
18+
py.test --cov pythonflow --cov-fail-under=100 --cov-report=term-missing
19+
20+
docs :
21+
sphinx-build -b doctest docs build
22+
sphinx-build -nWT docs build

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Pythonflow: Dataflow programming for python.
2+
3+
Pythonflow is a simple implementation of [dataflow programming](https://en.wikipedia.org/wiki/Dataflow_programming>) for python. Users of [Tensorflow](https://www.tensorflow.org/) will immediately be familiar with the syntax.
4+
5+
At Spotify, we use Pythonflow in data preprocessing pipelines for machine learning models because
6+
7+
* it automatically caches computationally expensive operations,
8+
* any part of the computational graph can be easily evaluated for debugging purposes,
9+
* it allows us to distribute data preprocessing across multiple machines.

docs/conf.py

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2017 Spotify AB
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# pythonflow documentation build configuration file, created by
19+
# sphinx-quickstart on Wed Sep 6 16:03:02 2017.
20+
#
21+
# This file is execfile()d with the current directory set to its
22+
# containing dir.
23+
#
24+
# Note that not all possible configuration values are present in this
25+
# autogenerated file.
26+
#
27+
# All configuration values have a default; values that are commented out
28+
# serve to show the default.
29+
30+
# If extensions (or modules to document with autodoc) are in another directory,
31+
# add these directories to sys.path here. If the directory is relative to the
32+
# documentation root, use os.path.abspath to make it absolute, like shown here.
33+
#
34+
import json
35+
import os
36+
import sys
37+
sys.path.insert(0, os.path.abspath('..'))
38+
39+
with open('../version.json') as fp:
40+
kwargs = json.load(fp)
41+
42+
43+
# -- General configuration ------------------------------------------------
44+
45+
# If your documentation needs a minimal Sphinx version, state it here.
46+
#
47+
# needs_sphinx = '1.0'
48+
49+
# Add any Sphinx extension module names here, as strings. They can be
50+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
51+
# ones.
52+
extensions = [
53+
'sphinx.ext.autodoc',
54+
'sphinx.ext.doctest',
55+
'sphinx.ext.coverage',
56+
'sphinx.ext.viewcode',
57+
'sphinx.ext.githubpages',
58+
'sphinx.ext.autosummary',
59+
'numpydoc'
60+
]
61+
62+
# Add any paths that contain templates here, relative to this directory.
63+
templates_path = []
64+
65+
# The suffix(es) of source filenames.
66+
# You can specify multiple suffix as a list of string:
67+
#
68+
# source_suffix = ['.rst', '.md']
69+
source_suffix = '.rst'
70+
71+
# The master toctree document.
72+
master_doc = 'index'
73+
74+
# General information about the project.
75+
project = kwargs['name']
76+
author = kwargs['author']
77+
copyright = '2017 Spotify AB'
78+
79+
# The version info for the project you're documenting, acts as replacement for
80+
# |version| and |release|, also used in various other places throughout the
81+
# built documents.
82+
#
83+
# The short X.Y version.
84+
version = kwargs['version']
85+
# The full version, including alpha/beta/rc tags.
86+
release = kwargs['version']
87+
88+
# The language for content autogenerated by Sphinx. Refer to documentation
89+
# for a list of supported languages.
90+
#
91+
# This is also used if you do content translation via gettext catalogs.
92+
# Usually you set "language" from the command line for these cases.
93+
language = None
94+
95+
# List of patterns, relative to source directory, that match files and
96+
# directories to ignore when looking for source files.
97+
# This patterns also effect to html_static_path and html_extra_path
98+
exclude_patterns = []
99+
100+
# The name of the Pygments (syntax highlighting) style to use.
101+
pygments_style = 'sphinx'
102+
103+
# If true, `todo` and `todoList` produce output, else they produce nothing.
104+
todo_include_todos = False
105+
106+
107+
# -- Options for HTML output ----------------------------------------------
108+
109+
# The theme to use for HTML and HTML Help pages. See the documentation for
110+
# a list of builtin themes.
111+
#
112+
html_theme = 'sphinx_rtd_theme'
113+
114+
# Theme options are theme-specific and customize the look and feel of a theme
115+
# further. For a list of options available for each theme, see the
116+
# documentation.
117+
#
118+
# html_theme_options = {}
119+
120+
# Add any paths that contain custom static files (such as style sheets) here,
121+
# relative to this directory. They are copied after the builtin static files,
122+
# so a file named "default.css" will overwrite the builtin "default.css".
123+
html_static_path = []
124+
125+
# Custom sidebar templates, must be a dictionary that maps document names
126+
# to template names.
127+
#
128+
# This is required for the alabaster theme
129+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
130+
html_sidebars = {
131+
'**': [
132+
'about.html',
133+
'navigation.html',
134+
'relations.html', # needs 'show_related': True theme option to display
135+
'searchbox.html',
136+
'donate.html',
137+
]
138+
}
139+
140+
141+
# -- Options for HTMLHelp output ------------------------------------------
142+
143+
# Output file base name for HTML help builder.
144+
htmlhelp_basename = 'pythonflowdoc'
145+
146+
147+
# -- Options for LaTeX output ---------------------------------------------
148+
149+
latex_elements = {
150+
# The paper size ('letterpaper' or 'a4paper').
151+
#
152+
# 'papersize': 'letterpaper',
153+
154+
# The font size ('10pt', '11pt' or '12pt').
155+
#
156+
# 'pointsize': '10pt',
157+
158+
# Additional stuff for the LaTeX preamble.
159+
#
160+
# 'preamble': '',
161+
162+
# Latex figure (float) alignment
163+
#
164+
# 'figure_align': 'htbp',
165+
}
166+
167+
# Grouping the document tree into LaTeX files. List of tuples
168+
# (source start file, target name, title,
169+
# author, documentclass [howto, manual, or own class]).
170+
latex_documents = [
171+
(master_doc, 'pythonflow.tex', 'pythonflow Documentation',
172+
'Till Hoffmann', 'manual'),
173+
]
174+
175+
176+
# -- Options for manual page output ---------------------------------------
177+
178+
# One entry per manual page. List of tuples
179+
# (source start file, name, description, authors, manual section).
180+
man_pages = [
181+
(master_doc, 'pythonflow', 'pythonflow Documentation',
182+
[author], 1)
183+
]
184+
185+
186+
# -- Options for Texinfo output -------------------------------------------
187+
188+
# Grouping the document tree into Texinfo files. List of tuples
189+
# (source start file, target name, title, author,
190+
# dir menu entry, description, category)
191+
texinfo_documents = [
192+
(master_doc, 'pythonflow', 'pythonflow Documentation',
193+
author, 'pythonflow', 'One line description of project.',
194+
'Miscellaneous'),
195+
]
196+
197+
# Disable class members (https://github.com/phn/pytpm/issues/3#issuecomment-12133978)
198+
numpydoc_show_class_members = False
199+
200+
# Ignore some warnings (https://stackoverflow.com/a/30624034/1150961)
201+
nitpick_ignore = [('py:class', 'object')]

0 commit comments

Comments
 (0)