Skip to content

Commit 609ad2d

Browse files
authored
Add (now mandatory) .readthedocs.yaml file, add docs requirements.txt and update sphinx conf (kivy#2916)
* Add (now mandatory) .readthedocs.yaml file, add docs requirements.txt and update sphinx conf * Do not use a double source of truth for docs dependencies. extra_require is great, but unfortunately we can't use it on readthedocs builds
1 parent 64ff7a8 commit 609ad2d

File tree

5 files changed

+51
-19
lines changed

5 files changed

+51
-19
lines changed

.github/workflows/push.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ jobs:
244244
steps:
245245
- uses: actions/checkout@v4
246246
- name: Requirements
247-
run: python3 -m pip install .[docs]
247+
run: |
248+
python -m pip install --upgrade pip
249+
pip install -r doc/requirements.txt
248250
- name: Check links
249251
run: sphinx-build -b linkcheck doc/source doc/build
250252
- name: Generate documentation

.readthedocs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3"
10+
11+
python:
12+
install:
13+
- requirements: doc/requirements.txt
14+
15+
sphinx:
16+
configuration: doc/source/conf.py

doc/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sphinx~=7.2.6
2+
furo==2023.9.10

doc/source/conf.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
15+
import datetime
1616
import os
17-
import shlex
17+
import re
18+
import sys
1819

1920
# If extensions (or modules to document with autodoc) are in another directory,
2021
# add these directories to sys.path here. If the directory is relative to the
2122
# documentation root, use os.path.abspath to make it absolute, like shown here.
2223
#sys.path.insert(0, os.path.abspath('.'))
23-
sys.path.append(os.path.abspath('ext/sphinx_rtd_theme'))
2424
sys.path.append(os.path.abspath('../../pythonforandroid'))
2525

26-
import sphinx_rtd_theme
27-
2826
# -- General configuration ------------------------------------------------
2927

3028
# If your documentation needs a minimal Sphinx version, state it here.
@@ -54,18 +52,35 @@
5452
master_doc = 'index'
5553

5654
# General information about the project.
57-
project = u'python-for-android'
58-
copyright = u'2015, Alexander Taylor'
59-
author = u'Alexander Taylor'
55+
project = 'python-for-android'
56+
57+
_today = datetime.datetime.now()
58+
59+
author = 'Kivy Team and other contributors'
60+
61+
copyright = f'{_today.year}, {author}'
6062

6163
# The version info for the project you're documenting, acts as replacement for
6264
# |version| and |release|, also used in various other places throughout the
6365
# built documents.
6466
#
67+
68+
# Lookup the version from the pyjnius module, without installing it
69+
# since readthedocs.org may have issue to install it.
70+
# Read the version from the __init__.py file, without importing it.
71+
def get_version():
72+
with open(
73+
os.path.join(os.path.abspath("../.."), "pythonforandroid", "__init__.py")
74+
) as fp:
75+
for line in fp:
76+
m = re.search(r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$', line)
77+
if m:
78+
return m.group(2)
79+
6580
# The short X.Y version.
66-
version = '0.1'
81+
version = get_version()
6782
# The full version, including alpha/beta/rc tags.
68-
release = '0.1'
83+
release = get_version()
6984

7085
# The language for content autogenerated by Sphinx. Refer to documentation
7186
# for a list of supported languages.
@@ -82,7 +97,7 @@
8297

8398
# List of patterns, relative to source directory, that match files and
8499
# directories to ignore when looking for source files.
85-
exclude_patterns = ['ext/*', ]
100+
exclude_patterns = []
86101

87102
# The reST default role (used for this markup: `text`) to use for all
88103
# documents.
@@ -116,15 +131,15 @@
116131

117132
# The theme to use for HTML and HTML Help pages. See the documentation for
118133
# a list of builtin themes.
119-
html_theme = 'sphinx_rtd_theme'
134+
html_theme = 'furo'
120135

121136
# Theme options are theme-specific and customize the look and feel of a theme
122137
# further. For a list of options available for each theme, see the
123138
# documentation.
124139
#html_theme_options = {}
125140

126141
# Add any paths that contain custom themes here, relative to this directory.
127-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
142+
# html_theme_path = []
128143

129144
# The name for this set of Sphinx documents. If None, it defaults to
130145
# "<project> v<release> documentation".
@@ -230,8 +245,8 @@
230245
# (source start file, target name, title,
231246
# author, documentclass [howto, manual, or own class]).
232247
latex_documents = [
233-
(master_doc, 'python-for-android.tex', u'python-for-android Documentation',
234-
u'Alexander Taylor', 'manual'),
248+
(master_doc, 'python-for-android.tex', 'python-for-android Documentation',
249+
author, 'manual'),
235250
]
236251

237252
# The name of an image file (relative to this directory) to place at the top of

setup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ def recursively_include(results, directory, patterns):
9595
url='https://github.com/kivy/python-for-android',
9696
license='MIT',
9797
install_requires=install_reqs,
98-
extras_require={
99-
"docs": ["sphinx", "sphinx-rtd-theme"],
100-
},
10198
entry_points={
10299
'console_scripts': [
103100
'python-for-android = pythonforandroid.entrypoints:main',

0 commit comments

Comments
 (0)