diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..0d08e26
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
+
+version: 2
+updates:
+ - package-ecosystem: "github-actions" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
new file mode 100644
index 0000000..d7fd321
--- /dev/null
+++ b/.github/workflows/build-and-test.yml
@@ -0,0 +1,38 @@
+name: Build and test
+
+on:
+ push:
+ # all branches
+ pull_request:
+ # all branches
+
+ # This enables the Run Workflow button on the Actions tab.
+ workflow_dispatch:
+
+jobs:
+ build-and-test:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Install Opendylan
+ uses: dylan-lang/install-opendylan@v3
+
+ - name: Add zlib dev dependency
+ run: sudo apt-get install -y zlib1g-dev
+
+ - name: Download dependencies
+ run: dylan update
+
+ - name: Build tests
+ run: dylan build zlib-test-suite
+
+ - name: Run tests
+ run: _build/bin/zlib-test-suite --progress none --report surefire > _build/TEST-zlib.xml
+
+ - name: Publish Test Report
+ if: success() || failure()
+ uses: mikepenz/action-junit-report@v4
+ with:
+ report_paths: '**/_build/TEST-*.xml'
diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml
new file mode 100644
index 0000000..0e37f67
--- /dev/null
+++ b/.github/workflows/build-docs.yml
@@ -0,0 +1,56 @@
+name: Build and deploy documentation
+
+on:
+ push:
+ # all branches
+ paths:
+ - 'documentation/**'
+
+ # This enables the Run Workflow button on the Actions tab.
+ workflow_dispatch:
+
+# https://github.com/JamesIves/github-pages-deploy-action#readme
+permissions:
+ contents: write
+
+# Set DYLAN environment variable to GITHUB_WORKSPACE so packages are
+# installed in ../../_packages relative to documentation's Makefile
+env:
+ DYLAN: ${{ github.workspace }}
+
+jobs:
+
+ build-and-deploy:
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Check links
+ uses: addnab/docker-run-action@v3
+ with:
+ image: ghcr.io/fraya/dylan-docs
+ options: -v ${{ github.workspace }}/documentation:/docs
+ run: make linkcheck
+
+ - name: Build docs with Furo theme
+ uses: addnab/docker-run-action@v3
+ with:
+ image: ghcr.io/fraya/dylan-docs
+ options: -v ${{ github.workspace }}/documentation:/docs
+ run: make html
+
+ - name: Upload html artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: zlib-doc-html
+ path: documentation/build/html/
+
+ - name: Bypassing Jekyll on GH Pages
+ run: sudo touch documentation/build/html/.nojekyll
+
+ - name: Deploy documents to GH pages
+ uses: JamesIves/github-pages-deploy-action@v4
+ with:
+ folder: documentation/build/html
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..17d2098
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+# Development directories
+
+/_build/
+/_packages/
+/registry/
+
+# Backup files
+
+*~
+
+/documentation/build/
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f8765d8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright 2024 dylan-hackers
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+“Software”), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..090b924
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,31 @@
+Zlib
+====
+
+Opendylan binding around Zlib library.
+
+Building
+--------
+
+Install development libraries
+
+.. code-block:: console
+
+ $ sudo apt install zlib1g-dev
+
+Download dependencies:
+
+.. code-block:: console
+
+ $ dylan update
+
+Build:
+
+.. code-block:: console
+
+ $ dylan build --all
+
+Run tests:
+
+.. code-block:: console
+
+ $ _build/bin/zlib-test-suite
diff --git a/documentation/Makefile b/documentation/Makefile
new file mode 100644
index 0000000..d0c3cbf
--- /dev/null
+++ b/documentation/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 = source
+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/documentation/make.bat b/documentation/make.bat
new file mode 100644
index 0000000..747ffb7
--- /dev/null
+++ b/documentation/make.bat
@@ -0,0 +1,35 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set SOURCEDIR=source
+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/documentation/source/conf.py b/documentation/source/conf.py
new file mode 100644
index 0000000..5b4268c
--- /dev/null
+++ b/documentation/source/conf.py
@@ -0,0 +1,33 @@
+# 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
+
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
+
+import sys, os
+sys.path.insert(0, os.path.abspath('../../_packages/sphinx-extensions/current/src/sphinxcontrib'))
+
+import dylan.themes as dylan_themes
+extensions = ['dylan.domain']
+
+templates_path = ['_templates']
+exclude_patterns = []
+
+primary_domain = 'dylan'
+
+
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
+project = 'Zlib'
+copyright = '2024, Dylan Hackers'
+author = 'Dylan Hackers'
+release = '0.1.0'
+
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
+
+html_theme = 'furo'
+html_static_path = ['_static']
diff --git a/documentation/source/index.rst b/documentation/source/index.rst
new file mode 100644
index 0000000..75057f3
--- /dev/null
+++ b/documentation/source/index.rst
@@ -0,0 +1,17 @@
+Welcome to Zlib's documentation!
+================================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+ :hidden:
+
+ reference
+
+This is the beginning of a binding to the `Zlib
+`_ library.
+
+Indices and tables
+==================
+
+* :ref:`genindex`
diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst
new file mode 100644
index 0000000..471c98a
--- /dev/null
+++ b/documentation/source/reference.rst
@@ -0,0 +1,33 @@
+Reference
+=========
+
+.. current-library:: zlib
+.. current-module:: zlib
+
+Utility functions
+-----------------
+
+These functions are implemented on top of the basic zlib
+stream-oriented functions. To simplify the interface, some default
+options are assumed (compression level and memory usage).
+
+
+.. function:: compress
+
+ Compress a string.
+
+ :signature: compress *string* => (compressed-string)
+
+ :parameter string: String to compress. An instance of :drm:``
+ :value compressed-string: An instance of :drm:``
+
+ :description:
+
+ Compress the source string into a new string. If there is a problem
+ in the compression process it raises an error.
+
+ :example:
+
+ .. code-block:: dylan
+
+ let compressed = compress("Hello");
diff --git a/dylan-package.json b/dylan-package.json
new file mode 100644
index 0000000..2a1c806
--- /dev/null
+++ b/dylan-package.json
@@ -0,0 +1,15 @@
+{
+ "dependencies": [ ],
+ "dev-dependencies": [
+ "testworks",
+ "sphinx-extensions"
+ ],
+ "description": "Bindings to Zlib library",
+ "name": "zlib",
+ "version": "0.1.0",
+ "url": "https://github.com/dylan-lang/zlib",
+ "keywords": [ "zlib", "binding" ],
+ "contact": "dylan-lang@google.com",
+ "license": "MIT",
+ "license-url": "https://opensource.org/license/mit"
+}
diff --git a/library.dylan b/library.dylan
deleted file mode 100644
index bad31a2..0000000
--- a/library.dylan
+++ /dev/null
@@ -1,13 +0,0 @@
-module: dylan-user
-
-define library zlib
- use common-dylan;
- use c-ffi;
- export zlib;
-end library;
-
-define module zlib
- use common-dylan;
- use c-ffi;
- export compress;
-end module;
diff --git a/source/library.dylan b/source/library.dylan
new file mode 100644
index 0000000..1a66ecf
--- /dev/null
+++ b/source/library.dylan
@@ -0,0 +1,26 @@
+module: dylan-user
+
+define library zlib
+ use common-dylan;
+ use c-ffi;
+
+ export
+ zlib,
+ zlib-impl;
+end library;
+
+define module zlib
+ create
+ compress;
+end module;
+
+define module zlib-impl
+ use common-dylan;
+ use c-ffi;
+
+ use zlib;
+
+ export
+ zlib-compress,
+ zlib-compress-bound;
+end module;
diff --git a/main.dylan b/source/zlib.dylan
similarity index 88%
rename from main.dylan
rename to source/zlib.dylan
index 2a969fb..57030ca 100644
--- a/main.dylan
+++ b/source/zlib.dylan
@@ -1,4 +1,4 @@
-module: zlib
+module: zlib-impl
define C-function zlib-compress
parameter destination :: ;
@@ -26,7 +26,3 @@ define function compress (string :: )
result;
end if;
end;
-/*
-define variable foobar = "foobar";
-format-out("%= => %=\n", foobar, compress(foobar));
-*/
diff --git a/source/zlib.lid b/source/zlib.lid
new file mode 100644
index 0000000..806c568
--- /dev/null
+++ b/source/zlib.lid
@@ -0,0 +1,5 @@
+Library: zlib
+Target-Type: dll
+C-Libraries: -lz
+Files: library
+ zlib
diff --git a/tests/library.dylan b/tests/library.dylan
new file mode 100644
index 0000000..7ed6223
--- /dev/null
+++ b/tests/library.dylan
@@ -0,0 +1,16 @@
+Module: dylan-user
+
+define library zlib-test-suite
+ use common-dylan;
+ use testworks;
+ use io;
+ use zlib;
+end library;
+
+define module zlib-test-suite
+ use common-dylan;
+ use testworks;
+ use format-out;
+ use zlib;
+ use zlib-impl;
+end module;
diff --git a/tests/zlib-test-suite.dylan b/tests/zlib-test-suite.dylan
new file mode 100644
index 0000000..86e4932
--- /dev/null
+++ b/tests/zlib-test-suite.dylan
@@ -0,0 +1,10 @@
+Module: zlib-test-suite
+
+define test compress-test ()
+ // stupid test until uncompress is working
+ let compressed = compress("A horse, a horse, my kingdom for a horse");
+ expect-equal(30, compressed.size);
+end test;
+
+// Use `_build/bin/hello-world-test-suite --help` to see options.
+run-test-application()
diff --git a/tests/zlib-test-suite.lid b/tests/zlib-test-suite.lid
new file mode 100644
index 0000000..7d6af49
--- /dev/null
+++ b/tests/zlib-test-suite.lid
@@ -0,0 +1,4 @@
+Library: zlib-test-suite
+Files: library
+ zlib-test-suite
+Target-Type: executable
diff --git a/zlib.lid b/zlib.lid
deleted file mode 100644
index c659072..0000000
--- a/zlib.lid
+++ /dev/null
@@ -1,5 +0,0 @@
-library: zlib
-executable: zlib
-c-libraries: -lz
-files: library
- main