Skip to content

Commit e9e7c96

Browse files
authored
Create GitHub Pages docs with Sphinx (TheAlgorithms#11888)
1 parent 260e3d8 commit e9e7c96

File tree

16 files changed

+179
-9
lines changed

16 files changed

+179
-9
lines changed

Diff for: .devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md
2-
ARG VARIANT=3.12-bookworm
2+
ARG VARIANT=3.13-bookworm
33
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
44
COPY requirements.txt /tmp/pip-tmp/
55
RUN python3 -m pip install --upgrade pip \

Diff for: .devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Update 'VARIANT' to pick a Python version: 3, 3.11, 3.10, 3.9, 3.8
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local on arm64/Apple Silicon.
10-
"VARIANT": "3.12-bookworm",
10+
"VARIANT": "3.13-bookworm",
1111
}
1212
},
1313

Diff for: .github/CODEOWNERS

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/.* @cclauss
1111

12-
# /arithmetic_analysis/
13-
1412
# /backtracking/
1513

1614
# /bit_manipulation/

Diff for: .github/workflows/build.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ jobs:
2525
- name: Run tests
2626
# TODO: #8818 Re-enable quantum tests
2727
run: pytest
28-
--ignore=quantum/q_fourier_transform.py
2928
--ignore=computer_vision/cnn_classification.py
29+
--ignore=docs/conf.py
3030
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
3131
--ignore=machine_learning/lstm/lstm_prediction.py
3232
--ignore=neural_network/input_data.py
3333
--ignore=project_euler/
34+
--ignore=quantum/q_fourier_transform.py
3435
--ignore=scripts/validate_solutions.py
3536
--cov-report=term-missing:skip-covered
3637
--cov=. .

Diff for: .github/workflows/sphinx.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: sphinx
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the "master" branch
5+
push:
6+
branches: ["master"]
7+
pull_request:
8+
branches: ["master"]
9+
# Or manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build_docs:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: 3.13
32+
allow-prereleases: true
33+
- run: pip install --upgrade pip
34+
- run: pip install myst-parser sphinx-autoapi sphinx-pyproject
35+
- uses: actions/configure-pages@v5
36+
- run: sphinx-build -c docs . docs/_build/html
37+
- uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: docs/_build/html
40+
41+
deploy_docs:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
if: github.event_name != 'pull_request'
46+
needs: build_docs
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/deploy-pages@v4
50+
id: deployment

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pre-commit run --all-files --show-diff-on-failure
7777

7878
We want your work to be readable by others; therefore, we encourage you to note the following:
7979

80-
- Please write in Python 3.12+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
80+
- Please write in Python 3.13+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
8181
- Please focus hard on the naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
8282
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
8383
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.

Diff for: DIRECTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@
351351
* [Power](divide_and_conquer/power.py)
352352
* [Strassen Matrix Multiplication](divide_and_conquer/strassen_matrix_multiplication.py)
353353

354+
## Docs
355+
* [Conf](docs/conf.py)
356+
354357
## Dynamic Programming
355358
* [Abbreviation](dynamic_programming/abbreviation.py)
356359
* [All Construct](dynamic_programming/all_construct.py)

Diff for: LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
## MIT License
22

33
Copyright (c) 2016-2022 TheAlgorithms and contributors
44

File renamed without changes.

Diff for: docs/conf.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from sphinx_pyproject import SphinxConfig
2+
3+
project = SphinxConfig("../pyproject.toml", globalns=globals()).name

Diff for: financial/ABOUT.md renamed to financial/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Interest
1+
# Interest
22

33
* Compound Interest: "Compound interest is calculated by multiplying the initial principal amount by one plus the annual interest rate raised to the number of compound periods minus one." [Compound Interest](https://www.investopedia.com/)
44
* Simple Interest: "Simple interest paid or received over a certain period is a fixed percentage of the principal amount that was borrowed or lent. " [Simple Interest](https://www.investopedia.com/)

Diff for: index.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# TheAlgorithms/Python
2+
```{toctree}
3+
:maxdepth: 2
4+
:caption: index.md
5+
6+
<!-- CONTRIBUTING.md must be the FIRST doc and README.md can come after. -->
7+
CONTRIBUTING.md
8+
README.md
9+
LICENSE.md
10+
```

Diff for: pyproject.toml

+105-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
[project]
2+
name = "thealgorithms-python"
3+
version = "0.0.1"
4+
description = "TheAlgorithms in Python"
5+
authors = [ { name = "TheAlgorithms Contributors" } ]
6+
requires-python = ">=3.13"
7+
classifiers = [
8+
"Programming Language :: Python :: 3 :: Only",
9+
"Programming Language :: Python :: 3.13",
10+
11+
]
12+
optional-dependencies.docs = [
13+
"myst-parser",
14+
"sphinx-autoapi",
15+
"sphinx-pyproject",
16+
]
17+
118
[tool.ruff]
2-
target-version = "py312"
19+
target-version = "py313"
320

421
output-format = "full"
522
lint.select = [
@@ -113,6 +130,9 @@ lint.pylint.max-statements = 88 # default: 50
113130
ignore-words-list = "3rt,ans,bitap,crate,damon,fo,followings,hist,iff,kwanza,manuel,mater,secant,som,sur,tim,toi,zar"
114131
skip = "./.*,*.json,ciphers/prehistoric_men.txt,project_euler/problem_022/p022_names.txt,pyproject.toml,strings/dictionary.txt,strings/words.txt"
115132

133+
[tool.pyproject-fmt]
134+
max_supported_python = "3.13"
135+
116136
[tool.pytest.ini_options]
117137
markers = [
118138
"mat_ops: mark a test as utilizing matrix operations.",
@@ -129,3 +149,87 @@ omit = [
129149
"project_euler/*",
130150
]
131151
sort = "Cover"
152+
153+
[tool.sphinx-pyproject]
154+
copyright = "2014, TheAlgorithms"
155+
autoapi_dirs = [
156+
"audio_filters",
157+
"backtracking",
158+
"bit_manipulation",
159+
"blockchain",
160+
"boolean_algebra",
161+
"cellular_automata",
162+
"ciphers",
163+
"compression",
164+
"computer_vision",
165+
"conversions",
166+
"data_structures",
167+
"digital_image_processing",
168+
"divide_and_conquer",
169+
"dynamic_programming",
170+
"electronics",
171+
"file_transfer",
172+
"financial",
173+
"fractals",
174+
"fuzzy_logic",
175+
"genetic_algorithm",
176+
"geodesy",
177+
"geometry",
178+
"graphics",
179+
"graphs",
180+
"greedy_methods",
181+
"hashes",
182+
"knapsack",
183+
"linear_algebra",
184+
"linear_programming",
185+
"machine_learning",
186+
"maths",
187+
"matrix",
188+
"networking_flow",
189+
"neural_network",
190+
"other",
191+
"physics",
192+
"project_euler",
193+
"quantum",
194+
"scheduling",
195+
"searches",
196+
"sorts",
197+
"strings",
198+
"web_programming",
199+
]
200+
autoapi_member_order = "groupwise"
201+
# autoapi_python_use_implicit_namespaces = true
202+
exclude_patterns = [
203+
".*/*",
204+
"docs/",
205+
]
206+
extensions = [
207+
"autoapi.extension",
208+
"myst_parser",
209+
]
210+
html_static_path = [ "_static" ]
211+
html_theme = "alabaster"
212+
myst_enable_extensions = [
213+
"amsmath",
214+
"attrs_inline",
215+
"colon_fence",
216+
"deflist",
217+
"dollarmath",
218+
"fieldlist",
219+
"html_admonition",
220+
"html_image",
221+
# "linkify",
222+
"replacements",
223+
"smartquotes",
224+
"strikethrough",
225+
"substitution",
226+
"tasklist",
227+
]
228+
myst_fence_as_directive = [
229+
"include",
230+
]
231+
templates_path = [ "_templates" ]
232+
[tool.sphinx-pyproject.source_suffix]
233+
".rst" = "restructuredtext"
234+
# ".txt" = "markdown"
235+
".md" = "markdown"

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ requests
1515
rich
1616
# scikit-fuzzy # uncomment once fuzzy_logic/fuzzy_operations.py is fixed
1717
scikit-learn
18+
sphinx_pyproject
1819
statsmodels
1920
sympy
2021
tensorflow ; python_version < '3.13'

Diff for: source/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)