From 413201e1b9533634ac3c3556676cf815ace9094e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Apr 2023 18:23:04 -0400 Subject: [PATCH] feat(bindgen): Generate Python docs/ --- .../compress_stringify_async.py | 28 +++---- .../parse_string_decompress_async.py | 20 ++--- .../compress_stringify.py | 28 +++---- .../parse_string_decompress.py | 20 ++--- .../itkwasm-compress-stringify/docs/Makefile | 20 +++++ .../docs/_static/favicon.png | Bin 0 -> 13605 bytes .../docs/_static/logo.svg | 1 + .../itkwasm-compress-stringify/docs/conf.py | 55 ++++++++++++++ .../itkwasm-compress-stringify/docs/index.md | 21 ++++++ .../itkwasm-compress-stringify/docs/make.bat | 35 +++++++++ .../docs/requirements.txt | 7 ++ .../compress_stringify.py | 28 +++---- .../compress_stringify_async.py | 28 +++---- .../parse_string_decompress.py | 20 ++--- .../parse_string_decompress_async.py | 20 ++--- packages/core/python/itkwasm/docs/conf.py | 1 + src/bindgen/python-resources/docs/.gitignore | 2 + src/bindgen/python-resources/docs/Makefile | 20 +++++ .../python-resources/docs/_static/favicon.png | Bin 0 -> 7598 bytes .../python-resources/docs/_static/logo.svg | 1 + src/bindgen/python-resources/docs/conf.py | 56 ++++++++++++++ src/bindgen/python-resources/docs/index.md | 21 ++++++ src/bindgen/python-resources/docs/make.bat | 35 +++++++++ .../python-resources/docs/requirements.txt | 7 ++ src/bindgen/python.js | 71 +++++++++++++----- src/bindgen/typescript.js | 2 +- 26 files changed, 399 insertions(+), 148 deletions(-) create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/Makefile create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/_static/favicon.png create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/_static/logo.svg create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/conf.py create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/index.md create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/make.bat create mode 100644 packages/compress-stringify/python/itkwasm-compress-stringify/docs/requirements.txt create mode 100644 src/bindgen/python-resources/docs/.gitignore create mode 100644 src/bindgen/python-resources/docs/Makefile create mode 100644 src/bindgen/python-resources/docs/_static/favicon.png create mode 100644 src/bindgen/python-resources/docs/_static/logo.svg create mode 100644 src/bindgen/python-resources/docs/conf.py create mode 100644 src/bindgen/python-resources/docs/index.md create mode 100644 src/bindgen/python-resources/docs/make.bat create mode 100644 src/bindgen/python-resources/docs/requirements.txt diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/compress_stringify_async.py b/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/compress_stringify_async.py index 9baa6e56a..1f7e71278 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/compress_stringify_async.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/compress_stringify_async.py @@ -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 diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/parse_string_decompress_async.py b/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/parse_string_decompress_async.py index 033217758..62052fa7c 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/parse_string_decompress_async.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/parse_string_decompress_async.py @@ -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 diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/compress_stringify.py b/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/compress_stringify.py index fbcce227e..aad8a3f79 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/compress_stringify.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/compress_stringify.py @@ -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'))) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/parse_string_decompress.py b/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/parse_string_decompress.py index 7f973ff61..5a3bcbd94 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/parse_string_decompress.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify-wasi/itkwasm_compress_stringify_wasi/parse_string_decompress.py @@ -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'))) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/Makefile b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/Makefile new file mode 100644 index 000000000..d4bb2cbb9 --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/Makefile @@ -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) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/_static/favicon.png b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/_static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..bd1e535c6d807ba2313cae8722a4944bb28d46af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ress-stringify/docs/_static/logo.svg new file mode 100644 index 000000000..669a445ed --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/_static/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/conf.py b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/conf.py new file mode 100644 index 000000000..8ce2094e9 --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/conf.py @@ -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", +} \ No newline at end of file diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/index.md b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/index.md new file mode 100644 index 000000000..97c23b49e --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/index.md @@ -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 +``` \ No newline at end of file diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/make.bat b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/make.bat new file mode 100644 index 000000000..32bb24529 --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/make.bat @@ -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 diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/docs/requirements.txt b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/requirements.txt new file mode 100644 index 000000000..eaed1dc05 --- /dev/null +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/docs/requirements.txt @@ -0,0 +1,7 @@ +sphinx +furo +sphinx-autodoc2 +myst-parser +sphinx-copybutton +sphinxext-opengraph +sphinx-design \ No newline at end of file diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify.py b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify.py index 9439c33b0..6fc00fa0d 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify.py @@ -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) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify_async.py b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify_async.py index ba8e0c322..b990e9436 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify_async.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/compress_stringify_async.py @@ -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) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress.py b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress.py index 3ebc921e5..45eecef51 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress.py @@ -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) diff --git a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress_async.py b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress_async.py index 07e86a310..fc0b8a9cf 100644 --- a/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress_async.py +++ b/packages/compress-stringify/python/itkwasm-compress-stringify/itkwasm_compress_stringify/parse_string_decompress_async.py @@ -11,22 +11,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 """ func = environment_dispatch("itkwasm_compress_stringify", "parse_string_decompress_async") output = await func(input, parse_string=parse_string) diff --git a/packages/core/python/itkwasm/docs/conf.py b/packages/core/python/itkwasm/docs/conf.py index a705f0f26..16c751875 100644 --- a/packages/core/python/itkwasm/docs/conf.py +++ b/packages/core/python/itkwasm/docs/conf.py @@ -37,6 +37,7 @@ intersphinx_mapping = { "python": ("https://docs.python.org/3/", None), + "numpy": ("https://numpy.org/doc/stable", None), } html_theme = 'furo' diff --git a/src/bindgen/python-resources/docs/.gitignore b/src/bindgen/python-resources/docs/.gitignore new file mode 100644 index 000000000..1fabdc368 --- /dev/null +++ b/src/bindgen/python-resources/docs/.gitignore @@ -0,0 +1,2 @@ +_build/ +apidocs/ diff --git a/src/bindgen/python-resources/docs/Makefile b/src/bindgen/python-resources/docs/Makefile new file mode 100644 index 000000000..d4bb2cbb9 --- /dev/null +++ b/src/bindgen/python-resources/docs/Makefile @@ -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) diff --git a/src/bindgen/python-resources/docs/_static/favicon.png b/src/bindgen/python-resources/docs/_static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..168ca5128ae11ba817fda4be0f065ad10d830e7f GIT binary patch literal 7598 zcmZ`;WmFVE*WM+T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ikr`X8yZ+pe^fK3!ddVe z*ZP&dW6QJ)_i{bX0Vg7~YmuaXxGR39?Q`Z!O_$ZBj?lxy!*;&3?+Z{ULy|XTl*tmP zGO0mtN*CFZFjeH@ty&2PEZ1vg!WS7CbN*7y0-ov54Bu!cti+JnhX=pJ?w);Bki&>g z;MX0ivv6Y&W-`*h1ADrk45^S_9<(TA@0U?vLV8^Z{$5QINJGzm8Xvo-mh-&cw$X=T zTg~~_cP(hmwLMVQk~^i4=HDh}$QDvMVCgK4AD%3Nlwf&}q~{`6O8_Zoxj|nf;d;U53UF|CjvYNdSX^u^H8nML%BgS9*kSeYN8yd6t{6)kRo2_F zOG!!ne0;dQnQf-t+8H@fMzz#Ab3tZVTnahkLm9oy$7xCSuXF*trdK9&0c&ljgsqi~ zo|Qke*}ZO3QmrK=m{W2J)*vL+I#(bC5YNL!5Md?pA?+T@R(yV#`0n%z|{5ub~ z$x6TXi$onJpce^f{Il)V2ylZ;F*gyAwwetT- z=QB%;M~c#4`wJeF_5c0*Wb;-s^0u||wv)2)w0i=8u%NIApP&$*u#ldxpp=ND)C*A_ oK|v`&!F=0;s{aXaakG5~_5c3^CMC6rp8^12rMIuEUqM3u12yJ+mH+?% literal 0 HcmV?d00001 diff --git a/src/bindgen/python-resources/docs/_static/logo.svg b/src/bindgen/python-resources/docs/_static/logo.svg new file mode 100644 index 000000000..669a445ed --- /dev/null +++ b/src/bindgen/python-resources/docs/_static/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/bindgen/python-resources/docs/conf.py b/src/bindgen/python-resources/docs/conf.py new file mode 100644 index 000000000..a82423015 --- /dev/null +++ b/src/bindgen/python-resources/docs/conf.py @@ -0,0 +1,56 @@ +# 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 = '@bindgenProject@' +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": "../@bindgenPyPackage@", + "exclude_files": ["_version.py"], + }, +] +autodoc2_render_plugin = "myst" + +intersphinx_mapping = { + "python": ("https://docs.python.org/3/", None), + "numpy": ("https://numpy.org/doc/stable", 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": "@bindgenRepository@", + "source_branch": "main", + "source_directory": "docs", +} \ No newline at end of file diff --git a/src/bindgen/python-resources/docs/index.md b/src/bindgen/python-resources/docs/index.md new file mode 100644 index 000000000..118c44206 --- /dev/null +++ b/src/bindgen/python-resources/docs/index.md @@ -0,0 +1,21 @@ +@bindgenProject@ +======= + +> @bindgenPackageDescription@ + +[![@bindgenProject@ version](https://badge.fury.io/py/@bindgenPyPackage@.svg)](https://pypi.org/project/@bindgenPyPackage@/) + +## Installation + +```shell +pip install @bindgenProject@ +``` + +```{toctree} +:hidden: +:maxdepth: 3 +:caption: 📖 Reference + +apidocs/index.rst +itkwasm docs +``` \ No newline at end of file diff --git a/src/bindgen/python-resources/docs/make.bat b/src/bindgen/python-resources/docs/make.bat new file mode 100644 index 000000000..32bb24529 --- /dev/null +++ b/src/bindgen/python-resources/docs/make.bat @@ -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 diff --git a/src/bindgen/python-resources/docs/requirements.txt b/src/bindgen/python-resources/docs/requirements.txt new file mode 100644 index 000000000..eaed1dc05 --- /dev/null +++ b/src/bindgen/python-resources/docs/requirements.txt @@ -0,0 +1,7 @@ +sphinx +furo +sphinx-autodoc2 +myst-parser +sphinx-copybutton +sphinxext-opengraph +sphinx-design \ No newline at end of file diff --git a/src/bindgen/python.js b/src/bindgen/python.js index a4a45737b..a572cbc0c 100644 --- a/src/bindgen/python.js +++ b/src/bindgen/python.js @@ -240,36 +240,26 @@ function functionModuleReturnType(interfaceJson) { } function functionModuleDocstring(interfaceJson) { - let docstring = `"""${interfaceJson.description}` - docstring += ` - - Parameters - ---------- - + let docstring = `"""${interfaceJson.description} ` interfaceJson['inputs'].forEach((value) => { const pythonType = interfaceJsonTypeToPythonType.get(value.type) - docstring += ` ${snakeCase(value.name)}: ${pythonType}\n` - docstring += ` ${value.description}\n\n` + docstring += `\n :param ${snakeCase(value.name)}: ${value.description}\n` + docstring += ` :type ${snakeCase(value.name)}: ${pythonType}\n` }) interfaceJson['parameters'].forEach((value) => { if (value.name === "memory-io" || value.name === "version") { return } const pythonType = interfaceJsonTypeToPythonType.get(value.type) - docstring += ` ${snakeCase(value.name)}: ${pythonType}, optional\n` - docstring += ` ${value.description}\n\n` + docstring += `\n :param ${snakeCase(value.name)}: ${value.description}\n` + docstring += ` :type ${snakeCase(value.name)}: ${pythonType}\n` }) - docstring += ` - Returns - ------- - -` const jsonOutputs = interfaceJson['outputs'] jsonOutputs.forEach((value) => { const pythonType = interfaceJsonTypeToPythonType.get(value.type) - docstring += ` ${pythonType}\n` - docstring += ` ${value.description}\n\n` + docstring += `\n :return: ${value.description}\n` + docstring += ` :rtype: ${pythonType}\n` }) docstring += ' """' @@ -729,7 +719,49 @@ function emscriptenPackage(outputDir, buildDir, wasmBinaries, options) { }) } -function pythonBindings(outputDir, buildDir, wasmBinaries, options) { +function packageDocs(packageName, packageDir, pypackage, options) { + const docFiles = [ + 'requirements.txt', + 'Makefile', + 'make.bat', + path.join('_static', 'logo.svg'), + path.join('_static', 'favicon.png'), + ] + + const docsDir = path.join(packageDir, 'docs') + mkdirP(docsDir) + mkdirP(path.join(docsDir, '_static')) + docFiles.forEach((filePath) => { + const outputPath = path.join(docsDir, filePath) + if (!fs.existsSync(outputPath)) { + const contents = fs.readFileSync(bindgenResource(path.join('docs', filePath)), {encoding:'utf8', flag:'r'}) + fs.writeFileSync(outputPath, contents) + } + }) + + const confPyPath = path.join(docsDir, 'conf.py') + if (!fs.existsSync(confPyPath)) { + let confPyContent = fs.readFileSync(bindgenResource(path.join('docs', 'conf.py')), {encoding:'utf8', flag:'r'}) + confPyContent = confPyContent.replaceAll('@bindgenProject@', packageName) + confPyContent = confPyContent.replaceAll('@bindgenPyPackage@', pypackage) + const repository = options.repository ?? 'https://github.com/InsightSoftwareConsortium/itk-wasm' + confPyContent = confPyContent.replaceAll('@bindgenRepository@', repository) + fs.writeFileSync(confPyPath, confPyContent) + } + + const indexPath = path.join(docsDir, 'index.md') + if (!fs.existsSync(indexPath)) { + let indexContent = fs.readFileSync(bindgenResource(path.join('docs', 'index.md')), {encoding:'utf8', flag:'r'}) + indexContent = indexContent.replaceAll('@bindgenProject@', packageName) + indexContent = indexContent.replaceAll('@bindgenPyPackage@', pypackage) + indexContent = indexContent.replaceAll('@bindgenPackageDescription@', options.packageDescription) + const repository = options.repository ?? 'https://github.com/InsightSoftwareConsortium/itk-wasm' + indexContent = indexContent.replaceAll('@bindgenRepository@', repository) + fs.writeFileSync(indexPath, indexContent) + } +} + +function dispatchPackage(outputDir, buildDir, wasmBinaries, options) { const packageName = options.packageName const packageDir = path.join(outputDir, packageName) mkdirP(packageDir) @@ -744,6 +776,7 @@ function pythonBindings(outputDir, buildDir, wasmBinaries, options) { const async = true const sync = true packageDunderInit(outputDir, buildDir, wasmBinaries, packageName, options.packageDescription, packageDir, pypackage, async, sync) + packageDocs(packageName, packageDir, pypackage, options) wasmBinaries.forEach((wasmBinaryName) => { const { interfaceJson } = wasmBinaryInterfaceJson(outputDir, buildDir, wasmBinaryName) @@ -753,7 +786,7 @@ function pythonBindings(outputDir, buildDir, wasmBinaries, options) { } function bindgen (outputDir, buildDir, filteredWasmBinaries, options) { - pythonBindings(outputDir, buildDir, filteredWasmBinaries, options) + dispatchPackage(outputDir, buildDir, filteredWasmBinaries, options) wasiPackage(outputDir, buildDir, filteredWasmBinaries, options) emscriptenPackage(outputDir, buildDir, filteredWasmBinaries, options) } diff --git a/src/bindgen/typescript.js b/src/bindgen/typescript.js index 58cb9663d..4244d000e 100644 --- a/src/bindgen/typescript.js +++ b/src/bindgen/typescript.js @@ -566,7 +566,7 @@ function bindgen (outputDir, buildDir, filteredWasmBinaries, options) { const packageName = options.packageName readme += `# ${packageName}\n` readme += `\n[![npm version](https://badge.fury.io/js/${packageName.replace('/', '%2F')}.svg)](https://www.npmjs.com/package/${packageName})\n` - readme += `\n${options.packageDescription}\n` + readme += `\n> ${options.packageDescription}\n` readme += `\n## Installation\n \`\`\`sh npm install ${packageName}