Skip to content

Commit

Permalink
Add notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
wannaphong committed Apr 8, 2024
1 parent b876065 commit b9bed65
Show file tree
Hide file tree
Showing 10 changed files with 5,915 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy Docs dev
on:
push:
branches:
- master

jobs:
release:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
sudo apt install pandoc libicu-dev
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build sphinx documentation
run: |
make html
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/html
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
20 changes: 20 additions & 0 deletions 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)
25 changes: 25 additions & 0 deletions clean_directory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# 1. Delete files in the pareent directory: /pythainlp/tutorials/*.*

for f in `curl --list-only --ipv4 ftp://$1:$2@thainlp.org/public_html/pythainlp/tutorials/`; do
# Delete each file individually
if [[ -f $f ]]; then
echo "deleting: $f"
curl --ipv4 ftp://$1:$2@thainlp.org -Q "DELE public_html/pythainlp/tutorials/$f"
fi
done

# 2. Delete files in the sub directories: notebooks, _images, _sources, _static

SUB_DIRECTORIES=(notebooks _images _sources _static)

for directory in ${SUB_DIRECTORIES[*]}; do
echo "delete files in: $directory"
for f in `curl --list-only --ipv4 ftp://$1:$2@thainlp.org/public_html/pythainlp/tutorials/$directory/`; do
if [[ -f $f ]]; then
echo "-- deleting: $f"
curl --ipv4 ftp://$1:$2@thainlp.org -Q "DELE public_html/pythainlp/tutorials/$directory/$f"
fi
done
done
35 changes: 35 additions & 0 deletions 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

if "%1" == "" goto help

%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.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx
sphinx_rtd_theme
ipykernel
nbsphinx
sphinx-intl
3 changes: 3 additions & 0 deletions source/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wy-nav-content {
max-width: none;
}
104 changes: 104 additions & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'pythainlp-tutorials'
copyright = '2019 - 2024, PyThaiNLP'
author = 'PyThaiNLP'

# The full version, including alpha/beta/rc tags
release = '0.1'


# -- Get version information and date from Git ----------------------------

try:
from subprocess import check_output
release = check_output(['git', 'describe', '--tags', '--always'])
release = release.decode().strip()
today = check_output(['git', 'show', '-s', '--format=%ad', '--date=short'])
today = today.decode().strip()
except Exception:
release = '<unknown>'
today = '<unknown date>'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'nbsphinx',
'sphinx.ext.mathjax',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '**.ipynb_checkpoints', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom css file
html_css_files = ["style.css"]

# Don't add .txt suffix to source files (available for Sphinx >= 1.5):
html_sourcelink_suffix = ''

nbsphinx_prolog = r"""
{% set docname = env.doc2path(env.docname, base=None) %}
{% set docname = docname.split('/')[1] %}
.. only:: html
.. role:: raw-html(raw)
:format: html
.. nbinfo::
Interactive online version:
:raw-html:`<a target="_blank" href="https://mybinder.org/v2/gh/pythainlp/tutorials/master?filepath=source/notebooks/{{ docname }}"><img alt="Binder badge" src="https://mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>`
:raw-html:`<a target="_blank" href="https://colab.research.google.com/github/PyThaiNLP/tutorials/blob/master/source/notebooks/{{ docname }}"><img alt="Google Colab badge" src="https://colab.research.google.com/assets/colab-badge.svg" style="vertical-align:text-bottom"></a>`
.. raw:: latex
\nbsphinxstartnotebook{The following section was created from
\texttt{\strut{}{{ docname }}}:}
"""

nbsphinx_epilog = r"""
.. raw:: latex
\nbsphinxstopnotebook{\hfill End of notebook.}
"""

master_doc = 'index'
locale_dirs = ['locale/'] # path is example but recommended.
gettext_compact = False # optional.
23 changes: 23 additions & 0 deletions source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. pythainlp-tutorials documentation master file, created by
sphinx-quickstart on Wed Jul 17 14:48:23 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to PyThaiNLP Tutorials
===============================================
PyThaiNLP is a Python library for Thai Natural Language Processing.

.. toctree::
:glob:
:maxdepth: 1
:caption: Tutorials:

notebooks/*

`Apache Software License 2.0 <https://apache.org/licenses/LICENSE-2.0>`_

Maintained by the PyThaiNLP team.

* See source code of these tutorials at https://github.com/PyThaiNLP/tutorials
* Main PyThaiNLP development at https://github.com/PyThaiNLP/pythainlp
* PyThaiNLP website at https://pythainlp.github.io
Loading

0 comments on commit b9bed65

Please sign in to comment.