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

Sphinx documentation for the Python API #40

Merged
merged 43 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a7e7dde
Add reST stubs for Jet Python package
Mandrenkov Jun 29, 2021
5264828
Add generated Python API docs to 'clean' target
Mandrenkov Jun 29, 2021
f4bc62f
Update conf.py to generate Python API docs
Mandrenkov Jun 29, 2021
2b3843d
Include autosummary templates based on SF and PL
Mandrenkov Jun 29, 2021
02c0b29
Fix Doxygen comment formatting in Tensor.hpp
Mandrenkov Jun 29, 2021
76c9032
Add module docstring to jet package
Mandrenkov Jun 29, 2021
d7e8880
Move constructor docstrings to class docstrings
Mandrenkov Jun 29, 2021
751a367
Update changelog
Mandrenkov Jun 29, 2021
cf9aa30
Merge branch 'main' into python-api-docs
Mandrenkov Jun 29, 2021
e7e2c4c
Update PR number in changelog
Mandrenkov Jun 29, 2021
06db7a2
Update name of TBCC to TBC after merge
Mandrenkov Jun 29, 2021
e2b6869
Remove trivial inheritance diagram from circuit.py
Mandrenkov Jun 29, 2021
251d942
Fix 'Key Concepts' and 'Getting Started' quick links
Mandrenkov Jun 30, 2021
63bfb7f
Replace tensors.html link with introduction.html
Mandrenkov Jun 30, 2021
9777a85
Add API documentation for Python bindings
Mandrenkov Jun 30, 2021
21352b4
Update TensorNetworkIO docstrings to match Python package conventions
Mandrenkov Jun 30, 2021
77228fe
Update TensorNetwork docstrings to match Python package conventions
Mandrenkov Jun 30, 2021
ee97e8f
Update Tensor docstrings to match Python package conventions
Mandrenkov Jun 30, 2021
7f4670b
Update TBC docstrings to match Python package conventions
Mandrenkov Jun 30, 2021
2423fa9
Update PathInfo docstrings to match Python package conventions
Mandrenkov Jun 30, 2021
81c7fc3
Apply C++ formatter
Mandrenkov Jun 30, 2021
d280844
Remove redundant import
Mandrenkov Jun 30, 2021
e9510f2
Add examples to interpreter.py docstrings
Mandrenkov Jun 30, 2021
ca934fb
Merge branch 'main' into python-api-docs
Mandrenkov Jun 30, 2021
6b30b17
Build Python wheel in documentation workflow
Mandrenkov Jun 30, 2021
14d3a58
Apply suggestions from code review
Mandrenkov Jun 30, 2021
7f79577
Merge branch 'python-api-docs' of github.com:XanaduAI/jet into python…
Mandrenkov Jun 30, 2021
30d1fd4
Remove MagicMock() modules
Mandrenkov Jun 30, 2021
bb8925b
Restore tildes to remove class ambiguity
Mandrenkov Jun 30, 2021
65316b2
Update 'docs' target to install Python package
Mandrenkov Jun 30, 2021
e8d7844
Install wheel prior to installing quantum-jet wheel
Mandrenkov Jun 30, 2021
c02fdc7
Defer *.whl wildcard expansion by creating 'dist' target
Mandrenkov Jun 30, 2021
1c9e497
Fix typo in 'dist' target
Mandrenkov Jun 30, 2021
9a79af8
Fix accidental blockquote caused by docstring indentation
Mandrenkov Jul 2, 2021
4d75456
Distinguish overloaded functions and methods
Mandrenkov Jul 2, 2021
8e8c170
Restore use of josh146/sphinx-action GitHub Action
Mandrenkov Jul 2, 2021
eb588b5
Apply suggested Sphinx build options
Mandrenkov Jul 2, 2021
cafb6fb
Move Sphinx options to 'docs' target of Makefile
Mandrenkov Jul 2, 2021
b620f58
Use Haskell syntax highlighting in XIR blocks
Mandrenkov Jul 2, 2021
1e54381
Replace 'cd' with Makefile '-C' flag
Mandrenkov Jul 2, 2021
fd9fdce
Try quotes around build command
Mandrenkov Jul 2, 2021
569c526
Restore GitHub Actions workflow
Mandrenkov Jul 2, 2021
1eb841f
Replace '.Class' with 'jet.Class'
Mandrenkov Jul 2, 2021
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
2 changes: 2 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@

### Documentation

* The Sphinx documentation now includes API documentation for the `jet` Python package. [(#40)](https://github.com/XanaduAI/jet/pull/40)

* The "Using Jet" section of the Sphinx documentation website now compiles with the latest Jet headers. [(#26)](https://github.com/XanaduAI/jet/pull/26)

* The license comment headers at the top of the IR source files have been removed. [(#14)](https://github.com/XanaduAI/jet/pull/14)
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- uses: josh146/sphinx-action@master
Mandrenkov marked this conversation as resolved.
Show resolved Hide resolved
with:
docs-folder: "docs/"
pre-build-command: "apt install -y doxygen && pip3 install -r requirements.txt"
build-command: "make html"
- name: Install dependencies
run: sudo apt install -y libopenblas-dev python3.8-dev doxygen graphviz

- name: Build documentation
run: make docs
Mandrenkov marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload HTML
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ docs/__pycache__/*
docs/_build/*
docs/_ext/__pycache__/*
docs/api/*
docs/code/api/*
docs/doxyoutput/*
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ TARGETS

uninstall [prefix=<path>] Remove Jet headers from <path>/include, defaults to $(.DEFAULT_PREFIX)

test Build and run C++ tests (requires Cmake)
test Build and run C++ tests (requires CMake)

dist Build the Python source and wheel distributions

docs Build docs (requires Doxygen, Pandoc and pip)

Expand Down Expand Up @@ -54,20 +56,26 @@ test: $(.TEST_BUILD_DIR)
$(.TEST_BUILD_DIR)/test/runner


.PHONY: dist
dist:
cd python && $(MAKE) dist


.PHONY: docs
docs: $(.VENV_DIR)
. $(.VENV_DIR)/bin/activate; cd ./docs && $(MAKE) html
docs: $(.VENV_DIR) dist
$(.VENV_DIR)/bin/pip install -q $(wildcard dist/*.whl) --upgrade
. $(.VENV_DIR)/bin/activate; cd docs && $(MAKE) html SPHINXOPTS="-W --keep-going"


.PHONY: clean
clean:
rm -rf ./docs/_build ./docs/api ./docs/doxyoutput
rm -rf $(.TEST_BUILD_DIR)
rm -rf $(.VENV_DIR)
rm -rf ./docs/_build ./docs/api ./docs/code/api ./docs/doxyoutput
rm -rf $(.TEST_BUILD_DIR) $(.VENV_DIR) ./dist


$(.VENV_DIR):
python3 -m venv $@
$@/bin/pip install -q wheel
$@/bin/pip install -q -r docs/requirements.txt


Expand Down
5 changes: 5 additions & 0 deletions docs/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ fullname | escape | underline}}
Mandrenkov marked this conversation as resolved.
Show resolved Hide resolved

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
86 changes: 86 additions & 0 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{ fullname }}
{{ underline }}

.. autoclass:: {{ fullname }}
:show-inheritance:

{% if '__init__' in methods %}
{% set caught_result = methods.remove('__init__') %}
{% endif %}

{% block attributes_documentation %}
{% if attributes %}

.. raw:: html

<a class="attr-details-header collapse-header" data-toggle="collapse" href="#attrDetails" aria-expanded="false" aria-controls="attrDetails">
<h2 style="font-size: 24px;">
<i class="fas fa-angle-down rotate" style="float: right;"></i> Attributes
</h2>
</a>
<div class="collapse" id="attrDetails">

{% block attributes_summary %}
{% if attributes %}

.. autosummary::
:nosignatures:
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}

{% for item in attributes %}
.. autoattribute:: {{ item }}
{%- endfor %}

.. raw:: html

</div>

{% endif %}
{% endblock %}

{% block methods_documentation %}
{% if methods %}

.. raw:: html

<a class="meth-details-header collapse-header" data-toggle="collapse" href="#methDetails" aria-expanded="false" aria-controls="methDetails">
<h2 style="font-size: 24px;">
<i class="fas fa-angle-down rotate" style="float: right;"></i> Methods
</h2>
</a>
<div class="collapse" id="methDetails">

{% block methods_summary %}
{% if methods %}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}

{% for item in methods %}
.. automethod:: {{ item }}
{%- endfor %}

.. raw:: html

</div>

{% endif %}
{% endblock %}

.. raw:: html

<script type="text/javascript">
$(".collapse-header").click(function () {
$(this).children('h2').eq(0).children('i').eq(0).toggleClass("up");
})
</script>
40 changes: 40 additions & 0 deletions docs/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block classes %}
{% if classes %}
.. rubric:: Classes

.. autosummary::
:toctree:

{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
:toctree:

{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions

.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
17 changes: 17 additions & 0 deletions docs/_templates/autosummary_core/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% if referencefile %}
.. include:: {{ referencefile }}
{% endif %}

{% if module.split(".")[1:] | length >= 1 %}
{% set mod = module.split(".")[1:] | join(".") %}
{% set mod = "jet." + mod %}
{% else %}
{% set mod = "jet" %}
{% endif %}

{{ mod }}.{{ objname }}
={% for i in range(mod|length) %}={% endfor %}{{ underline }}

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
99 changes: 99 additions & 0 deletions docs/_templates/autosummary_core/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{% if referencefile %}
.. include:: {{ referencefile }}
{% endif %}

{% if module.split(".")[1:] | length >= 1 %}
{% set mod = module.split(".")[1:] | join(".") %}
{% set mod = "jet." + mod %}
{% else %}
{% set mod = "jet" %}
{% endif %}

{{ mod }}.{{ objname }}
={% for i in range(mod|length) %}={% endfor %}{{ underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:show-inheritance:

{% if '__init__' in methods %}
{% set caught_result = methods.remove('__init__') %}
{% endif %}

{% block attributes_documentation %}
{% if attributes %}

.. raw:: html

<a class="attr-details-header collapse-header" data-toggle="collapse" href="#attrDetails" aria-expanded="false" aria-controls="attrDetails">
<h2 style="font-size: 24px;">
<i class="fas fa-angle-down rotate" style="float: right;"></i> Attributes
</h2>
</a>
<div class="collapse" id="attrDetails">

{% block attributes_summary %}
{% if attributes %}

.. autosummary::
:nosignatures:
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}

{% for item in attributes %}
.. autoattribute:: {{ item }}
{%- endfor %}

.. raw:: html

</div>

{% endif %}
{% endblock %}

{% block methods_documentation %}
{% if methods %}

.. raw:: html

<a class="meth-details-header collapse-header" data-toggle="collapse" href="#methDetails" aria-expanded="false" aria-controls="methDetails">
<h2 style="font-size: 24px;">
<i class="fas fa-angle-down rotate" style="float: right;"></i> Methods
</h2>
</a>
<div class="collapse" id="methDetails">

{% block methods_summary %}
{% if methods %}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}

{% for item in methods %}
.. automethod:: {{ item }}
{%- endfor %}

.. raw:: html

</div>

{% endif %}
{% endblock %}

.. raw:: html

<script type="text/javascript">
$(".collapse-header").click(function () {
$(this).children('h2').eq(0).children('i').eq(0).toggleClass("up");
})
</script>
48 changes: 48 additions & 0 deletions docs/_templates/autosummary_core/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% if referencefile %}
.. include:: {{ referencefile }}
{% endif %}

{% if module.split(".")[1:] | length >= 1 %}
{% set mod = module.split(".")[1:] | join(".") %}
{% set mod = "jet." + mod %}
{% else %}
{% set mod = "jet" %}
{% endif %}

{{ mod }}.{{ objname }}
={% for i in range(mod|length) %}={% endfor %}{{ underline }}

.. automodule:: {{ fullname }}

{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: Classes

.. autosummary::
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions

.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
14 changes: 14 additions & 0 deletions docs/code/jet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
jet
===

.. currentmodule:: jet

.. automodapi:: jet
Mandrenkov marked this conversation as resolved.
Show resolved Hide resolved
:no-heading:
:include-all-objects:
:skip: version
:skip: TaskBasedContractorType
:skip: TensorNetworkFileType
:skip: TensorNetworkSerializerType
:skip: TensorNetworkType
:skip: TensorType
Mandrenkov marked this conversation as resolved.
Show resolved Hide resolved
Loading