Skip to content

Commit c4fae6f

Browse files
Modify files for sphinx auto docs (#91)
* Modify files for sphinx auto docs * Fix Python class names and kwargs * Update upload_annotations docstrings in project.py * Fix project.upload_annotations docstring * Add missing files and udpate .gitignore * Move Sphinx documentation files to 'docs' directory * Add Sphinx requirements * Add docs/README.md * Add Sphinx theme to requirements * Fix docs/source/conf.py * Add google-api-core (for retry) to requirements.txt * Update README.md Co-authored-by: Florijan Stamenkovic <florijan.stamenkovic@gmail.com>
1 parent 85e6097 commit c4fae6f

27 files changed

+626
-114
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@ dmypy.json
131131

132132
# macos files
133133
.DS_STORE
134+
135+
# Sphinx Docs build
136+
docs/build/
137+
# and source files
138+
docs/source/_static
139+
docs/source/_templates

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/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Labelbox Python SDK API Documentation
2+
3+
The Labelbox Python API documentation is generated from source code comments
4+
using Sphinx (https://www.sphinx-doc.org/).
5+
6+
## Preparing the Sphinx environment
7+
8+
To generate the documentation install Sphinx and Sphinxcontrib-Napoleon. The
9+
easiest way to do it is using a Python virtual env and pip:
10+
11+
```
12+
# create a virtual environment
13+
python3 -m venv labelbox_docs_venv
14+
15+
# activate the venv
16+
source ./labelbox_docs_venv/bin/activate
17+
18+
# upgrade venv pip and setuptools
19+
pip install --upgrade pip setuptools
20+
21+
# install Sphinx and necessary contrib from requriements
22+
pip install -r labelbox_root/docs/requirements.txt
23+
24+
# install Labelbox dependencies
25+
pip install -r labelbox_root/requirements.txt
26+
```
27+
28+
There are other ways to do prepare the environment, but we highly recommend
29+
using a Python virtual environment.
30+
31+
## Generating Labelbox SDK API documentation
32+
33+
With the Sphinx environment prepared, enter the docs folder:
34+
35+
```
36+
cd labelbox_root/docs/
37+
```
38+
39+
Run the make build tool, instructing it to build docs as HTML:
40+
```
41+
make html
42+
```

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==3.4.3
2+
sphinxcontrib-napoleon==0.7
3+
sphinx-rtd-theme==0.5.1

docs/source/conf.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'Labelbox Python API reference'
21+
copyright = '2021, Labelbox'
22+
author = 'Alexandra Cota'
23+
24+
release = '2.4'
25+
26+
# -- General configuration ---------------------------------------------------
27+
28+
# Add any Sphinx extension module names here, as strings. They can be
29+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30+
# ones.
31+
extensions = [
32+
'sphinx.ext.autodoc',
33+
'sphinx.ext.viewcode',
34+
'sphinxcontrib.napoleon'
35+
]
36+
37+
# Add any paths that contain templates here, relative to this directory.
38+
templates_path = ['_templates']
39+
40+
# List of patterns, relative to source directory, that match files and
41+
# directories to ignore when looking for source files.
42+
# This pattern also affects html_static_path and html_extra_path.
43+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
44+
45+
46+
# -- Options for HTML output -------------------------------------------------
47+
48+
# The theme to use for HTML and HTML Help pages. See the documentation for
49+
# a list of builtin themes.
50+
#
51+
html_theme = 'sphinx_rtd_theme'
52+
53+
# Add any paths that contain custom static files (such as style sheets) here,
54+
# relative to this directory. They are copied after the builtin static files,
55+
# so a file named "default.css" will overwrite the builtin "default.css".
56+
html_static_path = ['_static']

docs/source/index.rst

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
Labelbox Python API reference
2+
===================================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
Client
9+
----------------------
10+
11+
.. automodule:: labelbox.client
12+
:members:
13+
:special-members: __init__
14+
:exclude-members: upload_data, upload_file
15+
:show-inheritance:
16+
17+
AssetMetadata
18+
--------------------------------------
19+
20+
.. automodule:: labelbox.schema.asset_metadata
21+
:members:
22+
:show-inheritance:
23+
24+
Benchmark
25+
--------------------------------
26+
27+
.. automodule:: labelbox.schema.benchmark
28+
:members:
29+
:show-inheritance:
30+
31+
BulkImportRequest
32+
--------------------------------------------
33+
34+
.. automodule:: labelbox.schema.bulk_import_request
35+
:members:
36+
:exclude-members: create_from_local_file, create_from_objects, create_from_url, from_name
37+
:show-inheritance:
38+
39+
DataRow
40+
--------------------------------
41+
42+
.. automodule:: labelbox.schema.data_row
43+
:members:
44+
:show-inheritance:
45+
46+
Dataset
47+
------------------------------
48+
49+
.. automodule:: labelbox.schema.dataset
50+
:members:
51+
:show-inheritance:
52+
53+
Label
54+
----------------------------
55+
56+
.. automodule:: labelbox.schema.label
57+
:members:
58+
:show-inheritance:
59+
60+
LabelingFrontend
61+
-----------------------------------------
62+
63+
.. automodule:: labelbox.schema.labeling_frontend
64+
:members: LabelingFrontend
65+
:exclude-members: LabelingFrontendOptions
66+
:show-inheritance:
67+
68+
LabelingFrontendOptions
69+
-----------------------------------------
70+
.. automodule:: labelbox.schema.labeling_frontend
71+
:members: LabelingFrontendOptions
72+
:exclude-members: LabelingFrontend
73+
:show-inheritance:
74+
:noindex:
75+
76+
LabelingParameterOverride
77+
-----------------------------------------
78+
.. automodule:: labelbox.schema.project
79+
:members: LabelingParameterOverride
80+
:show-inheritance:
81+
:noindex:
82+
83+
Ontology
84+
-------------------------------
85+
86+
.. automodule:: labelbox.schema.ontology
87+
:members:
88+
:exclude-members: OntologyEntity, Classification, Tool, Option
89+
:show-inheritance:
90+
91+
Organization
92+
-----------------------------------
93+
94+
.. automodule:: labelbox.schema.organization
95+
:members:
96+
:show-inheritance:
97+
98+
Prediction
99+
---------------------------------
100+
101+
.. automodule:: labelbox.schema.prediction
102+
:members: Prediction
103+
:exclude-members: PredictionModel
104+
:show-inheritance:
105+
106+
PredictionModel
107+
---------------------------------
108+
.. automodule:: labelbox.schema.prediction
109+
:members: PredictionModel
110+
:exclude-members: Prediction
111+
:show-inheritance:
112+
:noindex:
113+
114+
Project
115+
------------------------------
116+
117+
.. automodule:: labelbox.schema.project
118+
:members:
119+
:exclude-members: LabelerPerformance, LabelingParameterOverride
120+
:show-inheritance:
121+
122+
Review
123+
-----------------------------
124+
125+
.. automodule:: labelbox.schema.review
126+
:members:
127+
:show-inheritance:
128+
129+
Task
130+
---------------------------
131+
132+
.. automodule:: labelbox.schema.task
133+
:members:
134+
:show-inheritance:
135+
136+
User
137+
---------------------------
138+
139+
.. automodule:: labelbox.schema.user
140+
:members:
141+
:show-inheritance:
142+
143+
Webhook
144+
------------------------------
145+
146+
.. automodule:: labelbox.schema.webhook
147+
:members:
148+
:show-inheritance:
149+
150+
Exceptions
151+
--------------------------
152+
153+
.. automodule:: labelbox.exceptions
154+
:members:
155+
:show-inheritance:
156+
157+
Pagination
158+
--------------------------
159+
160+
.. automodule:: labelbox.pagination
161+
:members:
162+
:special-members: __init__
163+
:show-inheritance:
164+
165+
Enums
166+
----------------------------
167+
168+
.. automodule:: labelbox.schema.enums
169+
:members:
170+
:show-inheritance:
171+

0 commit comments

Comments
 (0)