Python: add system for generating markdown docs

This commit is contained in:
Gaute Lindkvist 2019-06-14 16:07:56 +02:00
parent 055cb732db
commit f59a13cd18
6 changed files with 233 additions and 0 deletions

View File

@ -0,0 +1,4 @@
You need sphinx (pip install sphinx) to update the documentation.
To update run "make html" to update to reflect changes to the python code.

View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
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% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

@ -0,0 +1,2 @@
.. include:: header.rst
.. include:: rips.rst

View File

@ -0,0 +1,67 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains 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
sys.path.insert(0, os.path.abspath('../../'))
# -- Project information -----------------------------------------------------
project = 'rips'
copyright = '2019, Ceetron Solutions AS'
author = 'Ceetron Solutions AS'
# The full version, including alpha/beta/rc tags
release = '2019.04.01'
# -- 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.napoleon',
'sphinx_markdown_builder'
]
master_doc = 'PythonRips'
napoleon_google_docstring = True
# 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 = ['build/*', 'rips.rst']
# -- 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'
smartquotes=False
# 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']
# -- Extension configuration -------------------------------------------------

View File

@ -0,0 +1,20 @@
---
layout: docs
title: rips - gRPC Python API
permalink: /docs/python/
published: true
---
ResInsight has a `gRPC Remote Procedure Call <https://www.grpc.io/>`_ interface with a Python Client interface. This interface allows you to interact with a running ResInsight instance from a Python script.
The Python client package is available for install via the Python PIP package system with ``pip install rips`` as admin user, or ``pip install --user rips`` as a regular user.
On some systems the ``pip`` command may have to be replaced by ``python -m pip``.
In order for gRPC to be available, ResInsight needs to be built with the ``RESINSIGHT_ENABLE_GRPC`` option set. A valid gRPC build will show a message in the About dialog confirming gRPC is available:
.. image:: ../images/AboutGrpc.png
Furthermore, gRPC needs to be enabled in the Scripting tab of the Preference dialog:
.. image:: ../images/PrefGrpc.png

View File

@ -0,0 +1,105 @@
Instance Module
================
.. autoclass:: rips.Instance
:members:
Example
--------
.. literalinclude:: ../../rips/examples/InstanceExample.py
:language: python
:lines: 5-
:emphasize-lines: 3
App Module
===========
.. autoclass:: rips.App
:members:
Example
--------
.. literalinclude:: ../../rips/examples/AppInfo.py
:language: python
:lines: 5-
:emphasize-lines: 5
Case Module
============
.. autoclass:: rips.Case
:members:
Example
-------
.. literalinclude:: ../../rips/examples/AllCases.py
:language: python
:lines: 5-
:emphasize-lines: 5
Commands Module
===============
.. autoclass:: rips.Commands
:members:
:undoc-members:
Example
--------
.. literalinclude:: ../../rips/examples/CommandExample.py
:language: python
:lines: 5-
Grid Module
===========
.. autoclass:: rips.Grid
:members:
Example
-------
.. code-block:: python
case = rips_instance.project.loadCase(path=casePath)
print (case.gridCount())
if case.gridCount() > 0:
grid = case.grid(index=0)
dimensions = grid.dimensions()
print(dimensions.i)
print(dimensions.j)
print(dimensions.k)
Project Module
==============
.. autoclass:: rips.Project
:members:
Properties Module
=================
.. autoclass:: rips.Properties
:members:
Synchronous Example
--------------------
Read two properties, multiply them together and push the results back to ResInsight in a naïve way, by reading PORO into a list, then reading PERMX into a list, then multiplying them both in a resulting list and finally transferring back the list.
This is slow and inefficient, but works.
.. literalinclude:: ../../rips/examples/InputPropTestSync.py
:language: python
:lines: 5-
Asynchronous Example
--------------------
Read two properties at the same time chunk by chunk, multiply each chunk together and start transferring the result back to ResInsight as soon as the chunk is finished.
This is far more efficient.
.. literalinclude:: ../../rips/examples/InputPropTestAsync.py
:language: python
:lines: 5-