Skip to content

Commit 5a502d2

Browse files
committed
ARROW-4216: [Python] Add CUDA API docs
Also reorganize the API docs into several documents, and add/improve docstrings. To allow building the docs without CUDA enabled, I added some conditional inclusion logic. When CUDA isn't enabled, the API docs are still generated but the docstrings are empty. This seems to be the only sane setting that doesn't produce Sphinx errors, one way or the other. Author: Antoine Pitrou <antoine@python.org> Closes apache#3372 from pitrou/ARROW-4216-cuda-py-docs and squashes the following commits: 80600da <Antoine Pitrou> ARROW-4216: Add CUDA API docs
1 parent 9d342ec commit 5a502d2

19 files changed

Lines changed: 1167 additions & 464 deletions

‎docs/source/conf.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
'sphinx.ext.autodoc',
5454
'sphinx.ext.autosummary',
5555
'sphinx.ext.doctest',
56+
'sphinx.ext.ifconfig',
5657
'sphinx.ext.mathjax',
5758
'sphinx.ext.viewcode',
5859
'sphinx.ext.napoleon',
@@ -69,6 +70,9 @@
6970
'inherited-members': None
7071
}
7172

73+
# Overriden conditionally below
74+
autodoc_mock_imports = []
75+
7276
# ipython directive options
7377
ipython_mplbackend = ''
7478

@@ -387,3 +391,32 @@
387391
# If true, do not generate a @detailmenu in the "Top" node's menu.
388392
#
389393
# texinfo_no_detailmenu = False
394+
395+
396+
# -- Customization --------------------------------------------------------
397+
398+
# Conditional API doc generation
399+
400+
# Sphinx has two features for conditional inclusion:
401+
# - The "only" directive
402+
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags
403+
# - The "ifconfig" extension
404+
# https://www.sphinx-doc.org/en/master/usage/extensions/ifconfig.html
405+
#
406+
# Both have issues, but "ifconfig" seems to work in this setting.
407+
408+
try:
409+
import pyarrow.cuda
410+
cuda_enabled = True
411+
except ImportError:
412+
cuda_enabled = False
413+
# Mock pyarrow.cuda to avoid autodoc warnings.
414+
# XXX I can't get autodoc_mock_imports to work, so mock manually instead
415+
# (https://github.com/sphinx-doc/sphinx/issues/2174#issuecomment-453177550)
416+
from unittest import mock
417+
pyarrow.cuda = sys.modules['pyarrow.cuda'] = mock.Mock()
418+
419+
def setup(app):
420+
# Use a config value to indicate whether CUDA API docs can be generated.
421+
# This will also rebuild appropriately when the value changes.
422+
app.add_config_value('cuda_enabled', cuda_enabled, 'env')

0 commit comments

Comments
 (0)