Skip to content

Commit

Permalink
Add support for publishing documentation (#28)
Browse files Browse the repository at this point in the history
fix #27

Documentation URLs:

  * https://datafusion-contrib.github.io/datafusion-c/
    * Redirect to https://datafusion-contrib.github.io/datafusion-c/latest/
  * https://datafusion-contrib.github.io/datafusion-c/${VERSION}/
    * Documentation for ${VERSION}
  * https://datafusion-contrib.github.io/datafusion-c/latest/
    * Copy of the latest
      https://datafusion-contrib.github.io/datafusion-c/${VERSION}/
  * https://datafusion-contrib.github.io/datafusion-c/main/
    * Documentation for the main branch

Documentation tools:

  * /
    * Sphinx
      * Base contents and layout
      * Theme: pydata_sphinx_theme
    * Doxygen
      * DataFusion C's API reference
      * Comments for Doxygen are written in src/capi.rs
      * Integrated into Sphinx by Breathe
  * /glib/
    * Gi-DocGen
      * No sphinx integration
      * Just hyper linked each other

Deployment:

  * The gh-pages branch is used
  * The gh-pages branch is updated automatically by GitHub Actions
  • Loading branch information
kou committed Aug 21, 2022
1 parent acec3e0 commit eeb2644
Show file tree
Hide file tree
Showing 37 changed files with 1,125 additions and 89 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ jobs:
./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt update
sudo apt install -y -V \
gtk-doc-tools \
libarrow-glib-dev \
libgirepository1.0-dev \
ninja-build \
valac
pip install meson
echo "GI_TYPELIB_PATH=${HOME}/local/lib/girepository-1.0" >> ${GITHUB_ENV}
echo "LD_LIBRARY_PATH=${PWD}/build:${HOME}/local/lib:${LD_LIBRARY_PATH}" >> ${GITHUB_ENV}
- name: Prepare on macOS
if: |
Expand All @@ -123,6 +123,7 @@ jobs:
brew update --preinstall
brew bundle --file=Brewfile
echo "DYLD_LIBRARY_PATH=${PWD}/build:${HOME}/local/lib:${DYLD_LIBRARY_PATH}" >> ${GITHUB_ENV}
echo "GI_TYPELIB_PATH=${HOME}/local/lib/girepository-1.0" >> ${GITHUB_ENV}
echo "XML_CATALOG_FILES=$(brew --prefix)/etc/xml/catalog" >> ${GITHUB_ENV}
# - name: Prepare on Windows
# if: |
Expand Down Expand Up @@ -155,8 +156,8 @@ jobs:
matrix.runs-on != 'windows-latest'
run: |
meson setup \
--libdir=lib \
--prefix=${HOME}/local \
-Ddoc=true \
-Dvapi=${{ matrix.runs-on == 'ubuntu-latest' }} \
-Dwerror=true \
build \
Expand Down Expand Up @@ -188,11 +189,6 @@ jobs:
matrix.runs-on != 'windows-latest'
run: |
build/example/sql-c
- name: Run Vala example
if: |
matrix.runs-on == 'ubuntu-latest'
run: |
build/example/sql-vala
- name: Run Python example
if: |
matrix.runs-on != 'windows-latest'
Expand All @@ -205,3 +201,24 @@ jobs:
run: |
cd build
../example/sql.rb
- name: Run GLib C example
if: |
matrix.runs-on != 'windows-latest'
run: |
build/example/sql-glib-c
- name: Run GLib Vala example
if: |
matrix.runs-on == 'ubuntu-latest'
run: |
build/example/sql-glib-vala
- name: Run GLib Python example
if: |
matrix.runs-on == 'ubuntu-latest'
run: |
pip install PyGObject
example/sql-glib.py
- name: Run GLib Ruby example
if: |
matrix.runs-on == 'ubuntu-latest'
run: |
bundle exec example/sql-glib.rb
125 changes: 125 additions & 0 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copyright 2022 Sutou Kouhei <kou@clear-code.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Document

on:
- push
- pull_request

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Prepare
run: |
sudo apt update
sudo apt install -y -V \
ca-certificates \
lsb-release \
wget
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt install -y -V \
./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt update
sudo apt install -y -V \
doxygen \
gtk-doc-tools \
libarrow-glib-dev \
libgirepository1.0-dev \
ninja-build \
valac
pip install \
Jinja2 \
Pygments \
Sphinx \
breathe \
gi-docgen \
meson \
pydata_sphinx_theme
case ${GITHUB_REF} in
refs/tags/*)
version=${GITHUB_REF#refs/tags/}
;;
*)
version=main
;;
esac
echo "VERSION=${version}" >> ${GITHUB_ENV}
- uses: actions-rs/toolchain@v1
id: rust-toolchain
with:
override: true
toolchain: stable
- name: Cache Cargo
uses: actions/cache@v2
with:
path: ~/.cargo
key: cargo-doc-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml') }}
- name: Install cargo-c
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-c
- name: Generate
run: |
meson setup \
--libdir=lib \
--prefix=${HOME}/local \
-Ddoc=true \
-Dsource-reference=${VERSION} \
-Dvapi=true \
-Dwerror=true \
build \
.
ninja -C build doc/html
cp -a build/doc/html/ ./
- uses: actions/upload-artifact@v3
with:
name: html
path: html/
- uses: actions/checkout@v3
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main')
with:
ref: gh-pages
path: gh-pages
- name: Deploy
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main')
run: |
rm -rf gh-pages/${VERSION}
cp -a build/doc/html/ gh-pages/${VERSION}
if [ "${VERSION}" != "main" ]; then
rm -rf gh-pages/latest
cp -a gh-pages/${VERSION} gh-pages/latest
fi
cd gh-pages
if [ "$(git status --porcelain)" != "" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m "Update by ${GITHUB_SHA}"
git push origin gh-pages
fi
doc_dir=gh-pages/${VERSION}
2 changes: 1 addition & 1 deletion .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
env:
APT_TARGETS: ${{ matrix.target }}
YUM_TARGETS: ${{ matrix.target }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: package-${{ matrix.id }}
path: package/${{ matrix.task-namespace }}/repositories/
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

/Cargo.lock
/target
/package/*.tar.gz
/package/apt/build.sh
/package/apt/env.sh
Expand All @@ -23,3 +22,4 @@
/package/yum/env.sh
/package/yum/repositories/
/package/yum/tmp/
/target
70 changes: 1 addition & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,72 +18,4 @@

C language bindings for DataFusion.

## How to build

Install dependencies:

```bash
cargo install cargo-c
```

### Without GLib API

```bash
cargo build
```

### With GLib API

```bash
meson setup build .
meson install -C build
```

#### Examples

See `example/sql.c` for C.

```console
$ build/example/sql-c
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

See `example/sql.py` for Python.

```console
$ LD_LIBRARY_PATH=$PWD/build example/sql.py
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

See `example/sql.rb` for Ruby.

```console
$ LD_LIBRARY_PATH=$PWD/build example/sql.rb
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

See `example/sql.vala` for Vala.

You need to add `-Dvapi=true` option to `meson setup` to enable Vala
support.

```console
$ build/example/sql-vala
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```
See https://datafusion-contrib.github.io/datafusion-c/ for details.
2 changes: 1 addition & 1 deletion cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

documentation_length = "full"
language = "C"

pragma_once = true
1 change: 1 addition & 0 deletions datafusion-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pkgconfig.generate(libdatafusion_glib,
filebase: 'datafusion-glib',
name: 'DataFusion GLib',
requires: ['datafusion', 'arrow-glib', 'gobject-2.0'],
variables: pkgconfig_variables,
version: version)

if have_gi
Expand Down
1 change: 1 addition & 0 deletions dev/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dev/release/rat_exclude_files.txt
doc/source/_static/switcher.json
package/debian/compat
package/debian/control
package/debian/gir1.2-datafusion-10.0.install
Expand Down
21 changes: 21 additions & 0 deletions doc/Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 Sutou Kouhei <kou@clear-code.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

DOXYFILE_ENCODING = UTF-8
EXTENSION_MAPPING = h=C
GENERATE_HTML = NO
GENERATE_LATEX = NO
GENERATE_LEGEND = NO
GENERATE_XML = YES
PROJECT_NAME = "DataFusion C"
34 changes: 34 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Sutou Kouhei <kou@clear-code.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -j auto
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
# $(O) is meant as a shortcut for $(SPHINXOPTS).
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

html:
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help html

Loading

0 comments on commit eeb2644

Please sign in to comment.