Skip to content

Commit 261eee1

Browse files
author
Fangjun Kuang
authored
[doc] add doc for kaldi pybind. (#3967)
1 parent 756f490 commit 261eee1

File tree

9 files changed

+301
-0
lines changed

9 files changed

+301
-0
lines changed

src/pybind/doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
12.1 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* Force table wrap: https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html */
2+
/* override table width restrictions */
3+
@media screen and (min-width: 767px) {
4+
5+
.wy-table-responsive table td {
6+
/* !important prevents the common CSS stylesheets from overriding
7+
this as on RTD they are loaded after this stylesheet */
8+
white-space: normal !important;
9+
}
10+
11+
.wy-table-responsive {
12+
overflow: visible !important;
13+
}
14+
}

src/pybind/doc/conf.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
# NOTE(fangjun): we have to use `pip install sphinx_rtd_theme`
18+
# otherwise `import` will throw.
19+
import sphinx_rtd_theme
20+
21+
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = 'Kaldi Pybind'
26+
copyright = '2020, Kaldi Pybind Authors'
27+
author = 'Kaldi Pybind Authors'
28+
29+
30+
# -- General configuration ---------------------------------------------------
31+
32+
# Add any Sphinx extension module names here, as strings. They can be
33+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34+
# ones.
35+
extensions = [
36+
'sphinx.ext.autodoc',
37+
'sphinx.ext.autosummary',
38+
'sphinx.ext.mathjax',
39+
'sphinx.ext.napoleon',
40+
'sphinx.ext.todo',
41+
'sphinx.ext.viewcode',
42+
]
43+
44+
# Add any paths that contain templates here, relative to this directory.
45+
templates_path = ['_templates']
46+
47+
# List of patterns, relative to source directory, that match files and
48+
# directories to ignore when looking for source files.
49+
# This pattern also affects html_static_path and html_extra_path.
50+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
51+
52+
# The suffix(es) of source filenames.
53+
# You can specify multiple suffix as a list of string:
54+
#
55+
source_suffix = '.rst'
56+
57+
# The master toctree document.
58+
master_doc = 'index'
59+
60+
# The name of the Pygments (syntax highlighting) style to use.
61+
pygments_style = 'sphinx'
62+
63+
64+
# -- Options for HTML output -------------------------------------------------
65+
66+
# The theme to use for HTML and HTML Help pages. See the documentation for
67+
# a list of builtin themes.
68+
#
69+
# html_theme = 'alabaster'
70+
html_theme = 'sphinx_rtd_theme'
71+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
72+
smartquotes = False
73+
74+
# Add any paths that contain custom static files (such as style sheets) here,
75+
# relative to this directory. They are copied after the builtin static files,
76+
# so a file named "default.css" will overwrite the builtin "default.css".
77+
html_static_path = ['_static']
78+
79+
html_context = {
80+
'css_files': [
81+
'_static/theme_overrides.css', # override wide tables in RTD theme
82+
],
83+
}
84+
85+
html_show_sourcelink = False

src/pybind/doc/developers.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Introduction
2+
3+
We use [Sphinx](https://www.sphinx-doc.org/en/master/) to generate
4+
documentation for kaldi pybind. This document describes the steps
5+
for **developers** to build the environment for generating
6+
documentation.
7+
8+
End users are advised to
9+
visit [TODO(fangjun):fill this](https://kaldi-asr.org/doc/)
10+
for pre-generated documentation.
11+
12+
13+
# Install Sphinx
14+
15+
First, install `sphinx` via `pip`
16+
17+
```sh
18+
pip install -U sphinx
19+
```
20+
21+
To check that `sphinx` is installed successfully, the
22+
command `sphinx-build --version` should print the version
23+
of the installed `sphinx`.
24+
25+
We will use the [theme](https://sphinx-rtd-theme.readthedocs.io/en/stable/)
26+
from <http://www.readthedocs.org/>, which can be installed by
27+
28+
```sh
29+
pip install sphinx_rtd_theme
30+
```
31+
32+
# Setup the template
33+
34+
Run `sphinx-quickstart` to generate the following files and directories:
35+
36+
```
37+
.
38+
├── _build
39+
├── conf.py
40+
├── index.rst
41+
├── make.bat
42+
├── Makefile
43+
├── _static
44+
└── _templates
45+
46+
3 directories, 4 files
47+
```
48+
49+
# Build the documentation
50+
51+
```bash
52+
make html
53+
```
54+
55+
The html files are generated in the directory `_build/html`.
56+
Copy all the files in that directory to the server which is
57+
hosting html pages.
58+
59+
To view the generated documentation in a web browser locally:
60+
61+
```bash
62+
cd _build/html
63+
python3 -m http.server
64+
```
65+
66+
It should print `Serving HTTP on 0.0.0.0 port 8000`.
67+
Then go to your browser and enter `http://localhost:8000`
68+
or `http://<your-server-ip>:8000` to view the
69+
generated documentation.

src/pybind/doc/getting_started.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
Getting Started
3+
###############
4+
5+
6+
Compiling Kaldi Pybind
7+
======================
8+
9+
First, you have to install Kaldi. You can find
10+
detailed information for Kaldi installation
11+
from
12+
`http://kaldi-asr.org/doc/install.html <http://kaldi-asr.org/doc/install.html>`_.
13+
14+
.. Note::
15+
16+
Kaldi Pybind is still under active development and has not
17+
yet been merged into the master branch. You should checkout
18+
the `pybind11` branch before compilation.
19+
20+
.. Note::
21+
22+
We support **ONLY** Python3. If you are still using Python2,
23+
please upgrade to Python3. Python3.5 is known to work.
24+
25+
The following is a quick start:
26+
27+
.. code-block:: bash
28+
29+
git clone https://github.com/kaldi-asr/kaldi.git
30+
cd kaldi
31+
git checkout pybind11
32+
cd tools
33+
extras/check_dependencies.sh
34+
make -j4
35+
cd ../src
36+
./configure --shared
37+
make -j4
38+
cd pybind
39+
pip install pybind11
40+
make
41+
make test
42+

src/pybind/doc/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. Kaldi Pybind documentation master file, created by
2+
sphinx-quickstart on Sun Mar 1 21:25:32 2020.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
.. image:: _static/KaldiTextAndLogoSmall.png
7+
:alt: Kaldi logo
8+
:width: 320px
9+
:align: center
10+
11+
-----------
12+
13+
Welcome to Kaldi Pybind's documentation!
14+
========================================
15+
16+
.. toctree::
17+
:maxdepth: 2
18+
19+
introduction
20+
getting_started

src/pybind/doc/introduction.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
About Kaldi Pybind
3+
#######################
4+
5+
.. image:: _static/KaldiTextAndLogoSmall.png
6+
:alt: Kaldi logo
7+
:width: 240px
8+
:align: right
9+
10+
11+
Kaldi Pybind is a Python wrapper for Kaldi
12+
using `Pybind11 <https://github.com/pybind/pybind11>`_.
13+
14+
Kaldi Pybind is still under active development.
15+
Everything related to Kaldi Pybind is put in the
16+
`pybind11 branch <https://github.com/kaldi-asr/kaldi/tree/pybind11>`_.

src/pybind/doc/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

0 commit comments

Comments
 (0)