Skip to content

Commit

Permalink
Merge pull request #22 from fraya/infrastructure
Browse files Browse the repository at this point in the history
Infrastructure and documentation update
  • Loading branch information
fraya committed Jun 16, 2024
2 parents d6dabb6 + c1d891c commit d8ee258
Show file tree
Hide file tree
Showing 13 changed files with 536 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
44 changes: 44 additions & 0 deletions .github/workflows/build-and-check-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and check documentation

on:
pull_request:
# all branches
paths:
- 'documentation/**'

# This enables the Run Workflow button on the Actions tab.
workflow_dispatch:

# 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: json
path: documentation/build/html/
56 changes: 56 additions & 0 deletions .github/workflows/build-and-deploy-documentation.yml
Original file line number Diff line number Diff line change
@@ -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: json
path: documentation/build/html/

- name: Bypassing Jekyll on GH Pages
run: sudo touch documentation/build/html/.nojekyll

- name: Deploy docs to GH pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: documentation/build/html
23 changes: 19 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: build-and-test
on:
push:
# all branches
paths-ignore:
- 'documentation/**'
pull_request:
branches:
- main
- master
paths-ignore:
- 'documentation/**'

# This enables the Run Workflow button on the Actions tab.
workflow_dispatch:
Expand All @@ -16,11 +20,22 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- uses: dylan-lang/install-opendylan@v2
- uses: actions/checkout@v4

- name: Install Opendylan
uses: dylan-lang/install-opendylan@v3

- name: Update dependencies
run: dylan update

- name: Build json-test-suite
run: ./dylan-compiler -build -jobs 2 json-test-suite
run: dylan build json-test-suite

- name: Run json-test-suite
run: _build/bin/json-test-suite
run: _build/bin/json-test-suite --progress none --report surefire > _build/TEST-json.xml

- name: Publish Test Report
if: success() || failure()
uses: mikepenz/action-junit-report@v4
with:
report_paths: '**/_build/TEST-*.xml'
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
_build
# backup files
*~
*.bak
.DS_Store

# project file
*.hdp

# documentation build directory
/documentation/build/

# compiler build directory
/_build/

# dylan tool package cache
/_packages/

# package registry folder
/registry/
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# JSON

Opendylan library to parse the JSON standard file format.

## Install

Add `json` to your project dependencies

```json
"dependencies": [ "json" ],
```

Update the dependencies:

```
dylan update
```

## Usage

Add `use json;` in the library and module section of your
`library.dylan` file.

This library exports the following methods:

- `parse-json` and
- `print-json`

### Parse JSON

An example of usage of `parse-json`:

```dylan
let json = """
{
"a": 1,
"b": 2
}
""";
let json-table = parse-json(json);
format-out("a = %d", json-table["a"]);
```

[Run this code](https://play.opendylan.org/shared/d123253033bda66a) in
https://play.opendylan.org

### Print JSON

`print-json` is used to pretty print a `table` in JSON format,
following the previous example:

```dylan
print-json(json-table, *standard-output*, indent: 2);
```

[Run a complete example](https://play.opendylan.org/shared/06af84b39fab129b) in
https://play.opendylan.org
20 changes: 20 additions & 0 deletions documentation/Makefile
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 = 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)
35 changes: 35 additions & 0 deletions documentation/make.bat
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=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
35 changes: 35 additions & 0 deletions documentation/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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

project = 'Json'
copyright = '2024, Dylan Hackers'
author = 'Dylan Hackers'
release = '1.1.1'

# -- 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'

# -- 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']

# Ignore certification verification
tls_verify = False
38 changes: 38 additions & 0 deletions documentation/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
json
====

.. current-library: json
.. toctree::
:maxdepth: 2
:hidden:

reference

This library provides essential functionality for working with JSON
data. JSON (JavaScript Object Notation) is a lightweight data
interchange format that is easy for humans to read and write, and easy
for machines to parse and generate.

The json library offers two primary methods to facilitate the
conversion between JSON strings and Dylan data structures, making it
straightforward to integrate JSON data handling into your Open Dylan
applications. This methods are:

:gf:`parse-json`
This method takes a JSON-formatted string and converts it into an
Open Dylan table. This function is useful when you need to process
JSON data received from external sources, such as web APIs or
configuration files.

:gf:`print-json`
The ``print-json`` function takes an Open Dylan table and converts
it into a formatted JSON string. This is useful for serializing
Open Dylan data structures into JSON format for storage,
transmission, or display purposes.


Indices and tables
==================

* :ref:`genindex`
Loading

0 comments on commit d8ee258

Please sign in to comment.