Skip to content

Commit

Permalink
feat(bindgen): Generate Python docs/
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Apr 26, 2023
1 parent 8d8a464 commit 413201e
Show file tree
Hide file tree
Showing 26 changed files with 399 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,20 @@ async def compress_stringify_async(
) -> bytes:
"""Given a binary, compress and optionally base64 encode.
Parameters
----------
:param input: Input binary
:type input: bytes
input: bytes
Input binary
:param stringify: Stringify the output
:type stringify: bool
stringify: bool, optional
Stringify the output
:param compression_level: Compression level, typically 1-9
:type compression_level: int
compression_level: int, optional
Compression level, typically 1-9
data_url_prefix: str, optional
dataURL prefix
Returns
-------
bytes
Output compressed binary
:param data_url_prefix: dataURL prefix
:type data_url_prefix: str
:return: Output compressed binary
:rtype: bytes
"""
js_module = await js_package.js_module
web_worker = js_resources.web_worker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@ async def parse_string_decompress_async(
) -> bytes:
"""Given a binary or string produced with compress-stringify, decompress and optionally base64 decode.
Parameters
----------
:param input: Compressed input
:type input: bytes
input: bytes
Compressed input
parse_string: bool, optional
Parse the input string before decompression
Returns
-------
bytes
Output decompressed binary
:param parse_string: Parse the input string before decompression
:type parse_string: bool
:return: Output decompressed binary
:rtype: bytes
"""
js_module = await js_package.js_module
web_worker = js_resources.web_worker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,20 @@ def compress_stringify(
) -> bytes:
"""Given a binary, compress and optionally base64 encode.
Parameters
----------
:param input: Input binary
:type input: bytes
input: bytes
Input binary
:param stringify: Stringify the output
:type stringify: bool
stringify: bool, optional
Stringify the output
:param compression_level: Compression level, typically 1-9
:type compression_level: int
compression_level: int, optional
Compression level, typically 1-9
data_url_prefix: str, optional
dataURL prefix
Returns
-------
bytes
Output compressed binary
:param data_url_prefix: dataURL prefix
:type data_url_prefix: str
:return: Output compressed binary
:rtype: bytes
"""
pipeline = Pipeline(file_resources('itkwasm_compress_stringify_wasi').joinpath(Path('wasm_modules') / Path('compress-stringify.wasi.wasm')))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@ def parse_string_decompress(
) -> bytes:
"""Given a binary or string produced with compress-stringify, decompress and optionally base64 decode.
Parameters
----------
:param input: Compressed input
:type input: bytes
input: bytes
Compressed input
parse_string: bool, optional
Parse the input string before decompression
Returns
-------
bytes
Output decompressed binary
:param parse_string: Parse the input string before decompression
:type parse_string: bool
:return: Output decompressed binary
:rtype: bytes
"""
pipeline = Pipeline(file_resources('itkwasm_compress_stringify_wasi').joinpath(Path('wasm_modules') / Path('parse-string-decompress.wasi.wasm')))

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = .
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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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

from datetime import date

project = 'itkwasm-compress-stringify'
copyright = f'{date.today().year}, NumFOCUS'
author = 'Insight Software Consortium'

extensions = [
'sphinx.ext.autosummary',
'autodoc2',
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx_copybutton',
'sphinxext.opengraph',
'sphinx_design',
]

myst_enable_extensions = ["colon_fence", "fieldlist"]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

autodoc2_packages = [
{
"path": "../itkwasm_compress_stringify",
"exclude_files": ["_version.py"],
},
]
autodoc2_render_plugin = "myst"

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"itkwasm": ("https://itkwasm.readthedocs.io/en/latest/", None),
}

html_theme = 'furo'
html_static_path = ['_static']
html_logo = "_static/logo.svg"
html_favicon = "_static/favicon.png"
html_title = f"{project}"

# Furo options
html_theme_options = {
"top_of_page_button": "edit",
"source_repository": "https://github.com/InsightSoftwareConsortium/itk-wasm",
"source_branch": "main",
"source_directory": "docs",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
itkwasm-compress-stringify
=======

> Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.
[![itkwasm-compress-stringify version](https://badge.fury.io/py/itkwasm_compress_stringify.svg)](https://pypi.org/project/itkwasm_compress_stringify/)

## Installation

```shell
pip install itkwasm-compress-stringify
```

```{toctree}
:hidden:
:maxdepth: 3
:caption: 📖 Reference
apidocs/index.rst
itkwasm docs <https://itkwasm.readthedocs.io/>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sphinx
furo
sphinx-autodoc2
myst-parser
sphinx-copybutton
sphinxext-opengraph
sphinx-design
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,20 @@ def compress_stringify(
) -> bytes:
"""Given a binary, compress and optionally base64 encode.
Parameters
----------
:param input: Input binary
:type input: bytes
input: bytes
Input binary
:param stringify: Stringify the output
:type stringify: bool
stringify: bool, optional
Stringify the output
:param compression_level: Compression level, typically 1-9
:type compression_level: int
compression_level: int, optional
Compression level, typically 1-9
data_url_prefix: str, optional
dataURL prefix
Returns
-------
bytes
Output compressed binary
:param data_url_prefix: dataURL prefix
:type data_url_prefix: str
:return: Output compressed binary
:rtype: bytes
"""
func = environment_dispatch("itkwasm_compress_stringify", "compress_stringify")
output = func(input, stringify=stringify, compression_level=compression_level, data_url_prefix=data_url_prefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,20 @@ async def compress_stringify_async(
) -> bytes:
"""Given a binary, compress and optionally base64 encode.
Parameters
----------
:param input: Input binary
:type input: bytes
input: bytes
Input binary
:param stringify: Stringify the output
:type stringify: bool
stringify: bool, optional
Stringify the output
:param compression_level: Compression level, typically 1-9
:type compression_level: int
compression_level: int, optional
Compression level, typically 1-9
data_url_prefix: str, optional
dataURL prefix
Returns
-------
bytes
Output compressed binary
:param data_url_prefix: dataURL prefix
:type data_url_prefix: str
:return: Output compressed binary
:rtype: bytes
"""
func = environment_dispatch("itkwasm_compress_stringify", "compress_stringify_async")
output = await func(input, stringify=stringify, compression_level=compression_level, data_url_prefix=data_url_prefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@ def parse_string_decompress(
) -> bytes:
"""Given a binary or string produced with compress-stringify, decompress and optionally base64 decode.
Parameters
----------
:param input: Compressed input
:type input: bytes
input: bytes
Compressed input
parse_string: bool, optional
Parse the input string before decompression
Returns
-------
bytes
Output decompressed binary
:param parse_string: Parse the input string before decompression
:type parse_string: bool
:return: Output decompressed binary
:rtype: bytes
"""
func = environment_dispatch("itkwasm_compress_stringify", "parse_string_decompress")
output = func(input, parse_string=parse_string)
Expand Down
Loading

0 comments on commit 413201e

Please sign in to comment.