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

wip: Build docs using pdoc #309

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions quil-py/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ dependencies = [
"pytest",
]

[tasks.py-docs]
dependencies = [
"poetry-install",
"install-quil"
]
command = "poetry"
args = ["run", "python", "make_docs.py"]

[tasks.dev-flow]
dependencies = ["dev-test-flow", "pytest-flow", "stubtest"]

Expand Down
19 changes: 19 additions & 0 deletions quil-py/make_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pathlib import Path
import sys

import pdoc

import quil # noqa - we need to import quil for it to appear in sys.modules


if __name__ == "__main__":
# Workaround for an incompatiblity between pdoc and how we expose the quil
# package from pyo3. This module hierarchy isn't valid in a real Python
# environment, but overriding module.__name__ here helps pdoc import the
# right module internally.
# Possibly related issue: https://github.com/mitmproxy/pdoc/issues/633
for qualified_name, module in sys.modules.items():
if qualified_name.startswith("quil.") and qualified_name.count(".") == 1:
module.__name__ = qualified_name

pdoc.pdoc("quil", "!quil.quil", output_directory=Path("docs"))
1 change: 1 addition & 0 deletions quil-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ black = "^23.1.0"
maturin = "^1.2.3"
mypy = "^1.1.1"
pytest = "^7.2.2"
pdoc = "^14.1.0"

[tool.maturin]
features = ["pyo3/extension-module"]
Expand Down
1 change: 1 addition & 0 deletions quil-py/quil/expression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .quil.expression import *
1 change: 1 addition & 0 deletions quil-py/quil/instructions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .quil.instructions import *
1 change: 1 addition & 0 deletions quil-py/quil/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .quil.program import *
Loading