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

adding autodocumentation for python and C++ #414

Merged
merged 5 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,11 @@ website/static/css/material.dark.css
obj
packages/*/cjs
cppbuild
.coverage
docsbuild
.coverage

# docs generated
docs/_build
docs/modules.rst
docs/perspective.*.rst
docs/python
32 changes: 30 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ option(PSP_CPP_BUILD "Build the C++ Project" OFF)
option(PSP_CPP_BUILD_TESTS "Build the C++ Tests" OFF)
option(PSP_PYTHON_BUILD "Build the Python Bindings" OFF)
option(PSP_CPP_BUILD_STRICT "Build the C++ with strict warnings" OFF)
option(PSP_BUILD_DOCS "Build the Perspective documentation" OFF)


if (NOT DEFINED PSP_WASM_BUILD)
Expand Down Expand Up @@ -128,6 +129,12 @@ if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug)
else()
message(WARNING "${Cyan}Building RELEASE${ColorReset}")
endif()

if(PSP_BUILD_DOCS)
message(WARNING "${Cyan}Building Perspective Documentation${ColorReset}")
else()
message(WARNING "${Cyan}Skipping Perspective Documentation${ColorReset}")
endif()
#######################
include_directories("${CMAKE_SOURCE_DIR}/src/include")

Expand Down Expand Up @@ -179,7 +186,7 @@ if (PSP_WASM_BUILD)
set(SYNC_MODE_FLAGS "-s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0 -s BINARYEN_METHOD='\"native-wasm\"' -s WASM=1")
set(ASYNC_MODE_FLAGS "-s ENVIRONMENT=worker -s BINARYEN_ASYNC_COMPILATION=1 -s BINARYEN_METHOD='\"native-wasm\"' -s WASM=1")
set(ASMJS_MODE_FLAGS "-s ENVIRONMENT=worker -s LEGACY_VM_SUPPORT=1 -s BINARYEN_ASYNC_COMPILATION=0 -s BINARYEN_METHOD='\"asmjs\"' -Wno-almost-asm -s WASM=0")
else()
elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
#####################
# VANILLA CPP BUILD #
#####################
Expand Down Expand Up @@ -363,7 +370,7 @@ if (PSP_WASM_BUILD)
set_target_properties(perspective.asm PROPERTIES OUTPUT_NAME "psp.asmjs")
add_dependencies(perspective.asm perspective.sync)
endif()
else()
elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_SHARED_LIBRARY_SUFFIX .dylib)
endif()
Expand Down Expand Up @@ -429,3 +436,24 @@ if (PSP_CPP_BUILD_TESTS)
)
endif()
#############

########
# Docs #
########
if(PSP_BUILD_DOCS)
add_custom_target(doxygen)
add_custom_command(TARGET doxygen
COMMAND doxygen doxygen.conf
WORKING_DIRECTORY ../docs
COMMENT "Build doxygen xml files used by sphinx/breathe."
)

add_custom_target(docs-html ALL)
add_custom_command(TARGET docs-html
COMMAND sphinx-build -b html . _build/html
WORKING_DIRECTORY ../docs
COMMENT "Build html documentation"
)
add_dependencies(docs-html doxygen)
endif()
##########
36 changes: 36 additions & 0 deletions docker/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# *****************************************************************************
#
# Copyright (c) 2019, the Perspective Authors.
#
# This file is part of the Perspective library, distributed under the terms of
# the Apache License 2.0. The full license can be found in the LICENSE file.
#

FROM python:3.7
# use the python one as its needs to be compiled for the docs to generate right

RUN apt-get update
RUN apt-get -y install apt-transport-https libtbb-dev cmake doxygen
RUN apt-get -y remove python3

RUN python3.7 -m pip install numpy pandas

RUN ls -al /usr/local/lib/python3.7/site-packages/numpy

RUN wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz >/dev/null 2>&1 || echo "wget failed"
RUN tar xfz boost_1_67_0.tar.gz
RUN cd boost_1_67_0 && CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.7m" C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/local/include/python3.7m" ./bootstrap.sh --with-python=/usr/local/bin/python3.7 || echo "boostrap failed"
RUN cd boost_1_67_0 && CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.7m" C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/local/include/python3.7m" ./b2 -j4 install || echo "build boost failed"

RUN ln -s /usr/local/lib/libboost_python37.so /usr/local/lib/libboost_python.so
RUN ln -s /usr/local/lib/libboost_numpy37.so /usr/local/lib/libboost_numpy.so
RUN python3 -m pip install 'numpy>=1.13.1' 'pandas>=0.22.0'

# docs dependencies
RUN python3 -m pip install breathe sphinx sphinx_rtd_theme
RUN npm install @babel/cli @babel/core @babel/plugin-proposal-decorators @babel/plugin-transform-for-of @babel/preset-env babel-plugin-transform-custom-element-classes jsdoc jsdoc-babel --save-dev
RUN yarn

# install from here from now, waiting on https://github.com/mozilla/sphinx-js/issues/94
RUN python3 -m pip install git+https://github.com/timkpaine/sphinx-js

5 changes: 1 addition & 4 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

FROM python:3.7

WORKDIR /usr/src/app
ADD . /usr/src/app

RUN apt-get update
RUN apt-get -y install apt-transport-https libtbb-dev cmake
RUN apt-get -y install apt-transport-https libtbb-dev cmake nodejs npm
RUN apt-get -y remove python3

RUN python3.7 -m pip install numpy pandas
Expand Down
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
223 changes: 223 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# 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
import sys
import os
import os.path
import subprocess
import sphinx_rtd_theme
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'python')))


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

project = 'perspective'
copyright = '2019, Perspective Authors'
author = 'Perspective Authors'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.2.14'


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

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# 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', # autodocument python
'breathe', # integrate with doxygen
'sphinx.ext.napoleon', # google style docstrings
'sphinx_js', # jsdoc
]

breathe_projects = {"perspective": os.path.abspath(os.path.join(os.path.dirname(__file__), '_build', 'xml'))}
breathe_default_project = "perspective"

js_source_path = [
# '../packages/perspective/src/js',
# '../packages/perspective/src/js/DataAccessor',
'../packages/perspective-viewer/src/js',
'../packages/perspective-viewer/src/js/computed_column',
'../packages/perspective-viewer/src/js/viewer',
# '../packages/perspective-viewer-highcharts/src/js',
# '../packages/perspective-viewer-hypergrid/src/js',
# '../packages/perspective-webpack-plugin/src/js',
]
root_for_relative_js_paths = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
jsdoc_config_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'jsdoc.conf'))

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# 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 = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


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

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]


# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'perspectivedoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'perspective.tex', 'perspective Documentation',
'Perspective Authors', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'perspective', 'perspective Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'perspective', 'perspective Documentation',
author, 'perspective', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------

def run_apidoc(_):
o_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'python'))
psp_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'python', 'perspective'))
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix, 'bin', 'sphinx-apidoc'))
subprocess.check_call([cmd_path,
'-E',
'-M',
'-o',
o_dir,
psp_dir,
'--force'])


def setup(app):
app.connect('builder-inited', run_apidoc)
10 changes: 10 additions & 0 deletions docs/cpp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
C++
===========
C++ Documentation

.. doxygennamespace:: perspective
:project: perspective
:members:
:protected-members:
:private-members:
:undoc-members:
Loading