[docs] Set up documentation structure with API reference

This commit is contained in:
OleehyO
2025-04-22 02:38:34 +00:00
parent 8aad53e079
commit 3eceedd96b
6 changed files with 245 additions and 0 deletions

20
docs/Makefile Normal file
View File

@@ -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
docs/make.bat Normal file
View File

@@ -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

0
docs/requirements.txt Normal file
View File

39
docs/source/api.rst Normal file
View File

@@ -0,0 +1,39 @@
API Reference
=============
This section provides detailed API documentation for the TexTeller package. TexTeller is a tool for detecting and recognizing LaTeX formulas in images and converting mixed text and formula images to markdown.
.. contents:: Table of Contents
:local:
:depth: 2
Image to LaTeX Conversion
-------------------------
.. autofunction:: texteller.api.img2latex
Paragraph to Markdown Conversion
------------------------------
.. autofunction:: texteller.api.paragraph2md
LaTeX Detection
---------------
.. autofunction:: texteller.api.detection.latex_detect
Model Loading
-------------
.. autofunction:: texteller.api.load_model
.. autofunction:: texteller.api.load_tokenizer
.. autofunction:: texteller.api.load_latexdet_model
.. autofunction:: texteller.api.load_textdet_model
.. autofunction:: texteller.api.load_textrec_model
KaTeX Conversion
----------------
.. autofunction:: texteller.api.to_katex

75
docs/source/conf.py Normal file
View File

@@ -0,0 +1,75 @@
# 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:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- 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.
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# -- Project information -----------------------------------------------------
project = 'TexTeller'
copyright = '2025, TexTeller Team'
author = 'TexTeller Team'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'myst_parser',
'sphinx.ext.duration',
'sphinx.ext.intersphinx',
'sphinx.ext.autosectionlabel',
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
'sphinx_copybutton',
# 'sphinx.ext.linkcode',
# 'sphinxarg.ext',
'sphinx_design',
'nbsphinx',
]
templates_path = ['_templates']
exclude_patterns = []
# Autodoc settings
autodoc_member_order = 'bysource'
add_module_names = False
autoclass_content = 'both'
autodoc_default_options = {
'members': True,
'member-order': 'bysource',
'undoc-members': True,
'show-inheritance': True,
'imported-members': True,
}
# Intersphinx settings
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable', None),
'torch': ('https://pytorch.org/docs/stable', None),
'transformers': ('https://huggingface.co/docs/transformers/main/en', None),
}
html_theme = 'sphinx_book_theme'
html_theme_options = {
'repository_url': 'https://github.com/OleehyO/TexTeller',
'use_repository_button': True,
'use_issues_button': True,
'use_edit_page_button': True,
'use_download_button': True,
}
html_logo = "../../assets/logo.svg"

76
docs/source/index.rst Normal file
View File

@@ -0,0 +1,76 @@
.. TexTeller documentation master file, created by
sphinx-quickstart on Sun Apr 20 13:05:53 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
TexTeller Documentation
===========================================
Features
--------
- **Image to LaTeX Conversion**: Convert images containing LaTeX formulas to LaTeX code
- **LaTeX Detection**: Detect and locate LaTeX formulas in mixed text/formula images
- **Paragraph to Markdown**: Convert mixed text and formula images to Markdown format
Installation
-----------
You can install TexTeller using pip:
.. code-block:: bash
pip install texteller
Quick Start
----------
Converting an image to LaTeX:
.. code-block:: python
from texteller import load_model, load_tokenizer, img2latex
# Load models
model = load_model(use_onnx=False)
tokenizer = load_tokenizer()
# Convert image to LaTeX
latex = img2latex(model, tokenizer, ["path/to/image.png"])[0]
Processing a mixed text/formula image:
.. code-block::python
from texteller import (
load_model, load_tokenizer, load_latexdet_model,
load_textdet_model, load_textrec_model, paragraph2md
)
# Load all required models
latex_model = load_model()
tokenizer = load_tokenizer()
latex_detector = load_latexdet_model()
text_detector = load_textdet_model()
text_recognizer = load_textrec_model()
# Convert to markdown
markdown = paragraph2md(
"path/to/mixed_image.png",
latex_detector,
text_detector,
text_recognizer,
latex_model,
tokenizer
)
API Documentation
----------------
For detailed API documentation, please see :doc:`./api`.
.. toctree::
:maxdepth: 2
:hidden:
api