Skip to content

Commit 147bbbd

Browse files
flying-sheepFrankie Robertson
andauthored
Modernize docs (#17)
Co-authored-by: Frankie Robertson <[email protected]>
1 parent 883a584 commit 147bbbd

File tree

8 files changed

+75
-37
lines changed

8 files changed

+75
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Caches
22
__pycache__/
33
/*cache/
4+
/node_modules/
45

56
# Build artifacts
67
/dist/

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -13,15 +13,15 @@ repos:
1313
- id: no-commit-to-branch
1414
args: ["--branch=main"]
1515
- repo: https://github.com/psf/black
16-
rev: "23.3.0"
16+
rev: "23.12.0"
1717
hooks:
1818
- id: black
1919
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: v0.0.275
20+
rev: v0.1.7
2121
hooks:
2222
- id: ruff
2323
args: ["--fix"]
2424
- repo: https://github.com/pre-commit/mirrors-prettier
25-
rev: v2.7.1
25+
rev: v4.0.0-alpha.4
2626
hooks:
2727
- id: prettier

.readthedocs.yml renamed to .readthedocs.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.11"
7-
jobs:
8-
post_install:
9-
- pip install poetry
10-
- poetry config virtualenvs.create false
11-
- poetry install --with=docs
7+
8+
python:
9+
install:
10+
- method: pip
11+
path: .
12+
extra_requirements:
13+
- docs
14+
- annlibs
1215

1316
sphinx:
1417
configuration: docs/conf.py

README.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ perform competitively in high dimensional spaces.
3535
Development
3636
===========
3737

38-
This project is managed using Poetry_ and pre-commit_.
39-
To get started, run ``pre-commit install`` once and ``poetry install ...``
40-
whenever dependencies have changed. E.g. @flying-sheep runs::
41-
42-
poetry install --with=test --extras=annlibs
43-
44-
This installs all optional (dev) dependencies except for those to build the docs.
45-
pre-commit_ comes into play on every `git commit` after installation.
38+
This project is managed using Hatch_ and pre-commit_. To get started, run ``pre-commit
39+
install`` and ``hatch env create``. Run all commands using ``hatch run python
40+
<command>`` which will ensure the environment is kept up to date. pre-commit_ comes into
41+
play on every `git commit` after installation.
4642

4743
Consult ``pyproject.toml`` for which dependency groups and extras exist,
48-
and the poetry help or user guide for more info on what they are.
44+
and the Hatch help or user guide for more info on what they are.
4945

50-
.. _poetry: https://python-poetry.org/
46+
.. _Hatch: https://hatch.pypa.io/
5147
.. _pre-commit: https://pre-commit.com/

docs/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
66
SPHINXOPTS ?=
7-
SPHINXBUILD ?= poetry run sphinx-build
8-
SOURCEDIR = .
9-
BUILDDIR = _build
7+
SPHINXBUILD ?= hatch run sphinx-build
8+
SOURCEDIR = $(CURDIR)
9+
BUILDDIR = $(CURDIR)/_build
1010

1111
# Put it first so that "make" without argument is like "make help".
1212
help:

docs/_templates/autosummary/class.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. add toctree option to make autodoc generate the pages
6+
7+
.. autoclass:: {{ objname }}
8+
9+
{% block attributes %}
10+
{% if attributes %}
11+
.. rubric:: Attributes
12+
13+
.. autosummary::
14+
:toctree: .
15+
{% for item in attributes %}
16+
~{{ fullname }}.{{ item }}
17+
{%- endfor %}
18+
{% endif %}
19+
{% endblock %}
20+
21+
{% block methods %}
22+
{% if methods %}
23+
.. rubric:: Methods
24+
25+
.. autosummary::
26+
:toctree: .
27+
{% for item in methods %}
28+
{%- if item != '__init__' %}
29+
~{{ fullname }}.{{ item }}
30+
{%- endif -%}
31+
{%- endfor %}
32+
{% endif %}
33+
{% endblock %}

docs/conf.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

7+
import os
8+
79
# -- Path setup --------------------------------------------------------------
810

911
# If extensions (or modules to document with autodoc) are in another directory,
1012
# add these directories to sys.path here. If the directory is relative to the
1113
# documentation root, use os.path.abspath to make it absolute, like shown here.
1214
#
13-
# import os
1415
# import sys
1516
# sys.path.insert(0, os.path.abspath('.'))
1617

17-
import sphinx_rtd_theme
18-
1918
# -- Project information -----------------------------------------------------
2019

2120
project = "sklearn-ann"
@@ -31,9 +30,11 @@
3130
extensions = [
3231
"sphinx.ext.autodoc",
3332
"sphinx.ext.autosummary",
34-
"numpydoc",
33+
"sphinx.ext.napoleon",
34+
"scanpydoc.definition_list_typed_field",
35+
"scanpydoc.rtd_github_links",
3536
"sphinx_issues",
36-
"sphinx.ext.viewcode",
37+
"sphinx.ext.linkcode",
3738
]
3839

3940
# Add any paths that contain templates here, relative to this directory.
@@ -45,19 +46,21 @@
4546
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4647

4748
autosummary_generate = True
49+
autodoc_default_options = {
50+
"undoc-members": True,
51+
}
4852

4953

5054
# -- Options for HTML output -------------------------------------------------
5155

5256
# The theme to use for HTML and HTML Help pages. See the documentation for
5357
# a list of builtin themes.
5458
#
55-
html_theme = "sphinx_rtd_theme"
56-
57-
# Add any paths that contain custom static files (such as style sheets) here,
58-
# relative to this directory. They are copied after the builtin static files,
59-
# so a file named "default.css" will overwrite the builtin "default.css".
60-
# html_static_path = ["_static"]
61-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
59+
html_theme = "sphinx_book_theme"
60+
html_theme_options = dict(
61+
repository_url="https://github.com/frankier/sklearn-ann",
62+
repository_branch=os.environ.get("READTHEDOCS_GIT_IDENTIFIER", "main"),
63+
)
64+
rtd_links_prefix = "src"
6265

6366
autodoc_mock_imports = ["annoy", "faiss", "pynndescent", "nmslib"]

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ tests = [
1919
"pytest-cov>=2.10.1",
2020
]
2121
docs = [
22-
"sphinx>=4.2.0",
22+
"sphinx>=7",
2323
"sphinx-gallery>=0.8.2",
24-
"sphinx-rtd-theme>=0.5.1",
24+
"sphinx-book-theme>=1.1.0rc1",
2525
"sphinx-issues>=1.2.0",
2626
"numpydoc>=1.1.0",
27-
"matplotlib>=3.3.3"
27+
"matplotlib>=3.3.3",
28+
"scanpydoc",
2829
]
2930
annoy = [
3031
"annoy>=1.17.0,<2.0.0",
@@ -81,6 +82,7 @@ features = [
8182

8283
[tool.hatch.envs.default.scripts]
8384
test = "pytest {args:tests}"
85+
build-docs = "sphinx-build -M html docs docs/_build"
8486

8587
[tool.hatch.build.targets.wheel]
8688
packages = ["src/sklearn_ann"]

0 commit comments

Comments
 (0)