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

docs(hugr-py): docstrings for builder #1231

Merged
merged 44 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
72b6d3b
docs: add docs build infrastructure
ss2165 Jun 26, 2024
169c1a3
docs: enable doctests in pytest
ss2165 Jun 26, 2024
7ae8adf
docs: add docstrings to node_port
ss2165 Jun 26, 2024
49222e8
docs: for utils.py
ss2165 Jun 26, 2024
d62ce5a
docs: add tys.py
ss2165 Jun 26, 2024
4e3fb73
docs: add exceptions.py
ss2165 Jun 27, 2024
c0bafc5
ci: add no cover pragmas
ss2165 Jun 27, 2024
b73e421
docs: add ops.py
ss2165 Jun 27, 2024
dc96da1
docs: add val.py
ss2165 Jun 28, 2024
cafb929
docs: impl repr for kinds
ss2165 Jun 28, 2024
2b1706c
docs: add hugr.py
ss2165 Jun 28, 2024
b1e549c
refator: use standard import pattern in dfg.py
ss2165 Jun 28, 2024
95c8e8f
refactor: use *args pattern in Cfg constructor
ss2165 Jun 28, 2024
dcdace5
refactor: remove singleton ops
ss2165 Jun 28, 2024
4283bd0
refactor: don't include empty rows in ops repr
ss2165 Jun 28, 2024
a3286a0
[REVERTME] turn off source to speed up docs builds
ss2165 Jun 28, 2024
b0cc8f1
docs: get rid of some sphinx warnings
ss2165 Jun 28, 2024
772e89c
refactor: separate inputs to `insert_tail_loop`
ss2165 Jun 28, 2024
98454df
refactor: couple of nicer reprs in ops
ss2165 Jun 28, 2024
88f3459
docs: add dfg.py
ss2165 Jun 28, 2024
3577090
docs: add cfg.py
ss2165 Jun 28, 2024
adfdb46
docs: add cond_loop.py
ss2165 Jun 28, 2024
c3cd684
docs: add function.py
ss2165 Jun 28, 2024
8b7c84f
docs: minor cleanups
ss2165 Jun 28, 2024
6ed7417
refactor(hugr-py): more ruff
ss2165 Jul 1, 2024
5b53d26
fix: fix some typos
ss2165 Jul 1, 2024
833c0f3
Merge branch 'ss/more-ruff' into ss/docstrings
ss2165 Jul 1, 2024
fa5b9f4
refactor: apply ruff fixes
ss2165 Jul 1, 2024
b7fabeb
fix: apply some fixes suggested by ruff+pycodestyle
ss2165 Jul 1, 2024
e5f20a6
exclude annoying things from docstyle
ss2165 Jul 1, 2024
9a26771
Merge branch 'main' into ss/docstrings
ss2165 Jul 1, 2024
65c9f83
docs: fix some typos
ss2165 Jul 1, 2024
fdc8d12
docs: add fullstop to alias desc in schema
ss2165 Jul 1, 2024
f7d2ead
typo
ss2165 Jul 1, 2024
1cb6ec3
docs: reword type propagation
ss2165 Jul 1, 2024
4806552
docs: remove unused newline
ss2165 Jul 1, 2024
c3d6986
docs: remove some unnecessary announcements
ss2165 Jul 1, 2024
36a222e
Review proof read edits
ss2165 Jul 1, 2024
4f30040
refactor: simplify import lines
ss2165 Jul 1, 2024
737e738
refactor: enforce bijection in initial bimap
ss2165 Jul 1, 2024
a957c98
ise -> ize
ss2165 Jul 1, 2024
621b255
refactor: remove extension delta from Dfg
ss2165 Jul 1, 2024
cc62d49
docstring fix
ss2165 Jul 1, 2024
006b94c
test: add NotBijection test
ss2165 Jul 1, 2024
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
1 change: 1 addition & 0 deletions hugr-py/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
Binary file added hugr-py/docs/_static/Quantinuum_logo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hugr-py/docs/_static/Quantinuum_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions hugr-py/docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.wy-side-nav-search,
.wy-nav-top {
background: #5A46BE;
}

.wy-grid-for-nav,
.wy-body-for-nav,
.wy-nav-side,
.wy-side-scroll,
.wy-menu,
.wy-menu-vertical {
background-color: #FFFFFF;
}

.wy-menu-vertical a:hover {
background-color: #d9d9d9;
}

.btn-link:visited,
.btn-link,
a:visited,
.a.reference.external,
.a.reference.internal,
.wy-menu-vertical a,
.wy-menu-vertical li,
.wy-menu-vertical ul,
.span.pre,
.sig-param,
.std.std-ref,


html[data-theme=light] {
--pst-color-inline-code: rgb(199, 37, 78) !important;
}

.sig-name {
font-size: 1.25rem;
}
3 changes: 3 additions & 0 deletions hugr-py/docs/api-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_autosummary
_build
generated
5 changes: 5 additions & 0 deletions hugr-py/docs/api-docs/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
37 changes: 37 additions & 0 deletions hugr-py/docs/api-docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
..
Custom class template to make sphinx-autosummary list the full API doc after
the summary. See https://github.com/sphinx-doc/sphinx/issues/7912

{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:
cqc-alec marked this conversation as resolved.
Show resolved Hide resolved

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:nosignatures:
{% for item in methods %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
68 changes: 68 additions & 0 deletions hugr-py/docs/api-docs/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
..
Custom module template to make sphinx-autosummary list the full API doc after
the summary. See https://github.com/sphinx-doc/sphinx/issues/7912

{{ name | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module attributes

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

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

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

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

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

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

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

{% block modules %}
{% if modules %}
.. autosummary::
:toctree:
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
44 changes: 44 additions & 0 deletions hugr-py/docs/api-docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Configuration file for the Sphinx documentation builder. # noqa: INP001
# See https://www.sphinx-doc.org/en/master/usage/configuration.html


project = "HUGR Python"
copyright = "2024, Quantinuum"
author = "Quantinuum"

extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
]

html_theme = "sphinx_book_theme"

html_title = "HUGR python package API documentation."

html_theme_options = {
"repository_url": "https://github.com/CQCL/hugr",
"use_repository_button": True,
"navigation_with_keys": True,
"logo": {
"image_light": "_static/Quantinuum_logo_black.png",
"image_dark": "_static/Quantinuum_logo_white.png",
},
}

html_static_path = ["../_static"]
html_css_files = ["custom.css"]

autosummary_generate = True

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "conftest.py"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
}

html_show_sourcelink = False
20 changes: 20 additions & 0 deletions hugr-py/docs/api-docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
HUGR Python API Documentation
==================================

This is the API documentation for the HUGR Python package.


.. autosummary::
:toctree: generated
:template: autosummary/module.rst
:recursive:

hugr


Indices and tables
~~~~~~~~~~~~~~~~~~

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions hugr-py/docs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

mkdir build

touch build/.nojekyll # Disable jekyll to keep files starting with underscores

sphinx-build -b html ./api-docs ./build/api-docs
Loading
Loading