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

Format the client and server pydocs the same #1392

Merged
merged 11 commits into from
Oct 6, 2021
6 changes: 3 additions & 3 deletions Integrations/python/deephaven/DBTimeUtils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def diffDay(start, end):
Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either
date is before Epoch (negative offset), the result may be unexpected.

If the second value is greater than the first value, the result will be negative.
If the first value is greater than the second value, the result will be negative.
"""

return _java_type_.diffDay(start, end)
Expand All @@ -453,7 +453,7 @@ def diffNanos(d1, d2):
Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either
date is before Epoch (negative offset), the result may be unexpected.

If the second value is greater than the first value, the result will be negative.
If the first value is greater than the second value, the result will be negative.
"""

return _java_type_.diffNanos(d1, d2)
Expand All @@ -475,7 +475,7 @@ def diffYear(start, end):
Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either
date is before Epoch (negative offset), the result may be unexpected.

If the second value is greater than the first value, the result will be negative.
If the first value is greater than the second value, the result will be negative.
"""

return _java_type_.diffYear(start, end)
Expand Down
1 change: 1 addition & 0 deletions pyclient/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source/code
130 changes: 123 additions & 7 deletions pyclient/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
# 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('..'))
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# -- Project information -----------------------------------------------------

Expand All @@ -29,16 +28,15 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc',
"sphinx_autodoc_typehints"]
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode', "sphinx_autodoc_typehints"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["proto"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------

Expand All @@ -52,10 +50,128 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom CSS files
html_css_files = ['custom.css']

# Theme options
# see https://alabaster.readthedocs.io/en/latest/customization.html
# see https://github.com/bitprophet/alabaster/blob/master/alabaster/theme.conf
html_theme_options = {
#'logo' : 'deephaven.png',
#'logo_name' : 'Deephaven',
'page_width': '80%',
'sidebar_width': '35%',
}

# A boolean that decides whether module names are prepended to all object names (for object types where a “module” of some kind is defined), e.g. for py:function directives. Default is True.
add_module_names = False

#########################################################################################################################################################################

import pydeephaven
package_roots = [pydeephaven]
package_excludes = ['._', 'proto']
docs_title = "Deephaven Python Client API modules."

#########################################################################################################################################################################


import os
import shutil
import pkgutil

def glob_package_names(packages):
rst = []

for package in packages:
rst.append(package.__name__)

if hasattr(package,"__path__"):
for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__+'.', onerror=lambda x: None):
rst.append(modname)

return rst


def _add_package(tree, package):
n = package[0]

if n not in tree:
tree[n] = {}

if len(package) > 1:
_add_package(tree[n],package[1:])


def package_tree(package_names):
rst = {}
for pn in package_names:
spn = pn.split('.')
_add_package(rst, spn)
return rst


def make_rst_tree(package, tree):
package_name = ".".join(package)

if len(tree) == 0:
toctree = ""
else:
toctree = ".. toctree::\n"
for k in tree:
p = package.copy()
p.append(k)
pn = ".".join(p)
toctree += "%s%s <%s>\n"%(" "*4,k,pn)

rst = "%s\n%s\n\n%s\n.. automodule:: %s\n :members:\n :show-inheritance:\n :special-members: __init__\n :undoc-members:\n\n"%(package_name,"="*len(package_name),toctree,package_name)

if len(package) > 0:
filename = f"code/{package_name}.rst"

with open(filename,"w") as file:
file.write(rst)

for k,v in tree.items():
p = package.copy()
p.append(k)
make_rst_tree(p, v)


_rst_modules = f'''
Python Modules
##############

{docs_title}

.. toctree::
:glob:

'''

def make_rst_modules(package_roots):
rst = _rst_modules

for pr in package_roots:
rst += "\n%s./code/%s"%(" "*4,pr.__name__)

filename = "modules.rst"

with open(filename,"w") as file:
file.write(rst)



pn = glob_package_names(package_roots)
pn = [p for p in pn if not any(exclude in p for exclude in package_excludes)]
pt = package_tree(pn)

if os.path.exists("code"):
shutil.rmtree("code")
os.mkdir("code")

make_rst_modules(package_roots)
make_rst_tree([],pt)



2 changes: 2 additions & 0 deletions pyclient/docs/source/genindex.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Index
#####
28 changes: 9 additions & 19 deletions pyclient/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
.. Deephaven Python Client API documentation master file, created by
sphinx-quickstart on Thu Aug 19 12:27:56 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

.. toctree::
:name: mastertoc
:hidden:

modules.rst
py-modindex.rst
genindex.rst


Deephaven Python Client API Documentation
===========================================================================

Deephaven Python Client (pydeephaven) is a Python API built on top of Deephaven’s highly efficient OpenAPI which is based on gRPC and Apache Arrow. It allows Python applications to remotely connect to Deephaven data servers, export/import data with the server, run Python scripts on the server, and execute powerful queries on data tables.

Because Deephaven data servers and Deephaven clients including pydeephaven exchange data in the Apache Arrow format, pydeephaven is able to leverage ‘pyarrow’ - the Python bindings of Arrow (ttps://arrow.apache.org/docs/python/) for data representation and integration with other data analytic tools such as NumPy, Pandas, etc.
Because Deephaven data servers and Deephaven clients including pydeephaven exchange data in the Apache Arrow format, pydeephaven is able to leverage ‘pyarrow’ - the Python bindings of Arrow (https://arrow.apache.org/docs/python/) for data representation and integration with other data analytic tools such as NumPy, Pandas, etc.

Examples:
>>> from pydeephaven import Session
Expand All @@ -21,17 +25,3 @@ Examples:
>>> df = joined_table.snapshot().to_pandas()
>>> print(df)
>>> session.close()

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

modules


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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
11 changes: 9 additions & 2 deletions pyclient/docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Python Modules
##############

Deephaven python modules.

.. toctree::
:maxdepth: 4
:glob:


pydeephaven
./code/pydeephaven
3 changes: 3 additions & 0 deletions pyclient/docs/source/py-modindex.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Module Index
############

55 changes: 0 additions & 55 deletions pyclient/docs/source/pydeephaven.rst

This file was deleted.

27 changes: 18 additions & 9 deletions sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
project = 'Deephaven'
copyright = '2021, Deephaven Data Labs'
author = 'Deephaven Data Labs'

# The full version, including alpha/beta/rc tags
#release = '0.0.1'

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode', "sphinx_autodoc_typehints"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -64,6 +68,15 @@

#########################################################################################################################################################################

import deephaven
import jpy
package_roots = [jpy, deephaven]
package_excludes = ['._']
docs_title = "Deephaven python modules."

#########################################################################################################################################################################


import os
import shutil
import pkgutil
Expand Down Expand Up @@ -112,7 +125,7 @@ def make_rst_tree(package, tree):
pn = ".".join(p)
toctree += "%s%s <%s>\n"%(" "*4,k,pn)

rst = "%s\n%s\n\n%s\n.. automodule:: %s\n :members:\n :undoc-members:\n\n"%(package_name,"="*len(package_name),toctree,package_name)
rst = "%s\n%s\n\n%s\n.. automodule:: %s\n :members:\n :show-inheritance:\n :special-members: __init__\n :undoc-members:\n\n"%(package_name,"="*len(package_name),toctree,package_name)

if len(package) > 0:
filename = f"code/{package_name}.rst"
Expand All @@ -126,11 +139,11 @@ def make_rst_tree(package, tree):
make_rst_tree(p, v)


_rst_modules = '''
_rst_modules = f'''
Python Modules
##############

Deephaven python modules.
{docs_title}

.. toctree::
:glob:
Expand All @@ -150,12 +163,8 @@ def make_rst_modules(package_roots):



import deephaven
import jpy
package_roots = [jpy, deephaven]
pn = glob_package_names(package_roots)
# remove private modules
pn = [p for p in pn if not '._' in p]
pn = [p for p in pn if not any(exclude in p for exclude in package_excludes)]
pt = package_tree(pn)

if os.path.exists("code"):
Expand Down
Loading