mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[doc] sphinx documentation setup
This commit is contained in:
parent
243c278bcc
commit
b2db98f128
15 changed files with 312 additions and 73 deletions
3
docs/.gitignore
vendored
Normal file
3
docs/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Sphinx
|
||||
build/
|
||||
source/generated/
|
20
docs/Makefile
Normal file
20
docs/Makefile
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
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)
|
18
docs/README.md
Normal file
18
docs/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Documentation
|
||||
|
||||
We use [Sphinx](https://www.sphinx-doc.org) to generate Meshroom's documentation.
|
||||
|
||||
To install all the requirements for building the documentation, simply run:
|
||||
```bash
|
||||
pip install sphinx sphinx-rtd-theme myst-parser
|
||||
```
|
||||
|
||||
> Note: since Sphinx will import the entire `meshroom` package, all requirements for Meshroom must also be installed
|
||||
|
||||
To generate the documentation, go to the `docs` folder and run the Sphinx makefile:
|
||||
```bash
|
||||
cd meshroom/docs
|
||||
make html
|
||||
```
|
||||
|
||||
To access the documentation, simply go to `meshroom/docs/build/html` and open `index.html` in a browser.
|
35
docs/make.bat
Normal file
35
docs/make.bat
Normal 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
|
||||
|
||||
%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.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
65
docs/source/_ext/fetch_md.py
Normal file
65
docs/source/_ext/fetch_md.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
import os
|
||||
from docutils.nodes import SparseNodeVisitor
|
||||
from docutils.parsers.rst import Directive
|
||||
from myst_parser.docutils_ import Parser
|
||||
from myst_parser.mdit_to_docutils.base import make_document
|
||||
|
||||
|
||||
class Relinker(SparseNodeVisitor):
|
||||
|
||||
@staticmethod
|
||||
def get_link_key(node):
|
||||
link_keys = ['uri', 'refuri', 'refname']
|
||||
for key in link_keys:
|
||||
if key in node.attributes.keys():
|
||||
return key
|
||||
return None
|
||||
|
||||
def relink(self, node, base_dir):
|
||||
key = Relinker.get_link_key(node)
|
||||
if key is None:
|
||||
return
|
||||
link = node.attributes[key]
|
||||
if link.startswith('http') or link.startswith('mailto'):
|
||||
return
|
||||
if link.startswith('/'):
|
||||
link = link[1:]
|
||||
node.attributes[key] = base_dir+'/'+link
|
||||
|
||||
def visit_image(self, node):
|
||||
self.relink(node, os.getenv('PROJECT_DIR'))
|
||||
|
||||
|
||||
class FetchMd(Directive):
|
||||
|
||||
required_arguments = 2
|
||||
|
||||
def arg_path(self):
|
||||
if self.arguments[0] == ':file:':
|
||||
return self.arguments[1]
|
||||
|
||||
def run(self):
|
||||
path = os.path.abspath(os.getenv('PROJECT_DIR') + '/' + self.arg_path())
|
||||
result = []
|
||||
try:
|
||||
with open(path) as file:
|
||||
parser = Parser()
|
||||
text = file.read()
|
||||
doc = make_document(parser_cls=Parser)
|
||||
parser.parse(text, doc)
|
||||
relinker = Relinker(doc)
|
||||
doc.walk(relinker)
|
||||
result.append(doc[0])
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('fetch_md', FetchMd)
|
||||
|
||||
return {
|
||||
'version': '0.1',
|
||||
'parallel_read_safe': True,
|
||||
'parallel_write_safe': True
|
||||
}
|
63
docs/source/_templates/autosummary/module.rst
Normal file
63
docs/source/_templates/autosummary/module.rst
Normal file
|
@ -0,0 +1,63 @@
|
|||
{{ fullname | escape | underline}}
|
||||
|
||||
|
||||
.. automodule:: {{ fullname }}
|
||||
|
||||
{% block attributes %}
|
||||
{% if attributes %}
|
||||
.. rubric:: {{ _('Module Attributes') }}
|
||||
|
||||
.. autosummary::
|
||||
{% for item in attributes %}
|
||||
{{ item }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block functions %}
|
||||
{% if functions %}
|
||||
.. rubric:: {{ _('Functions') }}
|
||||
|
||||
.. autosummary::
|
||||
{% for item in functions %}
|
||||
{{ item }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block classes %}
|
||||
{% if classes %}
|
||||
.. rubric:: {{ _('Classes') }}
|
||||
|
||||
.. autosummary::
|
||||
:toctree:
|
||||
:recursive:
|
||||
{% for item in classes %}
|
||||
{{ item }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block exceptions %}
|
||||
{% if exceptions %}
|
||||
.. rubric:: {{ _('Exceptions') }}
|
||||
|
||||
.. autosummary::
|
||||
{% for item in exceptions %}
|
||||
{{ item }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block modules %}
|
||||
{% if modules %}
|
||||
.. rubric:: Modules
|
||||
|
||||
.. autosummary::
|
||||
:toctree:
|
||||
:recursive:
|
||||
{% for item in modules %}
|
||||
{{ item }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
9
docs/source/api.rst
Normal file
9
docs/source/api.rst
Normal file
|
@ -0,0 +1,9 @@
|
|||
Python API Reference
|
||||
====================
|
||||
|
||||
|
||||
.. autosummary::
|
||||
:recursive:
|
||||
:toctree: generated
|
||||
|
||||
meshroom
|
6
docs/source/changes.rst
Normal file
6
docs/source/changes.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Release Notes
|
||||
=============
|
||||
|
||||
|
||||
.. fetch_md::
|
||||
:file: CHANGES.md
|
40
docs/source/conf.py
Normal file
40
docs/source/conf.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
os.environ['PROJECT_DIR'] = Path('../..').resolve().as_posix()
|
||||
|
||||
sys.path.append(os.path.abspath(os.getenv('PROJECT_DIR')))
|
||||
sys.path.append(os.path.abspath('./_ext'))
|
||||
|
||||
project = 'Meshroom'
|
||||
copyright = '2022, AliceVision Association'
|
||||
author = 'AliceVision Association'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.autosummary',
|
||||
'fetch_md'
|
||||
]
|
||||
|
||||
templates_path = ['_templates']
|
||||
exclude_patterns = []
|
||||
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_static_path = ['_static']
|
15
docs/source/index.rst
Normal file
15
docs/source/index.rst
Normal file
|
@ -0,0 +1,15 @@
|
|||
Welcome to meshroom's documentation!
|
||||
====================================
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
api
|
||||
install
|
||||
changes
|
||||
|
||||
|
||||
.. fetch_md::
|
||||
:file: README.md
|
6
docs/source/install.rst
Normal file
6
docs/source/install.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Install
|
||||
=======
|
||||
|
||||
|
||||
.. fetch_md::
|
||||
:file: INSTALL.md
|
|
@ -2,10 +2,10 @@ __version__ = "2021.1.0"
|
|||
__version_name__ = __version__
|
||||
|
||||
from distutils import util
|
||||
from enum import Enum
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from .common import init, Backend
|
||||
|
||||
# sys.frozen is initialized by cx_Freeze and identifies a release package
|
||||
isFrozen = getattr(sys, "frozen", False)
|
||||
|
@ -25,20 +25,7 @@ __version_name__ = os.environ.get("REZ_MESHROOM_VERSION", __version_name__)
|
|||
useMultiChunks = util.strtobool(os.environ.get("MESHROOM_USE_MULTI_CHUNKS", "True"))
|
||||
|
||||
|
||||
class Backend(Enum):
|
||||
STANDALONE = 1
|
||||
PYSIDE = 2
|
||||
|
||||
|
||||
backend = Backend.STANDALONE
|
||||
|
||||
|
||||
def useUI():
|
||||
global backend
|
||||
backend = Backend.PYSIDE
|
||||
|
||||
|
||||
def setupEnvironment():
|
||||
def setupEnvironment(backend=Backend.STANDALONE):
|
||||
"""
|
||||
Setup environment for Meshroom to work in a prebuilt, standalone configuration.
|
||||
|
||||
|
@ -61,6 +48,8 @@ def setupEnvironment():
|
|||
COPYING.md # Meshroom COPYING file
|
||||
"""
|
||||
|
||||
init(backend)
|
||||
|
||||
def addToEnvPath(var, val, index=-1):
|
||||
"""
|
||||
Add paths to the given environment variable.
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
import meshroom
|
||||
"""
|
||||
This module provides an abstraction around standard non-gui Qt notions (like Signal/Slot),
|
||||
so it can be used in python-only without the dependency to Qt.
|
||||
|
||||
Warning: A call to `init(Backend.XXX)` is required to choose the backend before using this module.
|
||||
"""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
class Backend(Enum):
|
||||
STANDALONE = 1
|
||||
PYSIDE = 2
|
||||
|
||||
DictModel = None
|
||||
ListModel = None
|
||||
|
@ -10,52 +21,14 @@ Variant = None
|
|||
VariantList = None
|
||||
JSValue = None
|
||||
|
||||
if meshroom.backend == meshroom.Backend.PYSIDE:
|
||||
# PySide types
|
||||
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||
elif meshroom.backend == meshroom.Backend.STANDALONE:
|
||||
# Core types
|
||||
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||
def init(backend):
|
||||
global DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||
if backend == Backend.PYSIDE:
|
||||
# PySide types
|
||||
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||
elif backend == Backend.STANDALONE:
|
||||
# Core types
|
||||
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||
|
||||
|
||||
class _BaseModel:
|
||||
""" Common API for model implementation """
|
||||
|
||||
def __init__(self, keyAttrName="name", **kwargs):
|
||||
"""
|
||||
:param keyAttrName: name of the attribute containing the unique key for an object
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def objects(self):
|
||||
""" Return a dictionary with {unique_key: object} mapping"""
|
||||
return None
|
||||
|
||||
def get(self, key):
|
||||
""" Get the object with the unique key 'key' """
|
||||
pass
|
||||
|
||||
def add(self, obj):
|
||||
""" Add given object using its 'keyAttrName' as unique key """
|
||||
pass
|
||||
|
||||
def pop(self, key):
|
||||
""" Remove 'item' with unique key 'key' from the model """
|
||||
pass
|
||||
|
||||
def remove(self, obj):
|
||||
""" Remove 'obj' from the model """
|
||||
pass
|
||||
|
||||
def clear(self):
|
||||
""" Remove all internal objects """
|
||||
pass
|
||||
|
||||
def update(self, d):
|
||||
""" Combine dict 'd' with self """
|
||||
pass
|
||||
|
||||
def reset(self, d):
|
||||
""" Reset model with given values """
|
||||
pass
|
||||
# default initialization
|
||||
init(Backend.STANDALONE)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
import meshroom
|
||||
meshroom.useUI()
|
|
@ -1,12 +1,11 @@
|
|||
import signal
|
||||
import sys
|
||||
import meshroom
|
||||
from meshroom.common import Backend
|
||||
|
||||
meshroom.setupEnvironment(backend=Backend.PYSIDE)
|
||||
|
||||
if __name__ == "__main__":
|
||||
meshroom.setupEnvironment()
|
||||
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
from meshroom.ui.app import MeshroomApp
|
||||
app = MeshroomApp(sys.argv)
|
||||
app.exec_()
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
from meshroom.ui.app import MeshroomApp
|
||||
app = MeshroomApp(sys.argv)
|
||||
app.exec_()
|
||||
|
|
Loading…
Add table
Reference in a new issue