From 9698fc83786b5ddb8b167be76a8484cf6ecbe156 Mon Sep 17 00:00:00 2001 From: Dario Seyb Date: Thu, 22 Feb 2018 20:02:34 +0100 Subject: [PATCH] updated CI and added documentation --- .gitlab-ci.yml | 252 +++++++++++++++++++++++++++++-- docs/.gitignore | 2 + docs/Makefile | 20 +++ docs/make.bat | 36 +++++ docs/source/conf.py | 172 +++++++++++++++++++++ docs/source/index.rst | 47 ++++++ meshvis/context.py | 3 + setup.py | 2 +- tests/test_indexed_attributes.py | 14 +- 9 files changed, 531 insertions(+), 17 deletions(-) create mode 100644 docs/.gitignore create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36768c8..a5d3d93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,23 +1,251 @@ -test-3.5: +stages: + - build + - test + - deploy + +build-3.6-VS2017: + stage: + build + tags: + - VS2017 + variables: + BUILD_PLATFORM: "VS2017" + ARCHITECTURE: "x64" + before_script: + - git submodule sync --recursive + - git submodule update --init --recursive + script: + - set Path=%Path%;C:\Program Files\Python36;C:\Program Files\Python36\Scripts; + - virtualenv --clear -p "C:\Program Files\Python36\python.exe" . + - call .\Scripts\activate + - python setup.py bdist_wheel --dist-dir dist3 + artifacts: + paths: + - dist3/ + +build-3.5-linux: + stage: + build tags: - Linux variables: GIT_SUBMODULE_STRATEGY: recursive script: - - virtualenv --clear -p python3.5 . - - source bin/activate - - pip install -e . - - cd tests - - python -m unittest discover + - virtualenv --clear -p python3.5 . + - source bin/activate + - python setup.py bdist_wheel --dist-dir dist3 + artifacts: + paths: + - dist3/ + +build-3.5-macos: + stage: + build + tags: + - Apple + variables: + GIT_SUBMODULE_STRATEGY: recursive + script: + - export PATH=/opt/local/bin:$PATH + - virtualenv --clear -p python3.5 . + - source bin/activate + - python setup.py bdist_wheel --dist-dir dist3 + artifacts: + paths: + - dist3/ -test-2.7: +build-2.7-linux: + stage: + build tags: - Linux variables: GIT_SUBMODULE_STRATEGY: recursive script: - - virtualenv --clear -p python2.7 . - - source bin/activate - - pip install -e . - - cd tests - - python -m unittest discover \ No newline at end of file + - virtualenv --clear -p python2.7 . + - source bin/activate + - python setup.py bdist_wheel --dist-dir dist2 + artifacts: + paths: + - dist2/ + +build-2.7-macos: + stage: + build + tags: + - Apple + variables: + GIT_SUBMODULE_STRATEGY: recursive + script: + - export PATH=/opt/local/bin:$PATH + - virtualenv --clear -p python2.7 . + - source bin/activate + - python setup.py bdist_wheel --dist-dir dist2 + artifacts: + paths: + - dist2/ + +test-3.6-VS2017: + stage: + test + tags: + - VS2017 + dependencies: + - build-3.6-VS2017 + script: + - set Path=%Path%;C:\Program Files\Python36;C:\Program Files\Python36\Scripts; + - virtualenv --clear -p "C:\Program Files\Python36\python.exe" . + - call .\Scripts\activate + - cd dist3 + - FOR %%a IN (*.whl) DO pip install %%a + - cd ..\tests + - python -m unittest discover + +test-3.5-linux: + stage: + test + tags: + - Linux + dependencies: + - build-3.5-linux + script: + - virtualenv --clear -p python3.5 . + - source bin/activate + - pip install dist3/*.whl + - cd tests + - python -m unittest discover + +test-3.5-macos: + stage: + test + tags: + - Apple + dependencies: + - build-3.5-macos + script: + - export PATH=/opt/local/bin:$PATH + - virtualenv --clear -p python3.5 . + - source bin/activate + - pip install dist3/*.whl + - cd tests + - python -m unittest discover + +test-2.7-linux: + stage: + test + tags: + - Linux + dependencies: + - build-2.7-linux + script: + - virtualenv --clear -p python2.7 . + - source bin/activate + - pip install dist2/*.whl + - cd tests + - python -m unittest discover + +test-2.7-macos: + stage: + test + tags: + - Apple + dependencies: + - build-2.7-macos + script: + - export PATH=/opt/local/bin:$PATH + - virtualenv --clear -p python2.7 . + - source bin/activate + - pip install dist2/*.whl + - cd tests + - python -m unittest discover + +deploy-3.6-VS2017: + stage: + deploy + tags: + - VS2017 + dependencies: + - build-3.6-VS2017 + script: + - mkdir release + - cd dist3 + - FOR %%a IN (*.whl) DO cp %%a ..\release + artifacts: + paths: + - release/*.whl + +deploy-3.5-linux: + stage: + deploy + tags: + - Linux + dependencies: + - build-3.5-linux + script: + - mkdir release + - cp dist3/*.whl release + artifacts: + paths: + - release/*.whl + +deploy-3.5-macos: + stage: + deploy + tags: + - Apple + dependencies: + - build-3.5-macos + script: + - mkdir release + - cp dist3/*.whl release + artifacts: + paths: + - release/*.whl + +deploy-2.7-linux: + stage: + deploy + tags: + - Linux + dependencies: + - build-2.7-linux + script: + - mkdir release + - cp dist2/*.whl release + artifacts: + paths: + - release/*.whl + +deploy-2.7-macos: + stage: + deploy + tags: + - Apple + dependencies: + - build-2.7-macos + script: + - mkdir release + - cp dist2/*.whl release + artifacts: + paths: + - release/*.whl + +deploy-documentation: + stage: + deploy + tags: + - Linux + dependencies: + - build-3.5-linux + script: + - virtualenv --clear -p python3.5 . + - source bin/activate + - pip install dist3/*.whl + - pip install sphinx sphinx_rtd_theme + - mkdir documentation + - cd docs + - make html + - cp -r build/html/* ../documentation + artifacts: + paths: + - documentation/ diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..5fed07c --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,2 @@ +/build/ +/source/_autosummary \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..6250264 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = meshvis +SOURCEDIR = source +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) \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..0baf098 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=meshvis + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..611a7a0 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,172 @@ +# -*- 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/stable/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 +sys.path.insert(0, os.path.abspath('../../meshvis/')) + + +# -- Project information ----------------------------------------------------- + +project = u'meshvis' +copyright = u'2018, Dario Seyb, Isaak Lim, Janis Born' +author = u'Dario Seyb, Isaak Lim, Janis Born' + +# The short X.Y version +version = u'' +# The full version, including alpha/beta/rc tags +release = u'' + + +# -- 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', + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.imgmath', + 'sphinx.ext.viewcode', + 'sphinx.ext.autosummary' +] + +autosummary_generate = True + +# 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 = 'sphinx' + + +# -- 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' + +# 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 = 'meshvisdoc' + + +# -- 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, 'meshvis.tex', u'meshvis Documentation', + u'Dario Seyb, Isaak Lim, Janis Born', '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, 'meshvis', u'meshvis 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, 'meshvis', u'meshvis Documentation', + author, 'meshvis', 'Visualize meshes, point clouds, volumes and other geometry in a Jupyter Notebook', + 'Miscellaneous'), +] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for todo extension ---------------------------------------------- + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..d84a820 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,47 @@ +.. meshvis documentation master file, created by + sphinx-quickstart on Thu Feb 22 19:39:24 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to meshvis's documentation! +=================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + +Setup +=================================== + +- Install dependencies +- Clone the repository +- pip install -e . + +Dependencies +=================================== + +- [pythreejs](https://github.com/jovyan/pythreejs/) 1.0.0-beta4 +- [openmesh-python](https://graphics.rwth-aachen.de:9000/adielen/openmesh-python) latest + +Example +=================================== + + +Overview +=================================== + +.. autosummary:: + :toctree: _autosummary + + meshvis.Context + meshvis.immediate + meshvis.mesh + meshvis.openmesh_utils + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/meshvis/context.py b/meshvis/context.py index 294bb64..54facb5 100644 --- a/meshvis/context.py +++ b/meshvis/context.py @@ -9,6 +9,9 @@ from .mesh_helper import calculateFaceNormals, calculatePointNormals from .mesh import * class Context(object): + """ + This is a module docstring + """ def __init__(self, width=600, height=400, background_color = '#dddddd'): self.camera = three.PerspectiveCamera(position=[1,1,1], fov=20, diff --git a/setup.py b/setup.py index 8bfc49e..7ad5a46 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup(name='meshvis', description='Visualize meshes, point clouds, volumes and other geometry in a Jupyter Notebook', long_description=readme(), url='https://graphics.rwth-aachen.de:9000/dseyb/meshvis', - author='Dario Seyb', + author='Dario Seyb, Isaak Lim, Janis Born', author_email='dario.seyb@rwth-aachen.de', license='MIT', packages=['meshvis'], diff --git a/tests/test_indexed_attributes.py b/tests/test_indexed_attributes.py index e5eaf4c..73054bf 100644 --- a/tests/test_indexed_attributes.py +++ b/tests/test_indexed_attributes.py @@ -4,14 +4,20 @@ import meshvis class IndexedAttributes(unittest.TestCase): quad_verts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]] - quad_faces = [[0, 1, 2], [0, 2, 3]] + quad_faces_tri = [[0, 1, 2], [0, 2, 3]] - def point_attribute(self): - attrib = meshvis.PointAttribute(['a', 'b', 'c, ''d']) - resolved_attrib = meshvis.resolve_attributes(self.quad_faces, [attrib]) + def point_attribute_tri(self): + attrib = meshvis.PointAttribute(['a', 'b', 'c', 'd']) + resolved_attrib = meshvis.resolve_attributes(self.quad_faces_tri, [attrib])[0] self.assertEqual(len(resolved_attrib), 6) self.assertListEqual(resolved_attrib, ['a', 'b', 'c', 'a', 'c', 'd']) + def face_attribute_tri(self): + attrib = meshvis.FaceAttribute(['a', 'b']) + resolved_attrib = meshvis.resolve_attributes(self.quad_faces_tri, [attrib])[0] + self.assertEqual(len(resolved_attrib), 2) + self.assertListEqual(resolved_attrib, ['a', 'b']) + if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(IndexedAttributes) -- GitLab