Skip to content

Commit

Permalink
sphinx-apidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Oct 31, 2024
1 parent 0a0b7a6 commit 0eb91d9
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 14 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ jobs:
- name: Build
run: |
for lang in ja en; do
cd ${GITHUB_WORKSPACE}/main/doc/${lang}
make html
make latexpdf
done
cd ${GITHUB_WORKSPACE}/main/doc
sh ./make.sh
16 changes: 11 additions & 5 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- deploy_api_docs
# - develop
# - ghactions
# - '*-autodoc'
Expand Down Expand Up @@ -48,11 +49,8 @@ jobs:
- name: Build
run: |
for lang in ja en; do
cd ${GITHUB_WORKSPACE}/main/doc/${lang}
make html
make latexpdf
done
cd ${GITHUB_WORKSPACE}/main/doc
sh ./make.sh --latex
- name: Deploy Configuration
run: |
Expand All @@ -71,6 +69,8 @@ jobs:
is_tag=NO
TARGET_NAME="${TARGET_NAME%-autodoc}"
test "_$(echo ${GITHUB_REF:-'//'} | cut -d/ -f2)" = "_tags" && is_tag=YES
# JA & EN manuals
for lang in ja en; do
rm -rf "gh-pages/manual/${TARGET_NAME}/${lang}"
mkdir -p "gh-pages/manual/${TARGET_NAME}"
Expand All @@ -80,6 +80,12 @@ jobs:
:
fi
done
# API manual
rm -rf "gh-pages/manual/${TARGET_NAME}/api"
mkdir -p "gh-pages/manual/${TARGET_NAME}"
cp -r "main/doc/api/build/html" "gh-pages/manual/${TARGET_NAME}/api"
cd gh-pages
git config --local user.name "${GIT_USER}"
git config --local user.email "${GIT_EMAIL}"
Expand Down
20 changes: 20 additions & 0 deletions doc/api/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 doc/api/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
2 changes: 2 additions & 0 deletions doc/api/source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
odatse*.rst
modules.rst
46 changes: 46 additions & 0 deletions doc/api/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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

import sys

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'ODAT-SE API'
copyright = '2020-, ISSP, UTokyo'
author = '2DMAT Developers'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

sys.path.insert(0, "../../src")

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.todo",
"sphinx.ext.napoleon",
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "haiku"
html_static_path = ['_static']

# -- Options for todo extension ----------------------------------------------

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

autoclass_content = 'both'

napoleon_include_init_with_doc = True

21 changes: 21 additions & 0 deletions doc/api/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. ODAT-SE API documentation master file, created by
sphinx-quickstart on Thu Oct 31 10:18:29 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ODAT-SE API's documentation!
=======================================

.. toctree::
:maxdepth: 4
:caption: Contents:

odatse


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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
8 changes: 4 additions & 4 deletions doc/en/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = pyMC
# 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

Expand Down
29 changes: 29 additions & 0 deletions doc/make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if [ "_$1" == "_--latex" ]; then
BUILD_LATEX=ON
latexmk --version > /dev/null 2>&1 || { echo "Latexmk is not installed"; exit 1; }
else
BUILD_LATEX=OFF
fi

sphinx-build --version > /dev/null 2>&1 || { echo "Sphinx is not installed"; exit 1; }

DOCROOT=`pwd`

# user's manual
cd ${DOCROOT}/ja
make html
if [ $BUILD_LATEX = "ON" ]; then
make latexpdf
fi

cd ${DOCROOT}/en
make html
if [ $BUILD_LATEX = "ON" ]; then
make latexpdf
fi

# api
cd $DOCROOT
sphinx-apidoc -P -f -e -o ./api/source ../src/odatse/
cd api
make html

0 comments on commit 0eb91d9

Please sign in to comment.