Skip to content

Create GitHub Pages docs with Sphinx #11888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md
ARG VARIANT=3.12-bookworm
ARG VARIANT=3.13-bookworm
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
COPY requirements.txt /tmp/pip-tmp/
RUN python3 -m pip install --upgrade pip \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Update 'VARIANT' to pick a Python version: 3, 3.11, 3.10, 3.9, 3.8
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.12-bookworm",
"VARIANT": "3.13-bookworm",
}
},

Expand Down
2 changes: 0 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

/.* @cclauss

# /arithmetic_analysis/

# /backtracking/

# /bit_manipulation/
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ jobs:
- name: Run tests
# TODO: #8818 Re-enable quantum tests
run: pytest
--ignore=quantum/q_fourier_transform.py
--ignore=computer_vision/cnn_classification.py
--ignore=docs/conf.py
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
--ignore=machine_learning/lstm/lstm_prediction.py
--ignore=neural_network/input_data.py
--ignore=project_euler/
--ignore=quantum/q_fourier_transform.py
--ignore=scripts/validate_solutions.py
--cov-report=term-missing:skip-covered
--cov=. .
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: sphinx

on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: ["master"]
pull_request:
branches: ["master"]
# Or manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13
allow-prereleases: true
- run: pip install --upgrade pip
- run: pip install myst-parser sphinx-autoapi sphinx-pyproject
- uses: actions/configure-pages@v5
- run: sphinx-build -c docs . docs/_build/html
- uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html

deploy_docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.event_name != 'pull_request'
needs: build_docs
runs-on: ubuntu-latest
steps:
- uses: actions/deploy-pages@v4
id: deployment
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pre-commit run --all-files --show-diff-on-failure

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

- 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.
- 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.
- 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.
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
Expand Down
3 changes: 3 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@
* [Power](divide_and_conquer/power.py)
* [Strassen Matrix Multiplication](divide_and_conquer/strassen_matrix_multiplication.py)

## Docs
* [Conf](docs/conf.py)

## Dynamic Programming
* [Abbreviation](dynamic_programming/abbreviation.py)
* [All Construct](dynamic_programming/all_construct.py)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
## MIT License

Copyright (c) 2016-2022 TheAlgorithms and contributors

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from sphinx_pyproject import SphinxConfig

project = SphinxConfig("../pyproject.toml", globalns=globals()).name
2 changes: 1 addition & 1 deletion financial/ABOUT.md → financial/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Interest
# Interest

* 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/)
* 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/)
10 changes: 10 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TheAlgorithms/Python
```{toctree}
:maxdepth: 2
:caption: index.md

<!-- CONTRIBUTING.md must be the FIRST doc and README.md can come after. -->
CONTRIBUTING.md
README.md
LICENSE.md
```
106 changes: 105 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
[project]
name = "thealgorithms-python"
version = "0.0.1"
description = "TheAlgorithms in Python"
authors = [ { name = "TheAlgorithms Contributors" } ]
requires-python = ">=3.13"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.13",

]
optional-dependencies.docs = [
"myst-parser",
"sphinx-autoapi",
"sphinx-pyproject",
]

[tool.ruff]
target-version = "py312"
target-version = "py313"

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

[tool.pyproject-fmt]
max_supported_python = "3.13"

[tool.pytest.ini_options]
markers = [
"mat_ops: mark a test as utilizing matrix operations.",
Expand All @@ -129,3 +149,87 @@ omit = [
"project_euler/*",
]
sort = "Cover"

[tool.sphinx-pyproject]
copyright = "2014, TheAlgorithms"
autoapi_dirs = [
"audio_filters",
"backtracking",
"bit_manipulation",
"blockchain",
"boolean_algebra",
"cellular_automata",
"ciphers",
"compression",
"computer_vision",
"conversions",
"data_structures",
"digital_image_processing",
"divide_and_conquer",
"dynamic_programming",
"electronics",
"file_transfer",
"financial",
"fractals",
"fuzzy_logic",
"genetic_algorithm",
"geodesy",
"geometry",
"graphics",
"graphs",
"greedy_methods",
"hashes",
"knapsack",
"linear_algebra",
"linear_programming",
"machine_learning",
"maths",
"matrix",
"networking_flow",
"neural_network",
"other",
"physics",
"project_euler",
"quantum",
"scheduling",
"searches",
"sorts",
"strings",
"web_programming",
]
autoapi_member_order = "groupwise"
# autoapi_python_use_implicit_namespaces = true
exclude_patterns = [
".*/*",
"docs/",
]
extensions = [
"autoapi.extension",
"myst_parser",
]
html_static_path = [ "_static" ]
html_theme = "alabaster"
myst_enable_extensions = [
"amsmath",
"attrs_inline",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
# "linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]
myst_fence_as_directive = [
"include",
]
templates_path = [ "_templates" ]
[tool.sphinx-pyproject.source_suffix]
".rst" = "restructuredtext"
# ".txt" = "markdown"
".md" = "markdown"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ requests
rich
# scikit-fuzzy # uncomment once fuzzy_logic/fuzzy_operations.py is fixed
scikit-learn
sphinx_pyproject
statsmodels
sympy
tensorflow ; python_version < '3.13'
Expand Down
Empty file removed source/__init__.py
Empty file.