Skip to content

Commit 3a80006

Browse files
committed
docs: restructure sphinx documentation
1 parent 6512b55 commit 3a80006

9 files changed

Lines changed: 98 additions & 149 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ jobs:
6464
with:
6565
parallel-finished: true
6666
base-path: tika
67+
68+
docs:
69+
uses: ./.github/workflows/documentation.yml
Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
# Simple workflow for deploying static content to GitHub Pages
21
name: Documentation
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches: ["master"]
8-
6+
workflow_call:
97
# Allows you to run this workflow manually from the Actions tab
108
workflow_dispatch:
119

12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13-
permissions:
14-
contents: write
15-
pages: write
16-
id-token: write
10+
# Set permissions at the job level.
11+
permissions: {}
1712

1813
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1914
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
@@ -22,32 +17,43 @@ concurrency:
2217
cancel-in-progress: false
2318

2419
jobs:
25-
# Single deploy job since we're just deploying
26-
deploy:
27-
environment:
28-
name: github-pages
29-
url: ${{ steps.deployment.outputs.page_url }}
30-
runs-on: ubuntu-latest
20+
build:
21+
name: Build documentation with Sphinx
22+
runs-on: ubuntu-slim
3123
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v4
34-
- name: Install dependencies
35-
run: |
24+
- uses: actions/checkout@v6
25+
- uses: actions/setup-python@v6
26+
with:
27+
python-version: "3.14"
28+
cache: 'pip'
29+
30+
- run: |
3631
python -m pip install --upgrade pip
3732
python -m pip install . --group=docs
38-
- name: Sphinx APIDoc
39-
run: |
40-
sphinx-apidoc -f -o docs/source/ .
41-
- name: Sphinx build
42-
run: |
43-
sphinx-build -b html docs/source/ docs/build/html
44-
- name: Setup Pages
45-
uses: actions/configure-pages@v5
46-
- name: Upload artifact
47-
uses: actions/upload-pages-artifact@v3
33+
python -m pip list
34+
35+
- run: |
36+
sphinx-build --builder html docs/source/ docs/build/html
37+
38+
- name: Upload artifact (only on push to master)
39+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
40+
uses: actions/upload-pages-artifact@v5
4841
with:
49-
# Upload entire repository
5042
path: './docs/build/html'
43+
44+
deploy:
45+
name: Deploy documentation to GitHub Pages
46+
needs: build
47+
# Deploy only on push to master
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
49+
permissions:
50+
pages: write
51+
id-token: write
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
runs-on: ubuntu-slim
56+
steps:
5157
- name: Deploy to GitHub Pages
5258
id: deployment
53-
uses: actions/deploy-pages@v4
59+
uses: actions/deploy-pages@v5

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ setup.cfg
2323

2424
# Sphinx documentation
2525
docs/build/
26+
# auto-generated by sphinx-apidoc
27+
docs/source/api/

docs/source/conf.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,70 @@
33
# For the full list of built-in configuration values, see the documentation:
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

6+
import importlib.metadata
7+
from datetime import datetime, timezone
8+
69
# -- Project information -----------------------------------------------------
710
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8-
import os
9-
import sys
10-
11-
# Add the parent directory of the documentation root to sys.path
12-
sys.path.insert(0, os.path.abspath("../.."))
13-
14-
project = 'tika-python'
15-
copyright = '2024, Chris A. Mattmann'
16-
author = 'Chris A. Mattmann'
11+
project = "tika-python"
12+
author = "Chris A. Mattmann"
13+
current_year = datetime.now(timezone.utc).astimezone().year
14+
copyright = f"{current_year}, {author}"
15+
version = importlib.metadata.version("tika")
16+
release = version
1717

1818
# -- General configuration ---------------------------------------------------
19-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
19+
# Ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
2020

2121
extensions = [
2222
"sphinx.ext.autodoc",
23+
"sphinx.ext.apidoc",
2324
"sphinx.ext.viewcode",
2425
"sphinx.ext.napoleon",
2526
"sphinx.ext.doctest",
2627
"sphinx.ext.autosectionlabel",
27-
"sphinx.ext.todo",
28-
"sphinx.ext.duration",
29-
"myst_parser"
28+
"myst_parser",
3029
]
3130

32-
templates_path = ['_templates']
33-
exclude_patterns = ['tika.tests*']
31+
master_doc = "index"
32+
exclude_patterns = ["_build"]
3433

34+
nitpicky = True
3535

36+
# -- sphinx-apidoc configuration ---------------------------------------------------
37+
# Ref: https://www.sphinx-doc.org/en/master/usage/extensions/apidoc.html#confval-apidoc_modules
38+
apidoc_modules = [
39+
{
40+
"path": "../../tika",
41+
"destination": "api",
42+
"separate_modules": True,
43+
"module_first": True,
44+
},
45+
]
3646

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

40-
html_theme = 'furo'
41-
html_static_path = ['_static']
50+
REPO_URL = "https://github.com/chrismattmann/tika-python"
51+
52+
html_theme = "furo"
53+
54+
html_theme_options = {
55+
"source_repository": REPO_URL,
56+
"top_of_page_buttons": [], # Note: do not show edit and view buttons
57+
"footer_icons": [
58+
{
59+
"name": "GitHub",
60+
"url": REPO_URL,
61+
# Embedded SVG instructions from furo docs
62+
# Ref: https://pradyunsg.me/furo/customisation/footer/#configuration
63+
"html": """
64+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
65+
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
66+
</svg>
67+
""",
68+
"class": "",
69+
},
70+
],
71+
}
72+

docs/source/index.rst

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
.. tika-python documentation master file, created by
2-
sphinx-quickstart on Sun Apr 14 20:07:31 2024.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
1+
.. include:: ../../README.md
2+
:parser: myst_parser.sphinx_
53

6-
Welcome to tika-python's documentation!
7-
=======================================
4+
Contents
5+
--------
86

97
.. toctree::
10-
:maxdepth: 7
11-
:caption: Contents:
8+
:maxdepth: 1
9+
10+
API <api/modules>
1211

13-
readme
14-
tika
1512

1613
Indices and tables
17-
==================
14+
------------------
1815

1916
* :ref:`genindex`
2017
* :ref:`modindex`
21-
* :ref:`search`

docs/source/modules.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/source/readme.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/source/tika.rst

Lines changed: 0 additions & 77 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ docs = [
5050
[project.urls]
5151
homepage = "http://github.com/chrismattmann/tika-python"
5252
repository = "http://github.com/chrismattmann/tika-python.git"
53+
documentation = "https://chrismattmann.github.io/tika-python"
5354

5455
[project.scripts]
5556
tika-python = "tika.tika:main"

0 commit comments

Comments
 (0)