Skip to content

Commit c19d422

Browse files
committed
Add docs
Closes #35
1 parent 6f75061 commit c19d422

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,25 @@ jobs:
1818
allow-prereleases: true
1919
- run: sudo apt-get update
2020
- run: sudo apt-get install libgmp-dev
21+
- run: sudo apt-get install texlive texlive-latex-extra latexmk
22+
if: matrix.python-version == 3.13
2123
- run: pip install --upgrade pip
2224
- run: pip --verbose install --editable .[develop]
25+
if: matrix.python-version != 3.13
26+
- run: pip --verbose install --editable .[develop,docs]
27+
if: matrix.python-version == 3.13
2328
- run: ruff check
2429
- run: pytest
30+
- name: Building docs
31+
if: matrix.python-version == 3.13
32+
run: |
33+
sphinx-build --color -W --keep-going -b html docs build/sphinx/html
34+
sphinx-build --color -W --keep-going -b latex docs build/sphinx/latex
35+
make -C build/sphinx/latex all-pdf
36+
- name: Archive build artifacts
37+
uses: actions/upload-artifact@v4
38+
if: matrix.python-version == 3.13
39+
with:
40+
path: |
41+
build/sphinx/html/
42+
build/sphinx/latex/python-gmp.pdf

.readthedocs.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
formats:
3+
- htmlzip
4+
- pdf
5+
build:
6+
os: ubuntu-22.04
7+
apt_packages:
8+
- libmpc-dev
9+
- gcc
10+
tools:
11+
python: "3"
12+
python:
13+
install:
14+
- method: pip
15+
path: .
16+
extra_requirements:
17+
- docs
18+
sphinx:
19+
fail_on_warning: true

docs/conf.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
python-gmp documentation build configuration file.
3+
4+
This file is execfile()d with the current directory set to its containing dir.
5+
6+
The contents of this file are pickled, so don't put values in the namespace
7+
that aren't pickleable (module imports are okay, they're removed
8+
automatically).
9+
"""
10+
11+
import packaging.version
12+
13+
import gmp
14+
15+
# Add any Sphinx extension module names here, as strings. They can be extensions
16+
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
17+
extensions = ['sphinx.ext.autodoc']
18+
19+
# The name of a reST role (builtin or Sphinx extension) to use as the
20+
# default role, that is, for text marked up `like this`.
21+
default_role = 'py:obj'
22+
23+
# Sphinx will warn about all references where the target cannot be found.
24+
nitpicky = True
25+
26+
# This value selects if automatically documented members are sorted
27+
# alphabetical (value 'alphabetical'), by member type (value 'groupwise')
28+
# or by source order (value 'bysource').
29+
autodoc_member_order = 'groupwise'
30+
31+
# The default options for autodoc directives. They are applied to all
32+
# autodoc directives automatically.
33+
autodoc_default_options = {'members': True}
34+
35+
# General information about the project.
36+
project = gmp.__package__
37+
copyright = '2024, Sergey B Kirpichev'
38+
39+
gmp_version = packaging.version.parse(gmp.__version__)
40+
41+
# The version info for the project you're documenting, acts as replacement for
42+
# |version| and |release|, also used in various other places throughout the
43+
# built documents.
44+
#
45+
# The short X.Y version.
46+
version = f"{gmp_version.major}.{gmp_version.minor}"
47+
# The full version, including alpha/beta/rc tags.
48+
release = gmp.__version__
49+
50+
# Grouping the document tree into LaTeX files. List of tuples
51+
# (source start file, target name, title, author, documentclass [howto/manual]).
52+
latex_documents = [('index', 'python-gmp.tex', 'python-gmp Documentation',
53+
'Sergey B Kirpichev', 'manual')]

docs/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Documentation for python-gmp
2+
============================
3+
4+
.. automodule:: gmp
5+
:members:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ content-type = 'text/x-rst'
3939
Homepage = 'https://github.com/diofant/python-gmp'
4040
'Source Code' = 'https://github.com/diofant/python-gmp'
4141
'Bug Tracker' = 'https://github.com/diofant/python-gmp/issues'
42+
Documentation = 'https://python-gmp.readthedocs.io/'
4243

4344
[tool.setuptools]
4445
ext-modules = [{name = "gmp", sources = ["main.c"], libraries = ["gmp"]}]
@@ -53,6 +54,7 @@ ext-modules = [{name = "gmp", sources = ["main.c"], libraries = ["gmp"]}]
5354
tests = ["pytest", "hypothesis",
5455
"gmpy2; platform_python_implementation!='PyPy'"]
5556
develop = ["python-gmp[tests]", "ruff"]
57+
docs = ['sphinx']
5658

5759
[tool.pytest.ini_options]
5860
addopts = "--durations=7"

0 commit comments

Comments
 (0)